Re: Full time Job opening -Python lead in washington area.
Radhika Bauerle, 03.11.2011 01:05: Hello eveyone: Well, and here's the problem already: everyone. Note that it's commonly considered inappropriate to post job offers on this list. Please use the Python job board instead: http://python.org/community/jobs/ (easy to find by clicking on python jobs on the Python.org front page) Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
A task like this is more suited to bash than Python: find . -name '*.pyc' -exec rm '{}' ';' -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
This can be added to git as a post-checkout hook: In your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
This can be added to your project's .git/hooks/post-checkout: #!/usr/bin/env bash cd ./$(git rev-parse --show-cdup) find . -name '*.pyc' -exec rm '{}' ';' -- http://mail.python.org/mailman/listinfo/python-list
Paramiko Question
Hi All, I need help with the below mentioned script. The second time I call a.execute, self.transport.open_session() fails with an EOF error. Is this a paramiko bug or am I doing something wrong? import paramiko class Connection(object): def __init__(self, host, username = None, password = None, private_key = None, \ port = 22): self.transport = paramiko.Transport((host, port)) self.live = True self.transport.connect(username = username, password = password) def execute(self, command): channel = self.transport.open_session() channel.exec_command(command) output = channel.makefile('rb', -1).readlines() if output: print output else: print channel.makefile_stderr('rb', -1).readlines() def close(self): if self.live: self.transport.close() self.live = False def __del__(self): self.close() if __name__ == '__main__': a= Connection('ip_or_hostname', 'root', '') print a.execute('version') print a.execute('version') print a.execute('version') a.close() Regards, Jacob Abraham -- http://mail.python.org/mailman/listinfo/python-list
Re: Chaco for real-time plot of PySerial data
On 11/1/11 10:27 PM, Jack Keegan wrote: Hi there, I asked this question on the enthought chaco mailing list some time last by have yet to receive a reply. Thought I'd ask here to see if anyone could shed some light on things for me. I have been considering using chaco / traits for close to a year now and am finally biting the bullet so to speak. What I would really like to do to begin with is to make a real-time plotting application which gets its data from the serial port. Can anyone please point me in the right direction for doing this? Since I didn't get a reply on the chaco list I'm now thinking it might be a dangerous route to go down since it will be difficult to get help. Any recommendations? I'm sorry we didn't respond to you. The chaco-users mailing list is not well-subscribed or well-trafficked, but the enthought-...@enthought.com mailing list is. We haven't done a good job of letting new people know they should be on the chaco-users list to answer questions or updating the documentation to point users to enthought-dev instead. Anyways, to answer your question, we have several examples of how one sets up a plot then updates it with new data: https://github.com/enthought/chaco/tree/master/examples/demo/updating_plot I can't help much with the PySerial part, I'm afraid. Integrating that with the GUI event loop is probably going to be the trickiest bit. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Database access benchmarks for use in web-frameworks - How does Python compare?
Good afternoon, I'm building a large e-commerce site, and it is very important that what I write can: - Handle larger server load - Deliver pages quickly - Make transactions quickly as well as have a small development time (i.e. pre-built modules for e-commerce are available, and extendible). Are there recent accessible statistics available, comparing these metrics across the most popular web-frameworks? (i.e. Symfony, DJango, Rails, ASP.NET etc) Thanks for all suggestions, Alec Taylor -- http://mail.python.org/mailman/listinfo/python-list
ctypes: catch system exit from C library
Hi all, in my python application I am calling functions from a C library via `ctypes` interface. Some fns from that C library calls `exit()` on error. It causes that the python application crashes even without any notification. Is it possible to catch library system exit calls from such python application? Thanks in advance, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
Jonathan Hartley wrote: A task like this is more suited to bash than Python: find . -name '*.pyc' -exec rm '{}' ';' You forgot to exclude the .svn directory from the search and didn't limit the deletion to pyc-files whose corresponding py-file doesn't exist. How would your line look with these modifications? -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes: catch system exit from C library
Martin Landa landa.mar...@gmail.com wrote: Hi all, in my python application I am calling functions from a C library via `ctypes` interface. Some fns from that C library calls `exit()` on error. It causes that the python application crashes even without any notification. Is it possible to catch library system exit calls from such python application? Thanks in advance, Martin There is no safe way to do this. An unsafe way would be to install an atexit() handler and longjmp out of it, but that would mess up any other atexit processing and quite likely crash the program. Or you could just move the essential cleanup into atexit() but not attempt to stop the program termination. The clean (but not necessarily easy) solution would be to move all of the code that uses the library into a separate subprocess and then you can catch and handle the subprocess exiting in your main code. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes: catch system exit from C library
Am 03.11.2011 11:07, schrieb Martin Landa: in my python application I am calling functions from a C library via `ctypes` interface. Some fns from that C library calls `exit()` on error. Just curious, which library is that? Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes: catch system exit from C library
On 2011-11-03, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Am 03.11.2011 11:07, schrieb Martin Landa: in my python application I am calling functions from a C library via `ctypes` interface. Some fns from that C library calls `exit()` on error. Just curious, which library is that? And who should we have thrashed and pilloried for writing it that way? -- Grant Edwards grant.b.edwardsYow! BARRY ... That was at the most HEART-WARMING gmail.comrendition of I DID IT MY WAY I've ever heard!! -- http://mail.python.org/mailman/listinfo/python-list
Python Pickling Issue
I have written a fairly large DAG with python and I've run into an issue when attempting to pickle the data to disk. It will pickle fine the first time, but if I call pickle again, it throws this error. /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto) 68 else: 69 if base is self.__class__: --- 70 raise TypeError, can't pickle %s objects % base.__name__ 71 state = base(self) 72 args = (self.__class__, base, state) TypeError: can't pickle function objects I'm calling save_file = open('my_file.rsf', 'w') cPickle.dump(self, save_file) I have attempted to pickle the object to a different file after the first time, but the error is still thrown. This wouldn't be very hard to track down if the error gave any indication as to where or what this function it can't pickle is, so if there's any possible way to at least get the name of what's failing to be pickled, that would be a win. Thanks in advance for all replies. Brandon L. Harris -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Pickling Issue
After digging around a while I discovered I was attempting to pickle a third party class that can't be pickled. Initially I was removing it before pickling and everything was kosher, but at some point it got back onto the class. Apologies. Brandon L. Harris On 11/03/2011 09:42 AM, Brandon Harris wrote: I have written a fairly large DAG with python and I've run into an issue when attempting to pickle the data to disk. It will pickle fine the first time, but if I call pickle again, it throws this error. /usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto) 68 else: 69 if base is self.__class__: --- 70 raise TypeError, can't pickle %s objects % base.__name__ 71 state = base(self) 72 args = (self.__class__, base, state) TypeError: can't pickle function objects I'm calling save_file = open('my_file.rsf', 'w') cPickle.dump(self, save_file) I have attempted to pickle the object to a different file after the first time, but the error is still thrown. This wouldn't be very hard to track down if the error gave any indication as to where or what this function it can't pickle is, so if there's any possible way to at least get the name of what's failing to be pickled, that would be a win. Thanks in advance for all replies. Brandon L. Harris -- http://mail.python.org/mailman/listinfo/python-list
Re: Paramiko Question
On 03/11/2011 09:22, Jacob Abraham wrote: Hi All, I need help with the below mentioned script. The second time I call a.execute, self.transport.open_session() fails with an EOF error. Is this a paramiko bug or am I doing something wrong? import paramiko class Connection(object): def __init__(self, host, username = None, password = None, private_key = None, \ port = 22): self.transport = paramiko.Transport((host, port)) self.live = True self.transport.connect(username = username, password = password) def execute(self, command): channel = self.transport.open_session() channel.exec_command(command) output = channel.makefile('rb', -1).readlines() if output: print output else: print channel.makefile_stderr('rb', -1).readlines() def close(self): if self.live: self.transport.close() self.live = False def __del__(self): self.close() if __name__ == '__main__': a= Connection('ip_or_hostname', 'root', '') print a.execute('version') print a.execute('version') print a.execute('version') a.close() I notice that in the 'execute' method you're opening the session, but not closing it. Could that be the cause of the problem? I also notice that in that method you're printing the output, not returning it, but when you call the execute method you're trying to print the result, which will be None. -- http://mail.python.org/mailman/listinfo/python-list
Re: AIX installation can't find zlib
we using RPM to install python 2.7.x and same issue there, can't import gzip b/c zlib is missing. we used RPM to install zlib, but did not effect python. you mentioned modules and uncommenting something. could you be more specific? also , we are not compiling. would that be required for python after uncommenting zlib? -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
All these ideas (shell and git hooks) are nice, but unfortunately - it's svn not git - it's windows not *nix - we have to remove only the ones without the corresponding *py... -- http://mail.python.org/mailman/listinfo/python-list
Python advanced course (preferably in NA)
Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? BTW, I'm not a computer engineer and have mechanical background. Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advanced course (preferably in NA)
On Thu, Nov 3, 2011 at 12:13 PM, Behnam bkamr...@gmail.com wrote: Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? While I don't know specifically, check out the following link (from the Python site): http://wiki.python.org/moin/PythonTraining I have taken a class each (PyCon tutorial) from Raymond Hettinger, David Beazley, and Brian Jones, and found each of them to be outstanding courses. Only David is listed on that page to which I linked, though I know Raymond does courses at least from time to time. I've also heard a talk from Wesley Chun and found him to be fantastic. -eric BTW, I'm not a computer engineer and have mechanical background. Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Dictionary sorting
Python newbie here. So, when creating dictionaries, I am noticing that each time I print it out, that its not in the same order as when I typed it in. They seem to be getting sorted somehow. Is there a way to not sort them and leave the order as is? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
In 16245908.783.1320346014867.JavaMail.geo-discussion-forums@yqhd1 Scott Ware scottdw...@gmail.com writes: Python newbie here. So, when creating dictionaries, I am noticing that each time I print it out, that its not in the same order as when I typed it in. They seem to be getting sorted somehow. Is there a way to not sort them and leave the order as is? Dictionaries don't maintain the order of the items. If you want to keep track of the order in which the items were inserted, you'll need to do that yourself using a separate mechanism (a list, for example.) -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
Great! Thanks, John for the quick response! -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
Note that there are a number of recipes available for free online, and if you are using a newer version of Python (2.7 or higher), the collections module includes an OrderedDict class (http://docs.python.org/library/collections.html#collections.OrderedDict - this also include a library for Python 2.4 and higher as well). Note that there are a lot of different possible behaviors, so any particular recipe may or may not behave exactly as you desire. Chris On Thu, Nov 3, 2011 at 12:00 PM, Scott Ware scottdw...@gmail.com wrote: Great! Thanks, John for the quick response! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
Moreover, for on-the-fly ordering you can consider to use sorted() on yourdict.keys(), like: for k in sorted(yourdict.keys()): print k, yourdict[k] I think it has no side effects, except that the orderering can be slow on huge data sets, and that you need to call it every time after updating the dict keys. Regards, insomniac -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advanced course (preferably in NA)
On 11/3/2011 11:13 AM Behnam said... Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? This list works well for that. Try answering all OOP related questions as completely as possible and provide example code. Those that know the difference will promptly point out the improved and generally preferred approaches. When no one corrects you, you're done. Only-slightly-tongue-in-cheek-ly y'rs, Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
On Fri, Nov 4, 2011 at 4:54 AM, Andrea Crotti andrea.crott...@gmail.com wrote: All these ideas (shell and git hooks) are nice, but unfortunately - it's svn not git - it's windows not *nix - we have to remove only the ones without the corresponding *py... Windows? Well, Windows shell scripting isn't quite as rich as bash/csh/etc, but it's possible. I'll leave recursion as an exercise for the reader, but this (untested) should do it for one directory: for %d in (*.pyc) do ( set fn=%d if not exist !fn:~0,-1! del %d ) This needs to be run with 'cmd /v' to enable delayed variable evaluation. Of course, it'd be really easy to do if Windows Batch had anything like decent string manipulation. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
On 11/3/2011 2:46 PM, Scott Ware wrote: Python newbie here. So, when creating dictionaries, I am noticing that each time I print it out, that its not in the same order as when I typed it in. They seem to be getting sorted somehow. No, the entries are not being sorted at all. Is there a way to not sort them and leave the order as is? CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in any way. If you want to keep the dict sorted by entry order (as far as the user view goes), use collections.OrderedDict. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advanced course (preferably in NA)
http://www.dabeaz.com/pythonmaster.html -- Original Message -- From: Emile van Sebille em...@fenx.com Date: Thu, 03 Nov 2011 14:25:03 -0700 On 11/3/2011 11:13 AM Behnam said... Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? This list works well for that. Try answering all OOP related questions as completely as possible and provide example code. Those that know the difference will promptly point out the improved and generally preferred approaches. When no one corrects you, you're done. Only-slightly-tongue-in-cheek-ly y'rs, Emile -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advanced course (preferably in NA)
I've taken two Python classes from David Beazley and can second Eric's recommendation. The advanced class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth the time and money! Catherine Eric Snow wrote: On Thu, Nov 3, 2011 at 12:13 PM, Behnam bkamr...@gmail.com wrote: Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? While I don't know specifically, check out the following link (from the Python site): http://wiki.python.org/moin/PythonTraining I have taken a class each (PyCon tutorial) from Raymond Hettinger, David Beazley, and Brian Jones, and found each of them to be outstanding courses. Only David is listed on that page to which I linked, though I know Raymond does courses at least from time to time. I've also heard a talk from Wesley Chun and found him to be fantastic. -eric BTW, I'm not a computer engineer and have mechanical background. Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python advanced course (preferably in NA)
I've taken two Python classes from David Beazley and can second Eric's recommendation. The advanced class is really advanced and goes into some pretty mind-blowing stuff. The class comes with lots of problems and solutions, and a book of all the slides which are a great reference. Well worth the time and money! Catherine Eric Snow wrote: On Thu, Nov 3, 2011 at 12:13 PM, Behnam bkamr...@gmail.com wrote: Anybody is aware of any advanced course in Python preferably in north america? I've been partly coding in Python for couple of years now and have used PyQt. What I'd like to learn more is a kind of advance OOP in python. Any idea? While I don't know specifically, check out the following link (from the Python site): http://wiki.python.org/moin/PythonTraining I have taken a class each (PyCon tutorial) from Raymond Hettinger, David Beazley, and Brian Jones, and found each of them to be outstanding courses. Only David is listed on that page to which I linked, though I know Raymond does courses at least from time to time. I've also heard a talk from Wesley Chun and found him to be fantastic. -eric BTW, I'm not a computer engineer and have mechanical background. Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
SystemError when defining
Try this out (Python 3.2.2 (default, Sep 5 2011, 04:52:19)): global_variable = None (lambda *, keyword_only=global_variable: None) # Works, as expected (lambda: (lambda argument=global_variable: None))()# Works, as expected (lambda: (lambda *, keyword_only=global_variable: None))() # Fails??? (lambda: (lambda argument=fake_variable: None))() # Fails, as expected (lambda: (lambda *, keyword_only=fake_variable: None))() # Fails??? Non-lambdas work as expected, but a lambda inside a non-lambda still exhibits this behaviour. Conclusion: When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython is unable to access the global scope and raises SystemError. -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
On 11/03/11 16:36, Terry Reedy wrote: Is there a way to not sort them and leave the order as is? CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in any way. Does this never trust it hold even for two consecutive iterations over an unchanged dict? I didn't see anything in the docs[1] to make such a claim, but at least from my experience, one can reliably assert d = {} randomly_populate(d) list1 = list(d.iterkeys()) list2 = list(d.iterkeys()) assert list1 == list2 I understand all bets are off if one adds/removes (or maybe changes the values) of the dict between iterations, but I didn't know if what I saw was merely an implementation detail that shouldn't be counted on. -tkc [1] http://docs.python.org/library/stdtypes.html#mapping-types-dict -- http://mail.python.org/mailman/listinfo/python-list
Re: SystemError when defining
On Fri, Nov 4, 2011 at 9:24 AM, Joshua Landau joshua.landau...@gmail.com wrote: Non-lambdas work as expected, but a lambda inside a non-lambda still exhibits this behaviour. Conclusion: When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython is unable to access the global scope and raises SystemError. Fascinating! I did some introspection with this: def foo(): a=1 # to make sure local variables do exist return (lambda *,keyword_only=global_variable: None)() dis.dis(foo) 2 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (a) 3 6 LOAD_CONST 2 ('keyword_only') 9 LOAD_NAME0 (global_variable) 12 LOAD_CONST 3 (code object lambda at 0x00FC7340, file pyshell#18, line 3) 15 MAKE_FUNCTION 256 18 CALL_FUNCTION0 21 RETURN_VALUE def foo(): a=1 return (lambda argument=global_variable: None)() dis.dis(foo) 2 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (a) 3 6 LOAD_GLOBAL 0 (global_variable) 9 LOAD_CONST 2 (code object lambda at 0x00F95E30, file pyshell#23, line 3) 12 MAKE_FUNCTION1 15 CALL_FUNCTION0 18 RETURN_VALUE Variations on the theme show that during compilation of foo, the name is normally cemented as either a global or a local - but if it's keyword-only, then a LOAD_NAME opcode is emitted. It's the code for LOAD_NAME that looks for locals, which presumably a lambda doesn't have. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
On Fri, Nov 4, 2011 at 10:01 AM, Tim Chase python.l...@tim.thechases.com wrote: list1 = list(d.iterkeys()) list2 = list(d.iterkeys()) assert list1 == list2 There is such a guarantee in Python 2. From http://docs.python.org/library/stdtypes.html: If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond. This allows the creation of (value, key) pairs using zip(): pairs = zip(d.values(), d.keys()). The same relationship holds for the iterkeys() and itervalues() methods: pairs = zip(d.itervalues(), d.iterkeys()) provides the same value for pairs. Another way to create the same list is pairs = [(v, k) for (k, v) in d.iteritems()]. Python 3 does things quite differently (with views), and I can't find a corresponding promise, but I expect that this would still be the case. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary sorting
Tim Chase python.l...@tim.thechases.com writes: On 11/03/11 16:36, Terry Reedy wrote: CPython iterates (and prints) dict items in their arbitrary internal hash table order, which depends on the number and entry order of the items. It is a bug to depend on that arbitrary order in any way. Does this never trust it hold even for two consecutive iterations over an unchanged dict? I didn't see anything in the docs[1] to make such a claim, Exactly. The order of retrieval is entirely up to the implementation. There is no guarantee that the order will be the same the next time you iterate over the same dict. It is a bug to depend on a reliable order of retrieving the items. I didn't know if what I saw was merely an implementation detail that shouldn't be counted on. If the docs don't specify some particular observed behaviour in Python, you should consider it an implementation detail. -- \ “Pray, v. To ask that the laws of the universe be annulled in | `\ behalf of a single petitioner confessedly unworthy.” —Ambrose | _o__) Bierce, _The Devil's Dictionary_, 1906 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: leftover pyc files
On Thu, Nov 3, 2011 at 1:54 PM, Andrea Crotti andrea.crott...@gmail.com wrote: All these ideas (shell and git hooks) are nice, but unfortunately - it's svn not git - it's windows not *nix - we have to remove only the ones without the corresponding *py... -- http://mail.python.org/mailman/listinfo/python-list Barely tested. Change the print functions to removes. Pass the top directory as the argument. import os, sys for dirpath, dirnames, filenames in os.walk(sys.argv[1]): if dirpath.endswith(__pycache__): thispath = dirpath[:-11] for f in filenames: if f.endswith(.pyc): if not os.path.exists(os.path.join(thispath,f[:-1])): print(delete + os.path.join(thispath,f)) else: for f in filenames: if f.endswith(.pyc): if not os.path.exists(os.path.join(dirpath,f[:-1])): print(delete + os.path.join(dirpath,f)) #os.remove(os.path.join(dirpath,f)) -- http://mail.python.org/mailman/listinfo/python-list
Design Pattern and Python: Any book recommendation? Your view?
Sorry to resurrect this topic. By google search the last discussion was in 2003. I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy -- http://mail.python.org/mailman/listinfo/python-list
Re: Design Pattern and Python: Any book recommendation? Your view?
In article 6097694.446.1320366784098.JavaMail.geo-discussion-forums@prap37, Anthony Kong anthony.hw.k...@gmail.com wrote: Sorry to resurrect this topic. By google search the last discussion was in 2003. What? We're bring it up again, SO SOON!? I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? [...] I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP To a certain extent, I agree. I don't have a huge amount of experience in Design Patterns, but have read (years ago) the obligatory Gang Of Four book. My impression was that much of that book was about how to build sane data structures to do useful things given the uber-bondage constraints of the C++ and Java typing systems. For example, let's look at Singleton. It's a useful pattern. Here's how I would implement Singleton in Python (hand-waving a bit about the syntax details): class Printer: thePrinter = None @staticmethod def get(): if Printer.thePrinter is None: Printer.thePrinter = Printer() return thePrinter def print(self): print some stuff whatever That seems to cover everything Singleton needs to do. In your application code, you do: myPrinter = Printer.get() myPrinter.print() and you can sleep easy knowing you've got the same Printer instance every time. The GoF version for C++ is filled with minutia about private constructors and assignment operators. All that stuff is important to get right in C++, but it has nothing to do with Singleton, per se. It's just all the gunk you have to worry about to correctly implement Singleton in C++. -- http://mail.python.org/mailman/listinfo/python-list
Re: Design Pattern and Python: Any book recommendation? Your view?
On Thu, Nov 3, 2011 at 5:33 PM, Anthony Kong anthony.hw.k...@gmail.com wrote: Sorry to resurrect this topic. By google search the last discussion was in 2003. I would like to find out what is the current prevailing view or consensus (if any) on the use of Design Pattern in python? I can only speak for myself, but the whole idea of design patterns is broken. The existence of nontrivial design patterns indicates language deficiencies. For more extensive corroborating discussions, see: http://www.codinghorror.com/blog/2005/06/are-design-patterns-how-languages-evolve.html http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures Python thankfully has relatively few/minor deficiencies (so long as one judges it within its dynamic language niche), so design patterns per se aren't too relevant to it. The canonical Python-specific design pattern is Borg (http://code.activestate.com/recipes/66531-singleton-we-dont-need-no-stinkin-singleton-the-bo/ ) [a variation on Singleton], and nowadays it (like its parent, Singleton) is considered to be of dubious utility/advisability. I am doing some 'fact-finding' in this area on request of my colleagues. Some of them want to buy a book or two in this subject area. Hopefully the newsgroup can give me some book recommendation and insight in this topic. The closest alternative would be some publication that gave examples of using some of Python's fancier, higher-level features, such as metaclasses and context managers. I haven't been in the market for such a book, so I have no good recommendations to give. Closest I could suggest would be the Language Reference (http://docs.python.org/reference/ ) and relevant PEPs (http://www.python.org/dev/peps/ ; they tend to include examples by way of motivating use-cases). I myself pretty much subscribe to the view that the nature of python language actually do away much of the need of the use of DP, but it is just a personal view. It comes form my experience of migrating from webware4py (webframework based on J2EE/servlet idea) to cherrypy I am glad you agree. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
match, concatenate based on filename
Hi All, I am trying to concatenate several hundred files based on their filename.. Filenames are like this: Q1.HOMOblast.fasta Q1.mus.blast.fasta Q1.query.fasta Q2.HOMOblast.fasta Q2.mus.blast.fasta Q2.query.fasta ... Q1223.HOMOblast.fasta Q1223.mus.blast.fasta Q1223.query.fasta All the Q1's should be concatenated together in a single file = Q1.concat.fasta.. Q2's go together, Q3's and so on... I envision something like for file in os.listdir(/home/matthew/Desktop/pero.ngs/fasta/final/): if file.startswith(Q%i): concatenate... But I can't figure out how to iterate this process over Q-numbers 1-1223 Any help appreciate. -- http://mail.python.org/mailman/listinfo/python-list
Re: match, concatenate based on filename
On Nov 3, 9:55 pm, Matt macma...@gmail.com wrote: Hi All, I am trying to concatenate several hundred files based on their filename.. Filenames are like this: Q1.HOMOblast.fasta Q1.mus.blast.fasta Q1.query.fasta Q2.HOMOblast.fasta Q2.mus.blast.fasta Q2.query.fasta ... Q1223.HOMOblast.fasta Q1223.mus.blast.fasta Q1223.query.fasta All the Q1's should be concatenated together in a single file = Q1.concat.fasta.. Q2's go together, Q3's and so on... I envision something like for file in os.listdir(/home/matthew/Desktop/pero.ngs/fasta/final/): if file.startswith(Q%i): concatenate... But I can't figure out how to iterate this process over Q-numbers 1-1223 Any help appreciate. I haven't tested this, so may have a typo or something, but it's often much cleaner to gather your information, massage it, and then use, than it is to gather it and use it in one go. from collections import defaultdict filedict = defaultdict(list) for fname in sorted(os.listdir(mydir)): if fname.startswith('Q') and '.' in fname: filedict[fname[:fname.find('.')]].append(fname) for prefix, fnames in filedict.iteritems(): #print prefix, fnames concatenate... HTH, Pat -- http://mail.python.org/mailman/listinfo/python-list
Re: match, concatenate based on filename
In 31568428.553.1320375329695.JavaMail.geo-discussion-forums@prgt40 Matt macma...@gmail.com writes: But I can't figure out how to iterate this process over Q-numbers 1-1223 for i in xrange(1, 1224): Q = Q%d % i file1 = %s.HOMOblast.fasta % Q file2 = %s.mus.blast.fasta % Q file3 = %s.query.fasta % Q target = %s.concat.fasta % Q concatenate(file1, file2, file3, target) Assuming that there are exactly three files to be concatenated for each value of i. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
[issue13330] Attempt full test coverage of LocaleTextCalendar.formatweekday
New submission from Sean Fleming seanmtflem...@gmail.com: Patch includes new statements in test_localecalendars of CalendarTestCase such that coverage of LocaleTextCalendar.formatweekday should improve significantly. Feedback is appreciated. -- components: Tests files: test_calendar.patch keywords: patch messages: 146895 nosy: Sean.Fleming priority: normal severity: normal status: open title: Attempt full test coverage of LocaleTextCalendar.formatweekday versions: Python 3.4 Added file: http://bugs.python.org/file23603/test_calendar.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13330 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13315] tarfile extract fails on OS X system python due to chown of gid=-1
Ronald Oussoren ronaldousso...@mac.com added the comment: There's little chance that Apple will fix this issue in their build (at least not until Lion+1 gets released) because this is not a security bug. Their breaking of 2.7 in Lion is probably due to lack of review for their collection of patches, and is not something we can fix. I'd close this as invalid as the issue is already fixed in our codebase. I won't file a bug at Apple for this, although that shouldn't stop anyone else from doing so (and remember: bugreport.apple.com is a popularity contest, the more people file an report about a bug the more likely it is that it will get fixed) -- status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13315 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13298] Result type depends on order of operands for bytes and bytearray
Petri Lehtinen pe...@digip.org added the comment: Note that .join() has a slightly different behaviour: b.join([bytearray(), b]) b'' bytearray().join([bytearray(), b]) bytearray(b'') b.join([bytearray(), memoryview(b)]) Traceback (most recent call last): File stdin, line 1, in module TypeError: sequence item 1: expected bytes, memoryview found I thinks this is worth fixing. Is there an issue already? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13298 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13308] fix test_httpservers failures when run as root
Charles-François Natali neolo...@free.fr added the comment: You should change issue # with the real issue number now that there's an issue for this :) Done :-) -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13308 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Petri Lehtinen pe...@digip.org added the comment: According to the man page, find -print0 and xargs -r are also GNU extensions. Even though they work on OpenBSD (do they?), they could still break on some platforms. As find -exec cmd {} ';' is already used for everything but __pycache__, I'd rather only change the removal of __pycache__. I believe there are more files that match '*.py[co]' than '__pycache__', and people are already waiting for a separate rm process to be invoked on each *.py[co], so invoking a separate rmdir for each __pycache__ shouldn't make it much slower. -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13327] Update utime API to not require explicit None argument
Petri Lehtinen pe...@digip.org added the comment: +1 on making the second arg optional. -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13327 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13328] pdb shows code from wrong module
Changes by Petri Lehtinen pe...@digip.org: -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13328 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13298] Result type depends on order of operands for bytes and bytearray
Nick Coghlan ncogh...@gmail.com added the comment: We can just use this one - it was more in the nature of a question is there anything we want to change about the status quo? than a request for any specific change. I'm actually OK with buffer API based interoperability, but if we're going to offer that, we should be consistent: 1. bytes and bytearray should interoperate with anything supporting the buffer interface (which they already mostly do) 2. When they encounter each other, LHS wins (as with set() and frozenset()) 3. We should fix the operand coercion bug for C level concatenation slot implementations (already covered by issue #11477) 4. Update the documentation as needed Since we're tinkering with builtin behaviour, 1 2 should probably be brought up on python-dev once someone checks if there is anything other than .join() that needs updating. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13298 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Remi Pointel pyt...@xiri.fr added the comment: According to the man page, find -print0 and xargs -r are also GNU extensions. Even though they work on OpenBSD (do they?), they could still break on some platforms. Yes, it works fine, but you're allright. As find -exec cmd {} ';' is already used for everything but __pycache__, I'd rather only change the removal of __pycache__. I believe there are more files that match '*.py[co]' than '__pycache__', and people are already waiting for a separate rm process to be invoked on each *.py[co], so invoking a separate rmdir for each __pycache__ shouldn't make it much slower. You mean to just exec rmdir instead of rm only for __pycache__? Cheers, Remi. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13308] fix test_httpservers failures when run as root
Petri Lehtinen pe...@digip.org added the comment: I mean that this should be enough to close this issue: - -find $(srcdir) -name '__pycache__' -exec rmdir {} '+' + -find $(srcdir) -name '__pycache__' -exec rmdir {} ';' That is, use ';' instead of the unportable '+' instead of changing all cleaning to use find ... | xargs ... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13308 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13308] fix test_httpservers failures when run as root
Petri Lehtinen pe...@digip.org added the comment: Whoops, posted the previous message to a totally wrong issue. Who was it thag introduced tabbed browsing? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13308 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Petri Lehtinen pe...@digip.org added the comment: I mean that this should be enough to close this issue: - -find $(srcdir) -name '__pycache__' -exec rmdir {} '+' + -find $(srcdir) -name '__pycache__' -exec rmdir {} ';' That is, use ';' instead of the unportable '+' instead of changing all cleaning to use find ... | xargs ... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13329] Runs normal as console script but falls as CGI
Petri Lehtinen pe...@digip.org added the comment: How are you running the CGI script? Are you sure that the PYTHONIOENCODING environment variable isn't set by the HTTP server? -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13329 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Remi Pointel pyt...@xiri.fr added the comment: Please see this: http://bugs.python.org/issue8665 http://hg.python.org/cpython/rev/5468f3aee4ae/ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Petri Lehtinen pe...@digip.org added the comment: Ah, I didn't think about that. How about using the -depth option then? It's in POSIX but does OpenBSD have it? The man page of GNU find says it has a -d option (that does the same as -depth) for compatibility with BSD. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13330] Attempt full test coverage of LocaleTextCalendar.formatweekday
Changes by Petri Lehtinen pe...@digip.org: -- components: +Library (Lib) keywords: +needs review stage: - patch review type: - feature request versions: +Python 3.3 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13330 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Remi Pointel pyt...@xiri.fr added the comment: How about using the -depth option then? It's in POSIX but does OpenBSD have it? The man page of GNU find says it has a -d option (that does the same as -depth) for compatibility with BSD. Yes, we have this option: -depth This primary always evaluates to true. The same as specifying the -d option. Source: http://www.openbsd.org/cgi-bin/man.cgi?query=find -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
STINNER Victor victor.stin...@haypocalc.com added the comment: By the way, removing *.pyc and *.pyo is useless: Python 3.3 only generates such files in __pycache__: + -find $(srcdir) -name '*.py[co]' -print0 | xargs -0r rm -f + -find $(srcdir) -name '__pycache__' -print0 | xargs -0r rmdir can be simplified to + -find $(srcdir) -name '__pycache__' -print0 | xargs -0r rm -rf -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6434] buffer overflow in Zipfile when wrinting more than 2gig file
Miguel Hernández Martos enla...@gmail.com added the comment: I think it's a dup of http://bugs.python.org/issue9720 That issue has a patch that allows the generation of zip files with 2GB files. -- nosy: +enlavin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6434 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Petri Lehtinen pe...@digip.org added the comment: + -find $(srcdir) -name '__pycache__' -print0 | xargs -0r rm -rf I'd still do it like this for portability's sake: + -find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10570] curses.tigetstr() returns bytes, but curses.tparm() expects a string
Petri Lehtinen pe...@digip.org added the comment: It seems that putp() should also accept only bytes, because it's used to output terminal commands. It's currently expecting a str. -- resolution: fixed - stage: patch review - committed/rejected status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10570 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1469629] __dict__ = self in subclass of dict causes a memory leak?
Changes by Boris FELD lothiral...@gmail.com: -- nosy: +Boris.FELD ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1469629 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3067] setlocale error message is confusing
Changes by Petri Lehtinen pe...@digip.org: -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3067 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13327] Update utime API to not require explicit None argument
Antoine Pitrou pit...@free.fr added the comment: The `delta` keyword would actually be better than `places`, especially on the slower buildbots. delta=10 would allow up to 10 seconds between those utime calls. Is that being too permissive? I think it's ok. We don't have to test the system's utime implementation, just that the second parameter does what it should. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13327 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Antoine Pitrou pit...@free.fr added the comment: I'd still do it like this for portability's sake: + -find $(srcdir) -depth -name '__pycache__' -exec rm -rf {} ';' Then you'd probably reintroduce issue8665. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Petri Lehtinen pe...@digip.org added the comment: Then you'd probably reintroduce issue8665. No, the -depth argument avoids that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13331] Packaging cannot install resource directory trees specified in setup.cfg
New submission from Vinay Sajip vinay_sa...@yahoo.co.uk: If setup.cfg contains a line such as [files] resources = mydata/** = {purelib} and the project contains a directory tree more than one level deep under mydata, e.g. mydata | +-mydata1 | | | +-data1.dat | +-mydata2 | +-data2.dat then the parsing correctly identifies all the things to copy, but the install_data step fails because it does not try to create intermediate directories for mydata1, mydata2 but tries to copy them as files using copy_file. -- assignee: tarek components: Distutils2, Library (Lib) messages: 146917 nosy: alexis, eric.araujo, tarek, vinay.sajip priority: high severity: normal status: open title: Packaging cannot install resource directory trees specified in setup.cfg versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13331 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13332] execfile fixer produces code that does not close the file
New submission from Sven Marnach s...@marnach.net: The execfile fixer of the 2to3 script replaces the 2.x code execfile(a.py) by exec(compile(open(a.py).read(), a.py, 'exec')) The new code does not explicitly close the file. This is not usually a problem in CPython, but 1. the code will throw a RessourceWarnings if enabled and 2. other Python implementation don't close the file immediately. (I think the 2to3 script should be as implementation-independent as possible.) The obvious fix would be to use a with-statement: with open(a.py) as new_name: exec(compile(new_name.read(), a.py, 'exec')) If this is to be changed, I'd be happy to prepare a patch. -- components: 2to3 (2.x to 3.x conversion tool) messages: 146918 nosy: smarnach priority: normal severity: normal status: open title: execfile fixer produces code that does not close the file type: behavior versions: Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13332 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13333] utf-7 inconsistent with surrogates
New submission from Antoine Pitrou pit...@free.fr: The utf-7 codec happily encodes lone surrogates, but it won't decode them: \ud801.encode(utf-7) b'+2AE-' \ud801\ud801.encode(utf-7) b'+2AHYAQ-' \ud801.encode(utf-7).decode(utf-7) Traceback (most recent call last): File stdin, line 1, in module File /home/antoine/cpython/default/Lib/encodings/utf_7.py, line 12, in decode return codecs.utf_7_decode(input, errors, True) UnicodeDecodeError: 'utf7' codec can't decode bytes in position 0-4: second surrogate missing at end of shift sequence \ud801\ud801.encode(utf-7).decode(utf-7) Traceback (most recent call last): File stdin, line 1, in module File /home/antoine/cpython/default/Lib/encodings/utf_7.py, line 12, in decode return codecs.utf_7_decode(input, errors, True) UnicodeDecodeError: 'utf7' codec can't decode bytes in position 0-6: second surrogate missing I don't know which behaviour is better but round-tripping is certainly a desirable property of any codec. -- components: Interpreter Core, Unicode messages: 146919 nosy: ezio.melotti, loewis, pitrou priority: normal severity: normal status: open title: utf-7 inconsistent with surrogates type: behavior versions: Python 2.7, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13327] Update utime API to not require explicit None argument
Jesús Cea Avión j...@jcea.es added the comment: +1 to the optional parameter. -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13327 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Antoine Pitrou pit...@free.fr added the comment: No, the -depth argument avoids that. Ah, you are right, my bad. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6434] buffer overflow in Zipfile when wrinting more than 2gig file
Nadeem Vawda nadeem.va...@gmail.com added the comment: Marking as duplicate. -- resolution: - duplicate stage: needs patch - committed/rejected status: open - closed superseder: - zipfile writes incorrect local file header for large files in zip64 type: crash - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6434 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9720] zipfile writes incorrect local file header for large files in zip64
Nadeem Vawda nadeem.va...@gmail.com added the comment: Issue 6434 was marked as a duplicate of this issue. -- nosy: +Paul, amaury.forgeotdarc, enlavin, lambacck, nadeem.vawda, segfault42 stage: - needs patch versions: +Python 3.3 -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9720 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13333] utf-7 inconsistent with surrogates
Changes by Petri Lehtinen pe...@digip.org: -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13332] execfile fixer produces code that does not close the file
Petri Lehtinen pe...@digip.org added the comment: Sounds reasonable to me. Is it easy to generate unique identifier names in 2to3 fixers? -- nosy: +petri.lehtinen ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13332 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13332] execfile fixer produces code that does not close the file
Antoine Pitrou pit...@free.fr added the comment: Be aware that execfile() is a simple function call and can be used in any expression. -- nosy: +benjamin.peterson, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13332 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13315] tarfile extract fails on OS X system python due to chown of gid=-1
Dave Flogeras dfloger...@gmail.com added the comment: Thank you sirs. I've already got a workaround for this situation, and personally don't care to waste my time with apple. I'm satisfied that Python is handling bugs seriously and it will hopefully get into an apple release in the future. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13315 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13334] Erroneous Size check in
New submission from david db.pub.m...@gmail.com: The _PyString_Resize function in stringobject.c[0] takes in a PyObject ** and a Py_ssize_t newsize. Where Py_ssize_t is often a typedef for ssize_t(a signed version of size_t). As such the newsize parameter could be negative. The code checks for when the newsize is negative like so: int _PyString_Resize(PyObject **pv, Py_ssize_t newsize) { ... if (!PyString_Check(v) || Py_REFCNT(v) != 1 || newsize 0 || PyString_CHECK_INTERNED(v)) { *pv = 0; Py_DECREF(v); PyErr_BadInternalCall(); return -1; } Unfortunately, a few lines below it does the following: *pv = (PyObject *) PyObject_REALLOC((char *)v, PyStringObject_SIZE + newsize); so now if PyStringObject_SIZE + newsize is enough to wrap around then realloc through python will end up allocating insufficient space for the 'new' string. The python interpreter is likely to crash on this line -- sv-ob_sval[newsize] = '\0'; I haven't tried to reproduce this in the python interpreter. IMHO the code should be checking that newline + PyStringObject_SIZE is non-negative. [0] - http://svn.python.org/projects/python/trunk/Objects/stringobject.c -- messages: 146927 nosy: db priority: normal severity: normal status: open title: Erroneous Size check in ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13334 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13335] Service application hang in python25.dll
New submission from Chandra Sekhar Reddy sanc...@ca.com: Service application hanged in python25.dll, below are the environment details. Operating System : Windows server 2008 R2 (Virtual Machine) Application Type : Service Application We have got the process dump from the customer environment and after analyzing the dump using the Windbg tool. Below is the status of the 4 running threads. Last error for thread 0: LastErrorValue: (Win32) 0 (0) - The operation completed successfully. LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0 Last error for thread 1: LastErrorValue: (Win32) 0 (0) - The operation completed successfully. LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0 Last error for thread 2: LastErrorValue: (Win32) 0 (0) - The operation completed successfully. LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0 Last error for thread 3: LastErrorValue: (Win32) 0 (0) - The operation completed successfully. LastStatusValue: (NTSTATUS) 0 - STATUS_WAIT_0 But as part of the hang analysis the command !analyze -hang shows some problem with thread 1 Probably caused by : python25.dll ( python25!PyList_New+62 ) 03dff250 1e072c5b python25!PyFuture_FromAST+0x873 03dff25c 1e073307 python25!PyFuture_FromAST+0xbcb 03dff264 1e07332e python25!PyObject_GC_Malloc+0x67 03dff270 1e081502 python25!PyObject_GC_New+0xe python25!PyList_New+0x62 Thanks, -Chandra -- components: Windows messages: 146928 nosy: chandra priority: normal severity: normal status: open title: Service application hang in python25.dll type: performance versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13335 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13334] Erroneous Size check in
Changes by david db.pub.m...@gmail.com: -- components: +None versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13334 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13334] Erroneous Size check in _PyString_Resize
Changes by david db.pub.m...@gmail.com: -- title: Erroneous Size check in - Erroneous Size check in _PyString_Resize ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13334 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13334] Erroneous Size check in _PyString_Resize
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Let's take an example: on a 32bit system, call _PyString_Resize(s, 0x7ff8) Then PyStringObject_SIZE + newsize is something like -0x7ff8 (yes, it wraps around and is a negative number) But when cast to an unsigned size_t (because that's what PyObject_REALLOC declares as parameter), it becomes 0x8008, which is correct even if it is very likely to fail. Did you experience something different? -- nosy: +amaury.forgeotdarc resolution: - invalid status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13334 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13335] Service application hang in python25.dll
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: This information is far too incomplete, but as a first step, did you check the memory usage of the process? Is the computer constantly swapping memory to disk? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13335 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13332] execfile fixer produces code that does not close the file
Sven Marnach s...@marnach.net added the comment: @Petri: Yes, that's what the BaseFix.new_name() method is for. @Antoine: I thought about this, though I don't think it is very common to call execfile() as part of an expression. The whole statement containing the function call would need to be wrapped. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13332 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13334] Erroneous Size check in _PyString_Resize
david db.pub.m...@gmail.com added the comment: Yes my bad :-) I got my C test case wrong. -- status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13334 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13334] Erroneous Size check in _PyString_Resize
Changes by Amaury Forgeot d'Arc amaur...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13334 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13311] asyncore handle_read should call recv
Giampaolo Rodola' g.rod...@gmail.com added the comment: When the remote end disconnects, handle_close is only called if recv is called (from handle_read). Actually this isn't true; handle_close() is also called in send(): http://hg.python.org/cpython/file/eb2991f7cdc8/Lib/asyncore.py#l364 I'd say your patch can be useful only in case the dispatcher subclass doesn't send() neither recv() any data, in which case the connection is supposed to remain open forever. On one hand this might be a good thing, on the other hand I'm not sure what the repercussions might be in the existing code base out there. Probably none, but... Perhaps you could provide more info about why you needed to do this in the first place. Did you encounter a specific use case requiring this patch in order to work? If so, please paste the code where you subclassed asyncore.dispatcher. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13311 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13326] make clean failed on OpenBSD
Petri Lehtinen pe...@digip.org added the comment: The issue exists only in 3.2 and 3.3, as 2.7 doesn't have __pycache__ (PEP 3147). In 3.2 and 3.3, all *.py[co] files are in __pycache__ directories, so the pycremoval make target can only remove the __pycache__ directories, using the -depth option of find to remove child directories before the parent. -- keywords: +easy stage: - needs patch versions: +Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13326 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13285] signal module ignores external signal changes
Vilya Harvey vilya.har...@gmail.com added the comment: Petri: yes, that what I was suggesting. Charles-François: I'm certainly open to alternatives. Unless I've overlooked something though, the problem is that no workaround is possible at the moment. BTW this came up in the context of a customer script for the software I work on, so it's not just a theoretical problem - at least, not for me. :-) I guess another solution would be methods to save and restore the native signal handers, e.g. savesignal(signum) restoresignal(signum). That wouldn't entirely solve the problem - if someone called setsignal() before calling savesignal(), they'd end up in the same situation - but it would at least permit a workaround. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13285 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13309] test_time fails: time data 'LMT' does not match format '%Z'
Changes by Antoine Pitrou pit...@free.fr: -- priority: normal - deferred blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13309 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13322] buffered read() and write() does not raise BlockingIOError
sbt shibt...@gmail.com added the comment: Wierdly, it looks like BlockingIO is not raised anywhere in the code for the C implementation of io. Even more wierdly, in the Python implementation of io, BlockingIOError is only ever raised by except clauses which have already caught BlockingIOError. So, of course, these clauses are dead code. The only code in CPython which can ever succesfully raise BlockingIOError is MockNonBlockWriterIO.write() in test/test_io.py. I don't know what the correct behaviour is for flush() and close() if you get EAGAIN. I think flush() should raise an error rather than blocking, and that close() should delegate to self.raw.close() before raising the error. The docs say that read(), readinto() and write() can raise BlockingIOError. But what should readall() and readline() do? Should we just try to emulate whatever Python's old libc IO system did (with BlockingIOError replacing IOError(EAGAIN))? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13322 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13307] bdist_rpm: INSTALLED_FILES does not use __pycache__
Éric Araujo mer...@netwok.org added the comment: I wrote the same fix this night :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13307 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13224] Change str(class) to return only the class name
Éric Araujo mer...@netwok.org added the comment: Please also see the proposed PEP 3155 I’ve seen it and like it. I assume you’re telling that we should consider str(cls/mod/func) to return the qname instead of the name? I think it could be good. My patch can wait for your PEP, or go in first and be updated later if your PEP is accepted. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13224 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11254] distutils doesn't byte-compile .py files to __pycache__ during installation
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset ea926dff958f by Éric Araujo in branch '3.2': More fixes for PEP 3147 compliance in distutils (#11254) http://hg.python.org/cpython/rev/ea926dff958f New changeset 60ede940089f by Éric Araujo in branch 'default': Merge follow-up for #11254 and other changes from 3.2 http://hg.python.org/cpython/rev/60ede940089f -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11254 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13322] buffered read() and write() does not raise BlockingIOError
Antoine Pitrou pit...@free.fr added the comment: Wierdly, it looks like BlockingIO is not raised anywhere in the code for the C implementation of io. That would explain why it isn't raised :) This is a hairy issue: read(n) is documented as returning either n bytes or nothing. But what if less than n bytes are available non-blocking? Currently we return a partial read. readline() behaviour is especially problematic: fcntl.fcntl(r, fcntl.F_SETFL, os.O_NDELAY) 0 rf = open(r, mode='rb') os.write(w, b'xy') 2 rf.read(3) b'xy' os.write(w, b'xy') 2 rf.readline() b'xy' We should probably raise BlockingIOError in these cases, but that complicates the implementation quite a bit: where do we buffer the partial data? The internal (fixed size) buffer might not be large enough. write() is a bit simpler, since BlockingIOError has a characters_written attribute which is meant to inform you of the partial success: we can just reuse that. That said, BlockingIOError could grow a partial_read attribute containing the read result... Of course, we may also question whether it's useful to use buffered I/O objects around non-blocking file descriptors; if you do non-blocking I/O, you generally want to be in control, which means not having any implicit buffer between you and the OS. (this may be a topic for python-dev) -- nosy: +benjamin.peterson, neologix, stutzbach stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13322 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13331] Packaging cannot install resource directory trees specified in setup.cfg
Éric Araujo mer...@netwok.org added the comment: Should be easy to add a test to reproduce this. -- assignee: tarek - eric.araujo keywords: +easy priority: high - normal stage: - needs patch type: - behavior versions: +3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13331 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11254] distutils doesn't byte-compile .py files to __pycache__ during installation
Changes by Éric Araujo mer...@netwok.org: -- resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11254 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12120] test_packaging failure
Éric Araujo mer...@netwok.org added the comment: I have improved packaging to be independent of -B/-O in http://hg.python.org/cpython/rev/dad02a080bbc. See commit message for rationale. -- assignee: tarek - eric.araujo stage: - committed/rejected versions: +3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12120 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com