A pair of desktop utilities: calendar, folder merge
A pair of basic tkinter desktop utility programs that others may find useful: 1) frigcal -- a refrigerator style calendar desktop GUI 2) mergeall -- do-it-yourself cloud storage, script + GUI Both were coded in part as supplements for book readers, but have grown useful enough to merit a wider post and broader user testing. Feedback welcome; details follow. 1) frigcal -- a refrigerator style calendar desktop GUI Documentation: http://learning-python.com/README-frigcal.html Download: http://learning-python.com/frigcal.zip Screenshots: http://learning-python.com/screenshots/01-win7-main-window.png http://learning-python.com/screenshots/02-win7-clones-and-images.png http://learning-python.com/screenshots/ A Python 3.X program that implements a basic personal calendar GUI. It uses portable iCalendar files for event storage, and sports Python coded configuration, persistent events, event colorization, multiple calendar files, multiple month windows, and automatic calendar backups. This program is not an Outlook replacement: it does not implement tools such as task scheduling, journaling, alarms, invitations, or recurring or multiday events. In exchange for its limited utility, though, this program minimizes code and GUI complexity; reduces the risk of data loss; and yields a calendar sufficient for most personal needs, that requires neither a subscription nor an account log-in. 2) mergeall -- do-it-yourself cloud storage, script + GUI Documentation: http://www.rmi.net/~lutz/mergeall.html Download: http://www.rmi.net/~lutz/mergeall.zip Screenshots: http://www.rmi.net/~lutz/launch-mergeall-GUI-screenshot-main.png http://www.rmi.net/~lutz/mergeall-desktop-screenshot-tablet.png http://www.rmi.net/~lutz/mergeall-desktop-screenshot-linux.png A Python 3.X/2.X script and GUI useful for managing backups and changes in multiple copies of large directory trees (folders). Designed to quickly synchronize changes in content mirrored across multiple devices such as laptops, tablets, and USB flashdrives, this program in some contexts can provide a manual alternative to cloud-based storage. Directory tree synchronization isn't the same as a cloud, of course; but together with fast local storage devices, this program might just help you avoid paying to store your personal data at sites that may share it with, or sell it to, both advertisers and government agencies (who, shockingly, may not have your best interest at heart). Cheers, --Mark Lutz (http://learning-python.com, http://www.rmi.net/~lutz) -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Microsoft Visual C++ Compiler for Python 2.7
Microsoft has released a compiler package for Python 2.7 to make it easier for people to build and distribute their C extension modules on Windows. The Microsoft Visual C++ Compiler for Python 2.7 is available from: http://aka.ms/vcpython27 This package contains all the tools and headers required to build C extension modules for Python 2.7 32-bit and 64-bit (note that some extension modules require 3rd party dependencies such as OpenSSL or libxml2 that are not included). Other versions of Python built with Visual C++ 2008 are also supported. You can install the package without requiring administrative privileges and, with the latest version of setuptools, use tools such as pip, wheel, or a setup.py file to produce binaries on Windows. (Note: This version of Visual C++ is no longer supported by Microsoft, and so new features, support, or bug fixes are not available.) -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Leap year
On Saturday, September 27, 2014 9:21:15 AM UTC+5:30, Seymore4Head wrote: Still practicing. Since this is listed as a Pseudocode, I assume this is a good way to explain something. That means I can also assume my logic is fading with age. http://en.wikipedia.org/wiki/Leap_year#Algorithm Me trying to look at the algorithm, it would lead me to try something like: if year % 4 !=0: return False elif year % 100 !=0: return True elif year % 400 !=0: return False Since it is a practice problem I have the answer: def is_leap_year(year): return ((year % 4) == 0 and ((year % 100) != 0 or (year % 400) == 0)) I didn't have any problem when I did this: if year % 400 == 0: print (Not leap year) elif year % 100 == 0: print (Leap year) elif year % 4 == 0: print (Leap year) else: print (Not leap year) Python has an if-expression distinct from the if-statement. However its confusing because its order is 'upside down' So below I use C's if-expression a?b:c to state some 'laws' of programming and leave it as an exercise to pythonify them a?T:F ≡ a A a?F:T ≡ not a B a?T:b ≡ a or b C a?b:F ≡ a and bD if p: E return x else: return y ≡ return (p ? x : y) Likewise if p F print x else print y ≡ print (p ? x : y) Now putting: a ≜ y%4==0 b ≜ y%100!=0 c ≜ y%400 == 0 the expression that is the (given) answer is a and (b or c) Lets use the above laws to open it up by C a and (b ? T: c) by D a?(b?T:c):F year%4==0 ? (y%100!=0 ? T: y%400==0) : F -- Now lets take your version: if year % 400 == 0: print (Not leap year) elif year % 100 == 0: print (Leap year) elif year % 4 == 0: print (Leap year) else: print (Not leap year) And now 'de-print' it [A good idea though I wont suggest it to you again!] print (!c ? F : (b? T : (a? T : F))) Forget about the print since its irrelevant and concentrate on (!c ? F : (b? T : (a? T : F))) by A = (!c ? F : (b? T : a)) by B = (c ? (b? T : a) : F) by D = (c and (b?T:a) by C = c and (b or a) Lets re-substitute a,b,c = y%400==0 and (y%100 !=0 or y%4 == 0) which interpreted says that ONLY years divisible by 400 are leap and not even all those!! -- https://mail.python.org/mailman/listinfo/python-list
Obscuring Python source from end users
Hello list Python 3.4 applies. I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know this project as an Excel add-in. Now, internal audit takes exception in some cases if users are able to see the source code. So I'm wondering if anyone has clever suggestions in this regard... My current plan is to modify the bdist_wheel setuptools extension so that it can produce distributions with only the .pyc files, laid out so that they will be importable in the normal way. This will be sufficient to satisfy internal audit, and will not negatively impact our users. However there are obvious downsides, including the overhead of maintaining separate wheels for different architectures and (in the future) Python versions. Not to mention that this plan seems to go against the grain of how Python wants to use byte code files... Is there a better solution? -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
On Mon, Sep 29, 2014 at 5:36 PM, norman.i...@gmail.com wrote: I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know this project as an Excel add-in. Now, internal audit takes exception in some cases if users are able to see the source code. The solution is to fix your internal audit. There's fundamentally no way to hide the source code, and it's going to add complexity. Demonstrate that it could take you a large number of man-hours and achieve little, and just declare that the source code IS what you want. Alternatively, you could do a source-level reformat that crunches everything down as much as possible, while still producing syntactically-identical source code. Remove all the comments, shorten local names to one letter, etc. That would result in something that, while still perfectly executable, won't be nearly as helpful. It wouldn't be nice readable source code, at least. Would your audit be satisfied with that? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
Thanks for the reply! I'm not concerned about hiding the source code in a fundamental way. The condition that needs to be satisfied is that independent validators (in the organisation) must not have access to the source code. Crunching the source is an interesting idea that could achieve that end, but it seems fraught with problems like maintaining consistency between renaming objects in a module and renaming where imports happen. -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
On Mon, 29 Sep 2014 00:36:47 -0700, norman.ives wrote: Hello list Python 3.4 applies. I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know this project as an Excel add-in. Now, internal audit takes exception in some cases if users are able to see the source code. So I'm wondering if anyone has clever suggestions in this regard... My current plan is to modify the bdist_wheel setuptools extension so that it can produce distributions with only the .pyc files, laid out so that they will be importable in the normal way. This will be sufficient to satisfy internal audit, and will not negatively impact our users. However there are obvious downsides, including the overhead of maintaining separate wheels for different architectures and (in the future) Python versions. Not to mention that this plan seems to go against the grain of how Python wants to use byte code files... Is there a better solution? For an internal app. I would suggest it is only necessary to protect user- names passwords to back end services (databases etc.). storing these in a separate file in an encrypted format should be enough to discourage internal users from digging deeper. This will not stop a determined hacker but neither will any other forms of obfuscation. -- new, adj.: Different color from previous model. -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
On Mon, Sep 29, 2014 at 6:41 PM, norman.i...@gmail.com wrote: Crunching the source is an interesting idea that could achieve that end, but it seems fraught with problems like maintaining consistency between renaming objects in a module and renaming where imports happen. Here's a technique that you could use. Pick two prefixes, one for long names and one for short names, and maintain a translation table. So, for instance, you could have two source files like this: # file1.py # Do something with the length and the count def xx_some_func(length, cnt): # TODO: Implement me. pass # file2.py import file1 def xx_foo(lst, len, count): # Do something for every element in the list # where the something is blah blah blah for element in lst: file1.xx_some_func(len, count) And then your crunched files might be: # file1.py: def x_a(a,b): pass # file2.py import file1 def x_b(a,b,c): for d in a: file2.x_a(b,c) The translation is 100% mechanical: any place you find xx_some_func, you replace it with x_a. If you find a string that begins xx_ and isn't in your translation table, you construct a new name (don't forget that you can use x_A as well as x_a) and add it to the table. It ought to be possible to do an AST reconstitution for at least part of this. I can hunt down some of my PEP 463 test code to help out with that. It should be possible to figure out what names are local, and then just use those. If this is of interest, I'll see what I can knock together. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Weird SSL problem
Hi! I’m trying to access https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration Doing it the simplest way I get the following: import urllib f = urllib.urlopen(https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration;) Traceback (most recent call last): File stdin, line 1, in module File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py, line 87, in urlopen return opener.open(url) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py, line 208, in open return getattr(self, name)(url) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py, line 437, in open_https h.endheaders(data) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py, line 969, in endheaders self._send_output(message_body) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py, line 829, in _send_output self.send(msg) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py, line 791, in send self.connect() File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py, line 1176, in connect self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py, line 387, in wrap_socket ciphers=ciphers) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py, line 143, in __init__ self.do_handshake() File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py, line 305, in do_handshake self._sslobj.do_handshake() IOError: [Errno socket error] [Errno 54] Connection reset by peer import ssl ssl.OPENSSL_VERSION ’OpenSSL 0.9.8za 5 Jun 2014' Now, using Safari, or curl for that matter, from the same machine works without a hitch. The URL above is also the only URL I’ve encountered this problem with. Anyone got an idea ? — Roland ”Being able to think like a child is an important attribute of being an adult” - Eddie Izzard -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
On Mon, Sep 29, 2014 at 6:55 PM, Chris Angelico ros...@gmail.com wrote: It ought to be possible to do an AST reconstitution for at least part of this. I can hunt down some of my PEP 463 test code to help out with that. It should be possible to figure out what names are local, and then just use those. If this is of interest, I'll see what I can knock together. Actually, why reconstitute? The AST can be compiled. Here's a Python cruncher/obscurer: import ast, sys, os # Note: If the file can't be parsed, this will raise SyntaxError # (from the ast.parse() line). def crunch(fn, outfn): with open(fn, rb) as f: data = f.read() tree = ast.parse(data) os.makedirs(os.path.split(outfn)[0], exist_ok=True) with open(outfn, w) as f: print(from ast import *, file=f) print(_code = +ast.dump(tree), file=f) print(fix_missing_locations(_code), file=f) print([globals().__delitem__(_) for _ in dir() if _[0]!='_'], file=f) print(exec(compile(_code,__name__,'exec')), file=f) if __name__ == __main__: for fn in sys.argv[1:]: outfn = crunched/ + fn crunch(fn, outfn) print(Crunched, fn, to, outfn) The resulting files should work just the same as the original ones, but will be virtually unreadable. This is still only obscurity, though; the only information actually removed is formatting and comments, not even names. But you could easily add an ast.walk() in there, just after the ast.parse(), and do whatever transformations you want. Note that unlike with JavaScript crunching, this won't shrink the files - in fact, it's usually going to expand them. They'll probably also take longer to load. There is no benefit other than the obscurity. Run this over some of your files, then see if your auditors are happy. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
ANN: eGenix PyCon UK 2014 Talks Videos
ANNOUNCING eGenix PyCon UK 2014 Talks Videos This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/PyCon-UK-2014-Presentations.html We have just published the talk slides and videos of our PyCon UK 2014 presentations. The PyCon UK Conference is the premier conference for Python users and developers in the UK. This year it was held from September 19-22 in Coventry, UK. EGENIX TALKS AT PYCON UK 2014 At this year's PyCon UK, Marc-André Lemburg, CEO of eGenix, gave the following talks at the conference. The presentations are available for viewing and download from our Presentations and Talks section: http://www.egenix.com/library/presentations/ When performance matters ... Simple idioms you can use to make your Python code run faster and use less memory. Python applications sometimes need all the performance they can get. Think of e.g. web, REST or RPC servers. There are several ways to address this: scale up by using more processes, use Cython, use PyPy, rewrite parts in C, etc. However, there are also quite a few things that can be done directly in Python. This talk goes through a number of examples and show cases how sticking to a few idioms can easily enhance the performance of your existing applications without having to revert to more complex optimization strategies. The talk was complemented with a lightning talk titled Pythons and Flies, which addresses a memory performance idiom and answers one of the audience questions raised in the above talk. Talk video and slides: http://www.egenix.com/library/presentations/PyCon-UK-2014-When-performance-matters/ Python Web Installer Installing Python packages is usually done with one of the available package installation systems, e.g. pip, easy_install, zc.buildout, or manually by running python setup.py install in a package distribution directory. These systems work fine as long as you have Python-only packages. For packages that contain binaries, such as Python C extensions or other platform dependent code, the situation is a lot less bright. In this talk, we present a new web installer system that we're currently developing to overcome these limitations. The system combines the dynamic Python installation interface supported by all installers (python setup.py install), with a web installer which automatically selects, downloads, verifies and installs the binary package for your platform. Talk video and slides: http://www.egenix.com/library/presentations/PyCon-UK-2014-Python-Web-Installer/ If you are interested in learning more about these idioms and techniques, eGenix now offers Python project coaching and consulting services to give your project teams advice on how to achieve best performance and efficiency with Python: http://www.egenix.com/services/coaching/ Please contact our eGenix Sales Team for information: sa...@egenix.com. INFORMATION About Python (http://www.python.org/): Python is an object-oriented Open Source programming language which runs on all modern platforms. By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for today's IT challenges. About eGenix (http://www.egenix.com/): eGenix is a software project, consulting and product company focusing on expert project services and professional quality products for companies, Python users and developers. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Sep 29 2014) Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2014-09-30: Python Meeting Duesseldorf ... tomorrow : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
norman.i...@gmail.com wrote: Hello list Python 3.4 applies. I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know this project as an Excel add-in. Now, internal audit takes exception in some cases if users are able to see the source code. You have my sympathy. So I'm wondering if anyone has clever suggestions in this regard... Yes. Distribute the pyc files only. That is the canonical Python answer to the problem of not distributing source code. You may need a tiny driver script (or perhaps not), if you do it will be something as minor as: import module_where_all_the_work_is_really_done as module module.main() depending on how the Excel add-in system works. My current plan is to modify the bdist_wheel setuptools extension so that it can produce distributions with only the .pyc files, laid out so that they will be importable in the normal way. This will be sufficient to satisfy internal audit, and will not negatively impact our users. Sounds good to me. Do you know about the compileall.py script/module in the standard library? However there are obvious downsides, including the overhead of maintaining separate wheels for different architectures and (in the future) Python versions. Not to mention that this plan seems to go against the grain of how Python wants to use byte code files... Well, yes, it does go against the grain, but byte-code only distributions are officially supported. Occasionally people have made requests to simplify the import system by dropping support for .pyc only imports, but Python's creator Guido van Rossum has made it clear that as alien as such a thing is to the open source community, Python is going to allow it. Another possibility is to distribute your modules inside a zip file. See here: https://mail.python.org/pipermail/python-list/2014-July/675506.html Such zip files are not just runnable, but also importable. Depending on your Excel requirements, you might need a tiny driver script as above. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Teaching Python
Hi, my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? -- Urbán Gábor Linux is like a wigwam: no Gates, no Windows and an Apache inside. -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
On Mon, Sep 29, 2014 at 11:18 PM, Gabor Urban urbang...@gmail.com wrote: my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? Right here: https://docs.python.org/3/tutorial/ There are other tutorials on the web, too. I strongly recommend starting with Python 3. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
Gabor Urban wrote: Hi, my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? The Internet is a big place, I always start by searching :-) https://duckduckgo.com/html/?q=python+tutorial+for+kids https://duckduckgo.com/html/?q=python+turtle+graphics https://startpage.com/do/search?q=python+programming+for+children Are you looking for instruction on how you can teach them, or for self-directed learning they can do on their own? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
On Monday, September 29, 2014 6:59:10 PM UTC+5:30, Chris Angelico wrote: On Mon, Sep 29, 2014 at 11:18 PM, Gabor Urban wrote: my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? Right here: https://docs.python.org/3/tutorial/ The official tutorial for an 11 year old?? I dont think so... There are other tutorials on the web, too. I strongly recommend starting with Python 3. There's the official turtle graphics Then there's this https://code.google.com/p/pynguin/ Though I guess just as the official tutorial is too adult for an 11 year old, turtle graphics may be too childish. You know your son better than we do: What excites him? Bores him? If you tell us then appropriate suggestions may follow -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
On Mon, Sep 29, 2014 at 11:38 PM, Rustom Mody rustompm...@gmail.com wrote: https://docs.python.org/3/tutorial/ The official tutorial for an 11 year old?? I dont think so... I don't see why not, to be honest. Not a lot of difference between his 11yo son and my 12yo sister, and I just pointed her at the tutorial and Idle's interactive mode and set her going. But the father is the best one to judge that; if the boys have dabbled in programming already, he and/or they will know if the tutorial's aimed too high for them. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: trouble building data structure
David Alban wrote: greetings, i'm writing a program to scan a data file. from each line of the data file i'd like to add something like below to a dictionary. my perl background makes me want python to autovivify, but when i do: file_data = {} [... as i loop through lines in the file ...] file_data[ md5sum ][ inode ] = { 'path' : path, 'size' : size, } i get: Traceback (most recent call last): File foo.py, line 45, in module file_data[ md5sum ][ inode ] = { 'path' : path, 'size' : size, } KeyError: '91b152ce64af8af91dfe275575a20489' what is the pythonic way to build my file_data data structure above that has the above structure? Others have suggested using a defaultdict, but here's an older solution: use the setdefault method on regular dicts. This fails: py file_data = {} py file_data[1234][23] = {'spam': 1, 'eggs': 2} Traceback (most recent call last): File stdin, line 1, in module KeyError: 1234 But this succeeds: py file_data.setdefault(1234, {})[23] = {'spam': 1, 'eggs': 2} py file_data.setdefault(5678, {})[42] = {'spam': 3, 'cheese': 1} py file_data {1234: {23: {'spam': 1, 'eggs': 2}}, 5678: {42: {'spam': 3, 'cheese': 1}}} Whether you prefer to use setdefault, or a defaultdict, is a matter of taste. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Storage Cost Calculation
Abohfu venant zinkeng vicezik at gmail.com writes: Hard drives have been the secondary storage of choice on computers for many years. They have improved in speed, in capacity, and in cost for over 50 years. It's interesting to look at how the prices have dropped, or, conversely, how much storage your money will buy now as compared to many years ago. This improvement is an example of Moore's Law This site was written by a person (in 2009) who had considered this amazing trend. He collected a lot of data about hard drive capacity and price. The formula he extrapolated by using the data he found iscost per gigabyte = 10-0.2502(year-1980) + 6.304where year is the year for which the extrapolated cost was desired. This formula is based on data from 1980 to 2010.Your program should develop a table of costs, based on the user's inputs of the starting and ending years and the formula. The table should produce columns as seen below, The column Year is the year, starting at the point the user says to start at, and going to the ending year, stopping there. The size of the step in the table is also specified by the user. The user inputs are all integers. Your program can assume that. NOTE: The ending year, stopping there phrase is a bit ambiguous. If you want to use the ending year as the stop value in a range function, that is fine. If you want to add one to the ending year and use that as the stop value, that is also ok. In the tables below, end year plus one was used. Tab characters can be used. Sample Run:Big Blue Hard Drive Storage Cost Enter the starting year: 1992 Enter the ending year: 2015 What step size for the table? 4 Hard Drive Storage Costs Table Start Year = 1992 End Year = 2015 Year Cost Per Gigabyte ($) 1992 2002.627 1996 199.894 2000 19.953 2004 1.992 2008 0.199 2012 0.02 Another Run:Big Blue Hard Drive Storage Cost Enter the starting year: 1998 Enter the ending year: 2010 What step size for the table? 2 Hard Drive Storage Costs Table Start Year = 1998 End Year = 2010 Year Cost Per Gigabyte ($) 1998 63.154 2000 19.953 2002 6.304 2004 1.992 2006 0.629 2008 0.199 2010 0.063 QUESTION Could someone help me with a design and a python program to implement that design to solve the above problem? divdiv dir=ltr ul li pHard drives have been the secondary storage of choice on computers for many years. They have improved in speed, in capacity, and in cost for over 50 years. It's interesting to look at how the prices have dropped, or, conversely, how much storage your money will buy now as compared to many years ago. This improvement is an example ofnbsp;a href=http://en.wikipedia.org/wiki/Moore%27s_law;Moore's Law/a/p pa href=http://www.mkomo.com/cost-per-gigabyte;This site/anbsp;was written by a person (in 2009) who had considered this amazing trend. He collected a lot of data about hard drive capacity and price. The formula he extrapolated by using the data he found is/pcost per gigabyte = 10-0.2502(year-1980) + 6.304brwherenbsp;yearnbsp;is the year for which the extrapolated cost was desired. This formula is based on data from 1980 to 2010.pYour program should develop a table of costs, based on the user's inputs of the starting and ending years and the formula. The table should produce columns as seen below, The column Year is the year, starting at the point the user says to start at, and going to the ending year, stopping there. The size of the step in the table is also specified by the user. The user inputs are all integers. Your program can assume that.nbsp;NOTE:nbsp;The ending year, stopping there phrase is a bit ambiguous. If you want to use the ending year as the stop value in a range function, that is fine. If you want to add one to the ending year and use that as the stop value, that is also ok.nbsp;In the tables below, nbsp;end year plus one was used.nbsp;Tab characters can be used./p pSample Run:/pBig Blue Hard Drive Storage Cost Enter the starting year: 1992 Enter the ending year: 2015 What step size for the table? 4 Hard Drive Storage Costs Table Start Year = 1992 End Year = 2015 Year Cost Per Gigabyte ($) 1992 2002.627 1996 199.894 2000 19.953 2004 1.992 2008 0.199 2012 0.02 pAnother Run:/pBig Blue Hard Drive Storage Cost Enter the starting year: 1998 Enter the ending year: 2010 What step size for the table? 2 Hard Drive Storage Costs Table Start Year = 1998 End Year = 2010 Year Cost Per Gigabyte ($) 1998
Re: Storage Cost Calculation
On Sun, 28 Sep 2014 20:07:31 +, Duncan Booth wrote: Later on the B+ had 64k of RAM and the B+128 had 128k of RAM and in each case the additional RAM was paged in as necessary but I don't think the RAM in the B was ever expandable. You could get various expansions to page multiple roms, I had a machine at one point with 15 multiple internally and a zif socket on top. I think there was a board that sat across the 4 paged ROM sockets which then had a cable to another board with 16 sockets on it, and one of the 16 sockets came through the case in a ZIF. Aries or Dabs or Watford Electronics I expect. I also remember soldering switches to TEAC drives from RS to make them 40 / 80 track switchable. Duncan, your name looks mighty familiar . Do you know a Judith? -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Another possibility is to distribute your modules inside a zip file. See here: https://mail.python.org/pipermail/python-list/2014-July/675506.html Such zip files are not just runnable, but also importable. Depending on your Excel requirements, you might need a tiny driver script as above. It should also be possible to temper with the zipimport module to allow a 'scrambled' zip file. That makes it harder for users to access the code by unpacking the zip file. py2exe will collect pyc files into a single zip file and import that. It does not need a driver script because it embeds the Python interpreter in an executable. Yet another option is to compile the Python code with Cython and distribute everything as compiled pyd files. Sturla -- https://mail.python.org/mailman/listinfo/python-list
Re: Obscuring Python source from end users
Chris Angelico ros...@gmail.com wrote: I have a project that involves distributing Python code to users in an organisation. Users do not interact directly with the Python code; they only know this project as an Excel add-in. Now, internal audit takes exception in some cases if users are able to see the source code. The solution is to fix your internal audit. +1 -- https://mail.python.org/mailman/listinfo/python-list
Re: trouble building data structure
On Mon, Sep 29, 2014 at 7:52 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Whether you prefer to use setdefault, or a defaultdict, is a matter of taste. There is potentially a significant difference in performance -- with setdefault, the subordinate data structure is created on every call to be passed into setdefault, only to be discarded if the key already exists. With defaultdict, the subordinate data structure is only created when needed. Dicts are pretty cheap to construct though, and this is probably not worth fretting over until profiling shows it to be a problem. On the other hand, it's easier to nest setdefaults arbitrarily deep than it is for defaultdicts. This is because defaultdict suffers from a design flaw -- defaultdict should be a function that returns a class (like namedtuple), not a class itself. Fortunately that's easily fixable: _DEFAULT_DICT_CACHE = {} def defaultdict(callable): try: return _DEFAULT_DICT_CACHE[callable] except KeyError: class _defaultdict(dict): def __missing__(self, key): self[key] = value = self._callable() return value _DEFAULT_DICT_CACHE[callable] = _defaultdict return _defaultdict A downside is that it would take some extra work to make this picklable. -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
On Mon, 29 Sep 2014 15:18:31 +0200, Gabor Urban urbang...@gmail.com wrote: Hi, my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? I ordered this book from the library a few weeks ago. It just came in yesterday. Python for kids. Jason R Briggs This was also a good page for starters. http://www.practicepython.org/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
On 29 September 2014 14:18:31 BST, Gabor Urban urbang...@gmail.com wrote: my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? How to Think Like a Computer Scientist - Learning with Python 3: http://openbookproject.net/thinkcs/python/english3e/ If you're after a printed book, the original (I believe) author's current version is here: http://www.greenteapress.com/thinkpython/thinkpython.html Simon -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
I am actually teaching Python as a side job. My students have ranged from eighth graders, up to a Silicon Valley hardware engineer who had no coding experience, but who needed to do some test engineering. My wife is an elementary school teacher. We occasionally talk about age-appropriate learning, and pedagogical strategies. I once watched a research biologist try to explain restriction enzymes to my sixth-grade son. It was painful to watch. Sure, my son is a smart kid, but there was no way he was going to understand what she was talking about without some background. For my younger Python students, I interact with them directly, sitting by their side while they type. Initially, I do not ask them to read any computer documentation. It's too difficult for them, even the official Python tutorial. The tutorial is aimed at an adult reader who has at least a little computer experience -- and sometimes, quite a lot. Just read Chapter 1. Imagine that you're 14 years old, reading that. Even if you have already programmed in one of the languages aimed at children, like Scratch, you will be in way over your head. Now, even though I think that the Python tutorial is too hard for young students to read, I do cover much of the MATERIAL in that tutorial, and in approximately the same order. I sit the student down in front of the interpreter, explain what an interpreter is, and then have them type simple mathematical expressions. I introduce variable names, and then strings, and lists. This is, more or less, the material in Chapter 3 of the tutorial -- although lists are not discussed until Chapter 5. Next, I introduce the idea of a program file, and have them start working with an editor. That's not in the tutorial at all. I introduce the print() function (briefly mentioned in Chapter 3), and the for statement (Section 4.2). Once you introduce the for statement, you need to explain code blocks, the use of a colon at the end of a line, and the use of indentation. This is enough information to get the student to write short programs. I start with single loops. Then, I have the student write a multiplication table program. Getting the student to grasp the idea of a loop inside a loop can sometimes be challenging. The next three things that I teach are the if statement (Section 4.1), the input() function (which appears in Chapter 4 of the tutorial, without any introduction or explanation), and string concatenation using the + operator. This is enough to get the student to write a program which accepts an input string, and prints out an alphabetized version of that string. I do not show the student the sorted() function until after they write the program with what they know! Typically, I move on to the range() function and slicing operations next. But unless you are working with very bright kids, that should be enough to keep them busy for a while. :^) -- https://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
On 9/29/2014 9:18 AM, Gabor Urban wrote: Hi, my 11 years old son and his classmate told me, that they would like to learn Python. They did some programming in Logo and turtle graphics, bat not too much. Doesn anybody has an idea how to start? Python has a turtle module, so they can continue where they left off. The turtledemo package has about 20 example programs and shows code in one pane beside a turtle canvas in another. The new 3.4.2 (release candidate now, final in a week or two) has several turtle and turtledemo fixes. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Weird SSL problem
In article cd8f39d9-acd9-4d6e-9aac-dbcdf607f...@adm.umu.se, Roland Hedberg roland.hedb...@adm.umu.se wrote: Hi! I¹m trying to access https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration Doing it the simplest way I get the following: import urllib f = urllib.urlopen(https://stsadweb.one.microsoft.com/adfs/.well-known/openid -configuration) Traceback (most recent call last): File stdin, line 1, in module File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py, line 87, in urlopen return opener.open(url) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py, line 208, in open return getattr(self, name)(url) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py, line 437, in open_https h.endheaders(data) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py , line 969, in endheaders self._send_output(message_body) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py , line 829, in _send_output self.send(msg) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py , line 791, in send self.connect() File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py , line 1176, in connect self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py, line 387, in wrap_socket ciphers=ciphers) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py, line 143, in __init__ self.do_handshake() File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py, line 305, in do_handshake self._sslobj.do_handshake() IOError: [Errno socket error] [Errno 54] Connection reset by peer import ssl ssl.OPENSSL_VERSION ¹OpenSSL 0.9.8za 5 Jun 2014' Now, using Safari, or curl for that matter, from the same machine works without a hitch. The URL above is also the only URL I¹ve encountered this problem with. Anyone got an idea ? I believe the problem is that the connection is protected by a multi-hostname server certificate and Python 2's urllib (and underlying httplib and ssl modules) do not support SNI extensions to TLS. The request above works fine with Python 3 (which has supported client-side SNI since Python 3.2). See http://bugs.python.org/issue5639 for more discussion of the matter. If Python 3 is not an option for you, the requests package available via PyPI should help. -- Ned Deily, n...@acm.org -- https://mail.python.org/mailman/listinfo/python-list
JSON-encoding very long iterators
I would like to add the ability to JSONEncode large iterators. Right now there is no way to do this without modifying the code. The JSONEncoder.default() doc string suggests to do this: For example, to support arbitrary iterators, you could implement default like this:: def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o) but this method requires the whole serialized object to fit in memory and it's a good chance that your iterator is an iterator to save on memory in the first place. By changing the code to accept iterators it is then possible to stream json as I did here: http://stackoverflow.com/a/26094558/289240 This would ideal if it were included in the standard library. Is there any reason why it shouldn't be? -- https://mail.python.org/mailman/listinfo/python-list
Re: JSON-encoding very long iterators
On Mon, Sep 29, 2014 at 7:19 PM, alf...@54.org wrote: I would like to add the ability to JSONEncode large iterators. Right now there is no way to do this without modifying the code. The JSONEncoder.default() doc string suggests to do this: For example, to support arbitrary iterators, you could implement default like this:: def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o) but this method requires the whole serialized object to fit in memory and it's a good chance that your iterator is an iterator to save on memory in the first place. By changing the code to accept iterators it is then possible to stream json as I did here: http://stackoverflow.com/a/26094558/289240 This would ideal if it were included in the standard library. Is there any reason why it shouldn't be? This would cause things that aren't lists to be encoded as lists. Sometimes that may be desirable, but in general if e.g. a file object sneaks its way into your JSON encode call, it is more likely correct to raise an error than to silently encode the file as if it were a list of strings. So it should not be the default behavior. That said, it sounds like it could be made easier to enable streaming from iterators as an option for those cases where it's desired. -- https://mail.python.org/mailman/listinfo/python-list
[issue6978] compiler.transformer dict key bug d[1,] = 1
Mark Lawrence added the comment: Can somebody set this to patch review and do the honours please. FWIW I don't like tulplesub in the patch. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6978 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9912] Fail when vsvarsall.bat produces stderr
Mark Lawrence added the comment: Ping. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9912 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue809846] bdist_wininst doesn't clean up read-only files in build dir
Mark Lawrence added the comment: I understand from the experts list that tarek is no longer maintaining distutils but I can't change the assigned to field. As a matter of interest there are another 67 issues with tarek assigned. -- nosy: +BreamoreBoy, dstufft versions: +Python 3.4, Python 3.5 -Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue809846 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22389] Generalize contextlib.redirect_stdout
John Isidore added the comment: There is stdout_redirected() function [1] that allows to redirect a file object given as `stdout` patameter including `sys.stderr`. It works at a file descriptor level i.e. it supports redirecting subprocess' output too but it doesn't work for StringIO (no fd). [1] http://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python/22434262#22434262 -- nosy: +John Isidore ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22389 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22472] OSErrors should use str and not repr on paths
Akira Li added the comment: OSError has *filename* attribute. Could it be passed to the UI instead? -- nosy: +akira ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22472 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21159] configparser.InterpolationMissingOptionError is not very intuitive
R. David Murray added the comment: We never promise that the messages won't change (they are not part of the API), so that part isn't a problem. We do try to be backward compatible there when it comes to args beyond the message text. I don't think unpickleability is an issue; at least there isn't any discussion of it in PEP 3161, and I don't remember any around the implementation. I think this is fine. I don't think we should worry about someone who is actually using rawval/rest pulled out of the exception args. You could put a porting note in What's New, but my guess is that the chances of anyone being inconvenienced by this are pretty near to zero. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21159 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22472] OSErrors should use str and not repr on paths
R. David Murray added the comment: No, because I'm just logging the error message. That's the UI. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22472 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17835] test_io broken on PPC64 Linux
James Spurin added the comment: With both the kernel parameters defined and undefined, I get the following output - # /local/0/opt/python-3.4.1/bin/python Python 3.4.1 (default, Sep 29 2014, 13:31:39) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux Type help, copyright, credits or license for more information. from socket import socket, SO_SNDBUF, SOL_SOCKET s = socket() s.getsockopt(SOL_SOCKET, SO_SNDBUF) 16384 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17835 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22460] idle editor: replace all in selection
bagrat lazaryan added the comment: replacing across multiple files is something i personally considered too fancy for idle, but that's a great feature. the same goes for smart selections like selecting multiline statements. if they don't contradict idle's simplicity ideology they are great canditates to be implemented. as to the editors currently implementing replace-in-selection, notepad++ is one. it actually does exactly what terry suggested, activating an in selection checkbox only if something is selected. (visual studio, and python tools for visual studio in particular, have some replacement and refactoring abilities too.) -- now, guys, i'm very sorry that i have to return to my already mentioned off-topic issue: i'm not getting emails from bugtracker. not even in spam. i was about to file a bug on the metatracker but it seems i can't even register on it because i am not receiving that confirmation email to activate my account! i don't know if http://psf.upfronthosting.co.za/roundup/meta/issue541 is related to my problem. it seems it might be. what am i to do? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22460 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9104] test.support method for dual-testing accelerated code (fixes test_exceptions and other's pickle testing)
Changes by Alexander Belopolsky alexander.belopol...@gmail.com: -- assignee: belopolsky - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9104 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20135] FAQ need list mutation answers
Roundup Robot added the comment: New changeset 138f54622841 by R David Murray in branch '3.4': #20135: FAQ entry for list mutation. (See also 6375bf34fff6.) https://hg.python.org/cpython/rev/138f54622841 New changeset 3d924bbfdcbc by R David Murray in branch 'default': Merge: #20135: FAQ entry for list mutation. (See also 90b07d422bd9.) https://hg.python.org/cpython/rev/3d924bbfdcbc New changeset 2b9db1fce82e by R David Murray in branch '2.7': #20135: FAQ entry for list mutation. https://hg.python.org/cpython/rev/2b9db1fce82e -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20135 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20135] FAQ need list mutation answers
R. David Murray added the comment: I accidentally committed the patch early to 3.4/3.5. I've now addressed Ezio's review comment per my suggestion on the review, and committed it to 2.7 as well. Thanks everyone for your contributions. -- resolution: - fixed stage: commit review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20135 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21338] Silent mode for compileall
R. David Murray added the comment: Berker: I had some review comments pending on the docs, but reitveld isn't letting me publish them for some reason (it says the patch set doesn't exist). The comments are: the method docs should probably say ``False`` or ``0`` (the default) (and all the numbers should be marked up as code), and the versionchanged I think should say that the option was changed to a multilevel value. Otherwise the patch looks good to me, too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21338 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20858] Enhancements/fixes to pure-python datetime module
Changes by Berker Peksag berker.pek...@gmail.com: -- stage: commit review - resolved ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20858 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22510] Faster bypass re cache when DEBUG is passed
Roundup Robot added the comment: New changeset 565096a32ce4 by Serhiy Storchaka in branch 'default': Issue #22510: Get rid of little overhead of testing re.DEBUG flag. https://hg.python.org/cpython/rev/565096a32ce4 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22510 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17442] code.InteractiveInterpreter doesn't display the exception cause
R. David Murray added the comment: After reconsidering Terry's idle example, it seems to me that the change could adversely impact existing code that already works around the lack of chained tracebacks, even as idle does. So I committed this to 3.5 only as an enhancement. Thanks Claudiu. As an aside, isn't it a (pre-existing) bug that if an excepthook exists, it gets passed None for the traceback? -- resolution: - fixed stage: commit review - resolved status: open - closed type: behavior - enhancement versions: -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17442 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17442] code.InteractiveInterpreter doesn't display the exception cause
Roundup Robot added the comment: New changeset 2b212a8186e0 by R David Murray in branch 'default': #17442: Add chained traceback support to InteractiveInterpreter. https://hg.python.org/cpython/rev/2b212a8186e0 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17442 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12006] strptime should implement %V or %u directive from libc
Alexander Belopolsky added the comment: For future reference, here is the example showing %Y %V ambiguity: date(2013,12,31).strftime('%Y %V %u') '2013 01 2' date(2013,1,1).strftime('%Y %V %u') '2013 01 2' which is resolved by using %G date(2013,12,31).strftime('%G %V %u') '2014 01 2' date(2013,1,1).strftime('%G %V %u') '2013 01 2' In other words, '2013 01 2' cannot be unambiguously parsed using '%Y %V %u' format. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12006 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12006] strptime should implement %G, %V and %u directives
Alexander Belopolsky added the comment: I think we need more tests showing that new directives don't violate strftime - strptime round-trip invariants. -- title: strptime should implement %V or %u directive from libc - strptime should implement %G, %V and %u directives ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12006 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5979] strptime() gives inconsistent exceptions
Changes by Alexander Belopolsky alexander.belopol...@gmail.com: -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5979 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12006] strptime should implement %G, %V and %u directives
Alexander Belopolsky added the comment: Documentation should say new in 3.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12006 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1565509] Repair or Change installation error
Steve Dower added the comment: Newer versions of Windows Installer (this looks like an XP issue...) will preserve a copy of the original MSI in a safe place, so this problem should not occur any more. I vote to close. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1565509 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5979] strptime() gives inconsistent exceptions
Changes by Berker Peksag berker.pek...@gmail.com: -- stage: needs patch - resolved ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5979 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10007] Visual C++ cannot build _ssl and _hashlib if newer OpenSSL is placed in $(dist) directory (PCBuild)
Steve Dower added the comment: Should be fine. Both 2.7 and default have the full OpenSSL version in pyproject.vsprops, so they'll only use the version they expect. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10007 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22510] Faster bypass re cache when DEBUG is passed
Serhiy Storchaka added the comment: Thank you Antoine for your review. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22510 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22513] grp.struct_group is not hashable
New submission from Ethan Furman: First, the behavior for pwd.struct_passwd: - -- pwd.getpwuid(1000) pwd.struct_passwd(pw_name='ethan', pw_passwd='x', pw_uid=1000, pw_gid=1000, pw_gecos='Ethan Furman,,,', pw_dir='/home/ethan', pw_shell='/bin/bash') -- set(pwd.getpwuid(1000)) set(['/bin/bash', 1000, 'Ethan Furman,,,', '/home/ethan', 'ethan', 'x']) -- set([pwd.getpwuid(1000)]) set([pwd.struct_passwd(pw_name='ethan', pw_passwd='x', pw_uid=1000, pw_gid=1000, pw_gecos='Ethan Furman,,,', pw_dir='/home/ethan', pw_shell='/bin/bash')]) Now, the behavior for grp.struct_group: -- -- grp.getgrgid(1000) grp.struct_group(gr_name='ethan', gr_passwd='x', gr_gid=1000, gr_mem=[]) -- set(grp.getgrgid(1000)) Traceback (most recent call last): File stdin, line 1, in module TypeError: unhashable type: 'list' -- set([grp.getgrgid(1000)]) Traceback (most recent call last): File stdin, line 1, in module TypeError: unhashable type: 'list' At the very least the error message is wrong (it's not a list), and at the most grp.struct_group should be hashable -- i.e. we should be able to have a set of groups. -- messages: 227811 nosy: ethan.furman priority: normal severity: normal status: open title: grp.struct_group is not hashable type: behavior versions: Python 2.7, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22513 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17442] code.InteractiveInterpreter doesn't display the exception cause
Claudiu Popa added the comment: Indeed, it's a preexisting bug. I'll try to come up with a patch shortly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17442 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22513] grp.struct_group is not hashable
Ethan Furman added the comment: Test added. -- keywords: +patch stage: - needs patch Added file: http://bugs.python.org/file36752/issue22513.stoneleaf.01.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22513 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6978] compiler.transformer dict key bug d[1,] = 1
Terry J. Reedy added the comment: I am closing this because a) Meador is correct that we do not normally patch deprecated features and b) the current emphasis on 2.7-only patches is security and keeping 2.7 working on current systems. The fix would only benefit 2.7.9+ code or 2.7.9+ and 3.x code, neither of which should be using compiler module. Benjamin, if you disagree, review and apply, as no one else will. -- resolution: - wont fix stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6978 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22460] idle editor: replace all in selection
Terry J. Reedy added the comment: About your email problem: post to core-mentorship list and if you cannot do that, write to Ezio Melotti and/or R. David Murray directly, as they are tracker maintainers. -- stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22460 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22513] grp.struct_group is not hashable
Serhiy Storchaka added the comment: This is because grp.struct_group contains unhashable component (a list). Same behavior with tuple: tuple(grp.getgrgid(1000)) ('serhiy', 'x', 1000, []) set(tuple(grp.getgrgid(1000))) Traceback (most recent call last): File stdin, line 1, in module TypeError: unhashable type: 'list' set([tuple(grp.getgrgid(1000))]) Traceback (most recent call last): File stdin, line 1, in module TypeError: unhashable type: 'list' Instead a set of grp.struct_group, create a dict, which maps group name to grp.struct_group. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22513 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22513] grp.struct_group is not hashable
Ethan Furman added the comment: Thanks, Serhiy. -- resolution: - not a bug stage: needs patch - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22513 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22486] Add math.gcd()
Changes by Alexander Belopolsky alexander.belopol...@gmail.com: -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22486 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22514] incomplete programming example on python.org
New submission from Friedrich Spee von Langenfeld: When I open www.python.org, there are some examples to demonstrate the look and feel of Python. I´ve tested an example (example number 1). Online, the following is shown: # Python 3: Fibonacci series up to n def fib(n): a, b = 0, 1 while a n: print(a, end=' ') a, b = b, a+b print() fib(1000) 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 But then I have tested the (following) code with Python 3.1: def fib(n): a, b = 0, 1 while a n: print(a, end= ) a, b = b, a+b print() fib(1000) 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 As you can see, the last number(987)wasn´t shown online. Perhaps, this behavior is browser-dependent. I´ve used Mozilla Firefox 32.0.3 . I can´t estimate the priority of this issue, because I can´t imagine how many people are using or analysing the examples. Can you reproduce my findings? -- messages: 227818 nosy: Friedrich.Spee.von.Langenfeld priority: normal severity: normal status: open title: incomplete programming example on python.org ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22514 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
New submission from Ram Rachum: I suggest implementing `Counter.__lt__` which will be a partial order, similarly to `set.__lt__`. That is, one counter will be considered smaller-or-equal to another if for any item in the first counter, the second counter has an equal or bigger amount of that item. -- components: Library (Lib) messages: 227819 nosy: cool-RR priority: normal severity: normal status: open title: Implement partial order on Counter versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22194] access to cdecimal / libmpdec API
Changes by Alexander Belopolsky alexander.belopol...@gmail.com: -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22194 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22437] re module: number of named groups is limited to 100 max
Roundup Robot added the comment: New changeset 0b85ea4bd1af by Serhiy Storchaka in branch 'default': Issue #22437: Number of capturing groups in regular expression is no longer https://hg.python.org/cpython/rev/0b85ea4bd1af -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22437 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22514] incomplete programming example on python.org
Benjamin Peterson added the comment: 987 is indeed missing. -- nosy: +benjamin.peterson resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22514 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19569] Use __attribute__((deprecated)) to warn usage of deprecated functions and macros
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19569 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19569] Use __attribute__((deprecated)) to warn usage of deprecated functions and macros
Arfrever Frehtes Taifersar Arahesis added the comment: There is already Py_DEPRECATED in Include/pyport.h: #if defined(__GNUC__) ((__GNUC__ = 4) || \ (__GNUC__ == 3) (__GNUC_MINOR__ = 1)) #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) #else #define Py_DEPRECATED(VERSION_UNUSED) #endif You can add this before '#else': #elif defined(_MSC_VER) _MSC_VER = 1300 #define Py_DEPRECATED(VERSION_UNUSED) __declspec(deprecated) Py_DEPRECATED is not used since Python 3.0 (it is still used in 2.7). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19569 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1565509] Repair or Change installation error
Zachary Ware added the comment: Steve Dower wrote: I vote to close. +1, and done. -- assignee: loewis - resolution: - third party stage: test needed - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1565509 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22437] re module: number of named groups is limited to 100 max
Serhiy Storchaka added the comment: Thank you Antoine for your review. To avoid discrepancy between re and regex (and other engines), I have committed only a part of dynamic patch, without adding support of backreferences with index over 99. It is unlikely to achieve this limit in hand written regular expression, and in generated regular expression you can use named groups. I found that backreference syntax is one of most discrepant thing in regular expressions. There are at least 8 different variants (\N, \gN, \gN, \g{N}, \kN, \k'N', \k{N}, (?P=N)), and \gN in Perl have different meaning. -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22437 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Steven D'Aprano added the comment: On Mon, Sep 29, 2014 at 07:33:21PM +, Ram Rachum wrote: I suggest implementing `Counter.__lt__` which will be a partial order, similarly to `set.__lt__`. Since Counter is described as a multiset, this sounds reasonable to me. -- nosy: +steven.daprano ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10007] Visual C++ cannot build _ssl and _hashlib if newer OpenSSL is placed in $(dist) directory (PCBuild)
Zachary Ware added the comment: PCbuild/build_ssl.py in 2.7 and 3.4 look through pyproject.(vs)props for the openssl dir, and 3.5 no longer uses build_ssl.py in the regular build process, so this is in fact out of date. -- assignee: - zach.ware resolution: - out of date stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10007 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Serhiy Storchaka added the comment: What should be result of following operations? Counter({'a': 0}) Counter({}) Counter({}) Counter({'a': 0}) Counter({'a': -1}) Counter({}) Counter({}) Counter({'a': -1}) -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ram Rachum added the comment: I suggest they be ignored like in `elements`. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ram Rachum added the comment: (I mean, the non-positive values should be ignored.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22512] 'test_distutils.test_bdist_rpm' causes creation of directory '.rpmdb' on home dir
Francis MB added the comment: Why is test.support.EnvironmentVarGuard preferable over distutils.test.support.EnvironGuard (with this one I'm not getting the warnings below)? If I change the patch to (not so different (?) as in other tests using EnvironmentVarGuard): $hg diff diff -r 2b212a8186e0 Lib/distutils/tests/test_bdist_rpm.py --- a/Lib/distutils/tests/test_bdist_rpm.py Mon Sep 29 11:25:00 2014 -0400 +++ b/Lib/distutils/tests/test_bdist_rpm.py Mon Sep 29 21:11:25 2014 +0200 @@ -5,7 +5,7 @@ import os import tempfile import shutil -from test.support import run_unittest +from test.support import run_unittest, EnvironmentVarGuard from distutils.core import Distribution from distutils.command.bdist_rpm import bdist_rpm @@ -36,8 +36,11 @@ super(BuildRpmTestCase, self).setUp() self.old_location = os.getcwd() self.old_sys_argv = sys.argv, sys.argv[:] +self.env = EnvironmentVarGuard() def tearDown(self): +self.env.__exit__() +del self.env os.chdir(self.old_location) sys.argv = self.old_sys_argv[0] sys.argv[:] = self.old_sys_argv[1] @@ -54,6 +57,7 @@ def test_quiet(self): # let's create a package tmp_dir = self.mkdtemp() +self.env['HOME'] = tmp_dir # to confine dir '.rpmdb' creation pkg_dir = os.path.join(tmp_dir, 'foo') os.mkdir(pkg_dir) self.write_file((pkg_dir, 'setup.py'), SETUP_PY) @@ -96,6 +100,7 @@ def test_no_optimize_flag(self): # let's create a package that brakes bdist_rpm tmp_dir = self.mkdtemp() +self.env['HOME'] = tmp_dir # to confine dir '.rpmdb' creation pkg_dir = os.path.join(tmp_dir, 'foo') os.mkdir(pkg_dir) self.write_file((pkg_dir, 'setup.py'), SETUP_PY) I get the message: [102/390] test_distutils Warning -- threading._dangling was modified by test_distutils Using EnvironmentVarGuard as context manager gives the same warning. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22512 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Serhiy Storchaka added the comment: There is other definition of the = operator for sets: A = B is equivalent to len(A - B) == 0. Extending to Counter this can mean len(A.subtract(B).elements()) == 0. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22516] Windows Installer won't - even when using just for meoption
New submission from J. Morton: Could not install 3.4.1 on Windows 7 Enterprise SP1 using the .MSI installer, even when using the ”just for me” option (our IM department has not given us the necessary rights to run the .MSI installer even in this mode). Please consider providing 3.4.1 (and all future releases) in a non “.MSI” file so that “admin” rights are not needed to do the install (a simple ZIP file? something similar to www.portableapps.com ?). Or as a source “tarball” for Windows machines – ideally one that is independent of compiler vendor (compileable using gcc, etc. instead of MSVC). -- components: Installation messages: 227832 nosy: NaCl, tim.golden priority: normal severity: normal status: open title: Windows Installer won't - even when using just for meoption versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22516 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22512] 'test_distutils.test_bdist_rpm' causes creation of directory '.rpmdb' on home dir
R. David Murray added the comment: Sorry, I'm not that familiar with distutils and did not realize it had stuff for environment protection in the setUp/tearDown. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22512 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22516] Windows Installer won't - even when using just for meoption
Changes by Ezio Melotti ezio.melo...@gmail.com: -- components: +Windows nosy: +steve.dower, terry.reedy, zach.ware ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22516 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22516] Windows Installer won't - even when using just for meoption
R. David Murray added the comment: The source tarball is the source tarball. You can built python yourself, but it does require MSVC. There are issues in this tracker about supporting other compilers, but for various reasons (mostly having to do with this being a volunteer community driven project) they have not gotten anywhere close to good enough for us to officially support it. For the 'no privileges' install question, I defer to Steve; otherwise I'd just close the issue. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22516 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22517] BufferedRWpair doesn't clear weakrefs
New submission from paul: # static void # bufferedrwpair_dealloc(rwpair *self) # { # _PyObject_GC_UNTRACK(self); # Py_CLEAR(self-reader); # Py_CLEAR(self-writer); # Py_CLEAR(self-dict); # Py_TYPE(self)-tp_free((PyObject *) self); # } # # Weakrefs to this object contain stale pointer after BufferedRWPair is freed. -- files: poc_brwpair_weakref.py messages: 227835 nosy: pkt priority: normal severity: normal status: open title: BufferedRWpair doesn't clear weakrefs type: crash versions: Python 3.4 Added file: http://bugs.python.org/file36753/poc_brwpair_weakref.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22517 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22516] Windows Installer won't - even when using just for meoption
Steve Dower added the comment: The just for me option isn't really just for me. I'll probably have a real option in 3.5, though it may still require admin rights. There's no reason sites like www.portableapps.com couldn't provide true per-user installers, and Continuum Analytics and Enthought both already do (as do others - I think Portable Python is fine, though not quite up to date). Python 3.4 probably won't be fixed. Python 3.5 might be. I don't need this issue to track it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22516 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22518] integer overflow in encoding unicode
New submission from paul: # static PyObject * # unicode_encode_ucs1(PyObject *unicode, # const char *errors, # unsigned int limit) # { # ... # while (pos size) { # ... # case 4: /* xmlcharrefreplace */ # /* determine replacement size */ # for (i = collstart, repsize = 0; i collend; ++i) { # Py_UCS4 ch = PyUnicode_READ(kind, data, i); # ... # else if (ch 10) # 1 repsize += 2+5+1; # ... # } # 2 requiredsize = respos+repsize+(size-collend); # if (requiredsize ressize) { # ... # if (_PyBytes_Resize(res, requiredsize)) # ... # } # /* generate replacement */ # for (i = collstart; i collend; ++i) { # 3 str += sprintf(str, #%d;, PyUnicode_READ(kind, data, i)); # } # # 1. ch=0x10, so repsize = (number of unicode chars in string)*8 #=2^29*2^3=2^32 == 0 (mod 2^32) # 2. respos==0, collend==0, so requiredsize=repsize==0, so the destination buffer #isn't resized # 3. overwrite -- files: poc_encode_latin1.py messages: 227837 nosy: pkt priority: normal severity: normal status: open title: integer overflow in encoding unicode type: crash versions: Python 3.4 Added file: http://bugs.python.org/file36754/poc_encode_latin1.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22518 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22519] integer overflow in computing byte's object representation
New submission from paul: # PyBytes_Repr(PyObject *obj, int smartquotes) # { # PyBytesObject* op = (PyBytesObject*) obj; # 1 Py_ssize_t i, length = Py_SIZE(op); # size_t newsize, squotes, dquotes; # ... # # /* Compute size of output string */ # newsize = 3; /* b'' */ # s = (unsigned char*)op-ob_sval; # for (i = 0; i length; i++) { # ... # default: # if (s[i] ' ' || s[i] = 0x7f) # 2 newsize += 4; /* \xHH */ # else # newsize++; # } # } # ... # 3 if (newsize (PY_SSIZE_T_MAX - sizeof(PyUnicodeObject) - 1)) { # PyErr_SetString(PyExc_OverflowError, # bytes object is too large to make repr); # return NULL; # } # 4 v = PyUnicode_New(newsize, 127); # ... # *p++ = 'b', *p++ = quote; # for (i = 0; i length; i++) { # ... # 5 *p++ = c; # } # *p++ = quote; # 6 assert(_PyUnicode_CheckConsistency(v, 1)); # return v; # } # # 1. length=2^30+1=1073741825 # 2. newsize=length*4+3=7 (overflow) # 3. check is inefficient, because newsize=7 # 4. allocated buffer is too small # 5. buffer overwrite # 6. this assert will likely fail, since there is a good chance the allocated #buffer is just before the huge one, so the huge one will overwrite itself. -- files: poc_repr_bytes.py messages: 227838 nosy: pkt priority: normal severity: normal status: open title: integer overflow in computing byte's object representation type: crash versions: Python 3.4 Added file: http://bugs.python.org/file36755/poc_repr_bytes.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22519 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22520] integer overflow in computing unicode's object representation
New submission from paul: # unicode_repr(PyObject *unicode) # { # ... # 1 isize = PyUnicode_GET_LENGTH(unicode); # idata = PyUnicode_DATA(unicode); # # /* Compute length of output, quote characters, and #maximum character */ # osize = 0; # ... # for (i = 0; i isize; i++) { # Py_UCS4 ch = PyUnicode_READ(ikind, idata, i); # switch (ch) { # ... # default: # /* Fast-path ASCII */ # if (ch ' ' || ch == 0x7f) # 2 osize += 4; /* \xHH */ # ... # } # } # # ... # 3 repr = PyUnicode_New(osize, max); # ... # for (i = 0, o = 1; i isize; i++) { # Py_UCS4 ch = PyUnicode_READ(ikind, idata, i); # ... # else { # 4 PyUnicode_WRITE(okind, odata, o++, ch); # } # } # } # } # /* Closing quote already added at the beginning */ # 5 assert(_PyUnicode_CheckConsistency(repr, 1)); # return repr; # } # # 1. isize=2^30+1 # 2. osize=isize*4=4 # 3. allocated buffer is too small # 4. heap overflow # 5. this assert will likely fail, since there is a good chance the allocated #buffer is just before the huge one, so the huge one will overwrite itself. -- files: poc_repr_unicode.py messages: 227839 nosy: pkt priority: normal severity: normal status: open title: integer overflow in computing unicode's object representation type: crash versions: Python 3.4 Added file: http://bugs.python.org/file36756/poc_repr_unicode.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22516] Windows Installer won't - even when using just for meoption
Changes by R. David Murray rdmur...@bitdance.com: -- resolution: - later stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22516 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22512] 'test_distutils.test_bdist_rpm' causes creation of directory '.rpmdb' on home dir
Francis MB added the comment: No problem, but is the, 3 lines, patch ok? what are the next steps, if yes? Shouldn't be the issue status now 'patch review' or similar? Thanks in advance! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22512 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22512] 'test_distutils.test_bdist_rpm' causes creation of directory '.rpmdb' on home dir
R. David Murray added the comment: Yes, sorry I forgot to change the stage. -- stage: - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22512 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22517] BufferedRWpair doesn't clear weakrefs
Changes by Serhiy Storchaka storch...@gmail.com: -- nosy: +benjamin.peterson, pitrou, stutzbach versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22517 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ethan Furman added the comment: What would be the result of Counter({'a':1, 'b':2}) Counter({'a':2, 'b':1}) ? -- nosy: +ethan.furman ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22518] integer overflow in encoding unicode
Serhiy Storchaka added the comment: Looks very similar to issue22470. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22518 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ram Rachum added the comment: False, like with sets. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
R. David Murray added the comment: Thanks, Ethan. I had a feeling that this wasn't well defined but I couldn't come up with an example :) -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ram Rachum added the comment: David, there's nothing here that isn't well defined. It's simply a partial order, not a total order. We have the same for sets. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ethan Furman added the comment: set's don't have values, and you are wanting to implement the partial ordering based on the values. (side-note: how does partial-ordering work for sets?) That is, one counter will be considered smaller-or-equal to another if for any item in the first counter, the second counter has an equal or bigger amount of that item. According to your definition, my example should have returned True, which is clearly nonsensical. Even if you changed the definition to: For every item in the first counter, that item's value is less than the corresponding item in the second counter. You have situations like: Counter({'a':1, 'b':1}) Counter({'a':2}) I just don't think there is one interpretation that is going to be correct most of the time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Changes by Josh Rosenberg shadowranger+pyt...@gmail.com: -- nosy: +josh.rosenberg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22515] Implement partial order on Counter
Ram Rachum added the comment: Ethan, I don't understand what the problem is. I also don't understand your side note question how does partial-ordering work for sets? I'm not sure what you're asking. That is, one counter will be considered smaller-or-equal to another if for any item in the first counter, the second counter has an equal or bigger amount of that item. According to your definition, my example should have returned True, which is clearly nonsensical. In your example the first counter had `b` twice, while the second counter had it only once. So the result is `False`. This comes pretty directly from my definition, I'm not sure where the confusion is. Regarding your new example: Since `Counter` works like a `defaultdict`, the second counter has a zero quantity of `b`. So the answer is again `False`. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22515 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com