[ANN] bzr 2.5.0 released
On behalf of the Bazaar team and community, I'm happy to announce availability of a new release of the bzr adaptive version control system. Bazaar http://bazaar.canonical.com/ is a Canonical project and part of the GNU project http://gnu.org/ to produce a free operating system. Thanks to everyone who contributed patches, suggestions, and feedback. Bazaar is now available for download from https://launchpad.net/bzr/2.5/2.5.0 as a source tarball. Installers are available for windows and OSX from the url above too. This release marks the start of a new long-term-stable series. From here, we will only make bugfix releases on the 2.5 series (2.5.1, etc, and support it until April 2017), while 2.6 will become our new development series. This is a bugfix and polish release over the 2.4 series, with a large number of bugs fixed (~170 for the 2.5 series alone). The 2.5 series provides a faster smart protocol implementation for many operations, basic support for colocated branches. We have started translating bzr with the 2.5 series: https://translations.launchpad.net/bzr, more than 20 languages have already been registered but these are the early days, contributions welcome. Only a few bugfixes have been included since 2.5b6 so all known fixed bugs are included here. Users are encouraged to upgrade from the other stable series. See http://doc.bazaar.canonical.com/bzr.dev/en/whats-new/whats-new-in-2.5.html for more details, Vincent -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Get tkinter text to the clipboard
How about import tkinter root = tkinter.Tk() root.clipboard_clear() root.clipboard_append(whatever) that works, thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
Wanderer wande...@dialup4less.com wrote: How do you handle this sort of thing in Python? I believe that the best thing to do is a Union-Find algorithm. Depending on the exact nature of your problem, you may also want to check out the Hoshen-Kopelman Algorithm. Although the algorithm itself is rather efficient, it was born in the context of percolation, that is to say with the assumption that the broken (or colored) cells are much more likely than in your context. -- -riko http://www.enrico-franchi.org/ http://rik0-techtemple.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
On 3/8/12 9:12 AM, Enrico Franchi wrote: Wandererwande...@dialup4less.com wrote: How do you handle this sort of thing in Python? I believe that the best thing to do is a Union-Find algorithm. Another term this problem is finding the connected components. Here is some code from Stefan van der Walt for this: http://mentat.za.net/source/connected_components.tar.bz2 http://mentat.za.net/cgi-bin/hgwebdir.cgi/ccomp -- 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
Re: Python site-packages permission denied?
On Wed, 07 Mar 2012 21:47:37 -0800, Ned Deily wrote: In article camzyqrtxy3msmxtivue8apyx2zfag3dqp1un+fqwnaywnoa...@mail.gmail.com, Chris Rebert c...@rebertia.com wrote: You generally shouldn't mess with Mac OS X's system copies of Python. Typically, one installs a separate copy using MacPorts, Fink, or whatever, and uses that instead. I don't understand what you mean by mess with. Certainly one should not attempt alter standard library modules provided with the system Python but adding additional packages is fully supported. I read Chris as making a general comment that one should be cautious about making changes to the system copy of Python, advice that holds for all OSes not just OS-X. Apple conveniently provides a special directory in user-controlled space (/Library/Python) as the default location for Distutils-based installs. They even provide versions of easy_install for the system Pythons. Perhaps so, but it seems to have the permissions messed up, or some other problem, because the OP can't write to it. His error is: copying build/lib/urllib2_file.py - /Library/Python/2.7/site-packages error: /Library/Python/2.7/site-packages/urllib2_file.py: Permission denied I note also that Chris' final comment was: In any case, you generally need to `sudo` when installing stuff system- wide. which is probably the solution the OP is looking for. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Memory leak involving traceback objects
I have the same problem with python 2.6.2. I have upgraded to 2.7.1 and the leak is gone. -- http://mail.python.org/mailman/listinfo/python-list
cython + scons + c++
Is there a version of cython.py, pyext.py that will work with c++? I asked this question some time ago, but never got an answer. I tried the following code, but it doesn't work correctly. If the commented lines are uncommented, the gcc command is totally mangled. Although it did build my 1 test extension OK, I didn't use any libstdc++ - I suspect it won't link correctly in general because it doesn't seem to treat the code as c++ (treats it as c code). cyenv = Environment(PYEXT_USE_DISTUTILS=True) cyenv.Tool(pyext) cyenv.Tool(cython) import numpy cyenv.Append(PYEXTINCPATH=[numpy.get_include()]) cyenv.Replace(CYTHONFLAGS=['--cplus']) #cyenv.Replace(CXXFILESUFFIX='.cpp') #cyenv.Replace(CYTHONCFILESUFFIX='.cpp') -- http://mail.python.org/mailman/listinfo/python-list
Re: cython + scons + c++
Neal Becker, 08.03.2012 15:23: Is there a version of cython.py, pyext.py that will work with c++? I asked this question some time ago, but never got an answer. I tried the following code, but it doesn't work correctly. If the commented lines are uncommented, the gcc command is totally mangled. Although it did build my 1 test extension OK, I didn't use any libstdc++ - I suspect it won't link correctly in general because it doesn't seem to treat the code as c++ (treats it as c code). cyenv = Environment(PYEXT_USE_DISTUTILS=True) cyenv.Tool(pyext) cyenv.Tool(cython) import numpy cyenv.Append(PYEXTINCPATH=[numpy.get_include()]) cyenv.Replace(CYTHONFLAGS=['--cplus']) #cyenv.Replace(CXXFILESUFFIX='.cpp') #cyenv.Replace(CYTHONCFILESUFFIX='.cpp') I don't use Scons, so I don't know if running the compiler at a command line level is the best way to do it in that build system. But I know that some people on the Cython users mailing list use it, so you may want to ask over there. https://groups.google.com/group/cython-users Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: cython + scons + c++
On 03/08/2012 09:23 AM, Neal Becker wrote: Is there a version of cython.py, pyext.py that will work with c++? I asked this question some time ago, but never got an answer. I tried the following code, but it doesn't work correctly. If the commented lines are uncommented, the gcc command is totally mangled. Although it did build my 1 test extension OK, I didn't use any libstdc++ - I suspect it won't link correctly in general because it doesn't seem to treat the code as c++ (treats it as c code). cyenv = Environment(PYEXT_USE_DISTUTILS=True) cyenv.Tool(pyext) cyenv.Tool(cython) import numpy cyenv.Append(PYEXTINCPATH=[numpy.get_include()]) cyenv.Replace(CYTHONFLAGS=['--cplus']) #cyenv.Replace(CXXFILESUFFIX='.cpp') #cyenv.Replace(CYTHONCFILESUFFIX='.cpp') I don't know anything about writing c/c++ code with Python. I have plenty of experience with each, but not together. But the usual C++ answer is to use an extern C declaration for any function you need to be visible to the outside world. It prevents the usual C++ name mangling. (It therefore also prevents function overloading and can't generally be used on class member functions) -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
newb __init__ inheritance
Hello everyone. This is my first post in this group. I started learning python a week ago from the dive into python e- book and thus far all was clear. However today while reading chapter 5 about objects and object orientation I ran into something that confused me. it says here: http://www.diveintopython.net/object_oriented_framework/defining_classes.html#fileinfo.class.example __init__ methods are optional, but when you define one, you must remember to explicitly call the ancestor's __init__ method (if it defines one). This is more generally true: whenever a descendant wants to extend the behavior of the ancestor, the descendant method must explicitly call the ancestor method at the proper time, with the proper arguments. However later on in the chapter: http://www.diveintopython.net/object_oriented_framework/userdict.html it says: Methods are defined solely by their name, and there can be only one method per class with a given name. So if a descendant class has an __init__ method, it always overrides the ancestor __init__ method, even if the descendant defines it with a different argument list. And the same rule applies to any other method. My question is if __init__ in the descendant class overrides __init__ in the parent class how can I call the parent's __init__ from the descendant class - I just overrode it didn't I? Am I missing something more fundamental here? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Can't get around HTTP/401 response using SUDS
SUDS version 0.4 pn x86_64 Python 2.7 I'm having a bear of a time getting HTTP Basic Authentication to work for a SOAP request via suds. Also using an HTTP proxy server. In WireShark I just see a request - GET http://./services/services/JobService-0.0.1?wsdl HTTP/1.1 Accept-Encoding: identity Host: ... Connection: close User-Agent: Python-urllib/2.7 This doesn't contain any authentication credentials so the response is HTTP/401, and the client doesn't retry with credentials. The response does come from the remote as I can see there is a WWW-Authenticate header and it is from an Apache Tomcat server - so it makes it through the proxy server. Code url = 'http://../services/services/JobService-0.0.1?wsdl' proxy = urllib2.ProxyHandler({'http': 'http://.:3128'}) transport = suds.transport.http.HttpAuthenticated() transport.urlopener = urllib2.build_opener(proxy) client = suds.client.Client(url, transport=transport, username='**', password='') I've tried the above as well as the method described at http://blogs.oucs.ox.ac.uk/inapickle/2011/05/14/exchange-web-services-suds-and-python/ It has the same problem. Back Trace Traceback (most recent call last): File etrace.py, line 30, in module client = suds.client.Client(url, transport=transport, username='***', password='*') File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py, line 112, in __init__ self.wsdl = reader.open(url) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/reader.py, line 152, in open d = self.fn(url, self.options) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/wsdl.py, line 136, in __init__ d = reader.open(url) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/reader.py, line 79, in open d = self.download(url) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/reader.py, line 95, in download fp = self.options.transport.open(Request(url)) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/transport/http.py, line 173, in open return HttpTransport.open(self, request) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/transport/http.py, line 64, in open raise TransportError(str(e), e.code, e.fp) suds.transport.TransportError: HTTP Error 401: Unauthorized -- System Network Administrator [ LPI NCLA ] http://www.whitemiceconsulting.com OpenGroupware Developer http://www.opengroupware.us Adam Tauno Williams -- http://mail.python.org/mailman/listinfo/python-list
Re: Python recursive tree, linked list thingy
On Mar 7, 3:27 pm, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Mar 7, 2012 at 1:03 PM, Ian Kelly ian.g.ke...@gmail.com wrote: A set of defective pixels would be the probable choice, since it offers efficient membership testing. Some actual code, using a recursive generator: def get_cluster(defective, pixel): yield pixel (row, column) = pixel for adjacent in [(row - 1, column), (row, column - 1), (row, column + 1), (row + 1, column)]: if adjacent in defective: defective.remove(adjacent) for cluster_pixel in get_cluster(defective, adjacent): yield cluster_pixel defective = {(327, 415), (180, 97), (326, 415), (42, 15), (180, 98), (325, 414), (325, 415)} clusters = [] while defective: pixel = defective.pop() clusters.append(list(get_cluster(defective, pixel))) from pprint import pprint pprint(clusters) Cheers, Ian This works for me and I can modify it to look for column defects also. It also shows I know less about Python then I thought I did. I had to read up on generators and iterators to understand the code. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: newb __init__ inheritance
On Thursday, March 8, 2012 4:25:06 PM UTC+1, hyperboogie wrote: My question is if __init__ in the descendant class overrides __init__ in the parent class how can I call the parent's __init__ from the descendant class - I just overrode it didn't I? Am I missing something more fundamental here? No, you're not. However, you can explicitly call the __init__() method of a particular class. Hard-coding the class gives you: class A(object): def __init__(self): print(In A) class B(A): def __init__(self): A.__init__(self) print(In B) Alternatively you can figure out the parent class with a call to super: class C(A): def __init__(self): super(self.__class__, self).__init__() print(In C) a = A() (prints In A) b = B() (prints In A, In B on two lines) c = C() (prints In A, In C on two lines) Hope this helps. Maarten -- http://mail.python.org/mailman/listinfo/python-list
Re: newb __init__ inheritance
Maarten wrote: Alternatively you can figure out the parent class with a call to super: This is WRONG: super(self.__class__, self).__init__() You have to name the current class explicitly. Consider: class A(object): ... def __init__(self): ... print in a ... class B(A): ... def __init__(self): ... print in b ... super(self.__class__, self).__init__() # wrong ... class C(B): pass ... Can you figure out what C() will print? Try it out if you can't. The corrected code: class B(A): ... def __init__(self): ... print in b ... super(B, self).__init__() ... class C(B): pass ... C() in b in a __main__.C object at 0x7fcfafd52b10 In Python 3 you can call super() with no args; super().__init__() do the right thing there. -- http://mail.python.org/mailman/listinfo/python-list
Re: newb __init__ inheritance
hyperboogie wrote: Hello everyone. This is my first post in this group. I started learning python a week ago from the dive into python e- book and thus far all was clear. However today while reading chapter 5 about objects and object orientation I ran into something that confused me. it says here: http://www.diveintopython.net/object_oriented_framework/defining_classes.html#fileinfo.class.example __init__ methods are optional, but when you define one, you must remember to explicitly call the ancestor's __init__ method (if it defines one). This is more generally true: whenever a descendant wants to extend the behavior of the ancestor, the descendant method must explicitly call the ancestor method at the proper time, with the proper arguments. However later on in the chapter: http://www.diveintopython.net/object_oriented_framework/userdict.html it says: Methods are defined solely by their name, and there can be only one method per class with a given name. So if a descendant class has an __init__ method, it always overrides the ancestor __init__ method, even if the descendant defines it with a different argument list. And the same rule applies to any other method. My question is if __init__ in the descendant class overrides __init__ in the parent class how can I call the parent's __init__ from the descendant class - I just overrode it didn't I? Am I missing something more fundamental here? Thanks An excellent question. What you subclass you are creating a new, different class. class A(object): def __init__(self): print(this is class A's __init__) def method1(self, value): print(value) class B(A): def __init__(self): print(this is class B's __init__) test = B() test.method1('42') When it says that the subclass overrides methods of the same name, it means that if it finds the method in the subclass, it will stop looking and use the one it found. So in the example above when Python creates test it will find __init__ in B and so won't bother looking in A for it. However, when looking for 'method1' Python does not find it in B, and so looks in A for it and, finding it there, uses that as B's method1. If you want B's __init__ to also call A's __init__, you have to so explicity: def __init__(self): A.__init__(self) or def __init__(self): super(B, self).__init__() or with Python 3 def __init__(self): super().__init__() ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI components in python
On Wed, 2012-03-07 at 19:14 +0530, janaki rajamani wrote: I am stuck with the brain workshop software implemented using python. The code involves a lot of GUI elements and i am familar only with the basic python programming. I would like to know whether there are built in classes to support GUI elements or arethey project dependant. There are wrappers for various GUI toolkits/technologies such as PyGTK for using Gtk in Python. These wrappers often provide quite a bit of assistance and tools for working with that technology. You need to ask more specifically to get a more useful answer? -- System Network Administrator [ LPI NCLA ] http://www.whitemiceconsulting.com OpenGroupware Developer http://www.opengroupware.us Adam Tauno Williams signature.asc Description: This is a digitally signed message part -- http://mail.python.org/mailman/listinfo/python-list
RE: GUI components in python
I am stuck with the brain workshop software implemented using python. The code involves a lot of GUI elements and i am familar only with the basic python programming. I would like to know whether there are built in classes to support GUI elements or arethey project dependant. There are wrappers for various GUI toolkits/technologies such as PyGTK for using Gtk in Python. These wrappers often provide quite a bit of assistance and tools for working with that technology. You need to ask more specifically to get a more useful answer? The TKinter library ships with Python. So I guess that would be the built-in classes. Usually though the UI is project dependent and there are several frameworks depending on the features you want. This may help list some of the frameworks and help you choose: http://www.awaretek.com/toolkits.html Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Buffering in Wing and IDLE 3
In article mailman.390.1330912210.3037.python-l...@python.org, Ned Deily n...@acm.org wrote: http://www.activestate.com/activetcl/downloads GREAT ! It seems to work. At least, I can now get the ~ char in France from within IDLE. A big step for manking :-) Thanks folks, franck -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
Alright, I'm simply lost about how to install these modules. I extracted the folders from the .tar.gz files and then went into those folders in my command prompt. I typed: C:\Python32\python setup.py install and for a while something was happening (I was doing the lxml one) and then it stopped with an error that it couldn't find a file. So I have no idea. Next I installed the distribute module, which seemed to install okay. But now I don't understand how to use easy_install. Where do I call it from? What do I do with the .tar.gz files at this point? The instructions for lxml say to run this command: easy_install --allow-hosts=lxml.de,*.python.org lxml but WHERE do I run it? I tried it in the Python directory, and then further in the lxml site-packages directory, but it doesn't work. What do I do with it? Where do I put the .tar files? -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Mar 8, 3:33 pm, John Salerno johnj...@gmail.com wrote: Alright, I'm simply lost about how to install these modules. I extracted the folders from the .tar.gz files and then went into those folders in my command prompt. I typed: C:\Python32\python setup.py install and for a while something was happening (I was doing the lxml one) and then it stopped with an error that it couldn't find a file. So I have no idea. Next I installed the distribute module, which seemed to install okay. But now I don't understand how to use easy_install. Where do I call it from? What do I do with the .tar.gz files at this point? The instructions for lxml say to run this command: easy_install --allow-hosts=lxml.de,*.python.org lxml but WHERE do I run it? I tried it in the Python directory, and then further in the lxml site-packages directory, but it doesn't work. What do I do with it? Where do I put the .tar files? Well, after a bit of experimentation, I got it to run, but I seem to have run into the same error as when I used setup.py: http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Now I have no idea what to do. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
In 21519dbf-4097-4780-874d-41d76f645...@x17g2000yqj.googlegroups.com John Salerno johnj...@gmail.com writes: Well, after a bit of experimentation, I got it to run, but I seem to have run into the same error as when I used setup.py: http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Now I have no idea what to do. The first error on that screen is that xslt-config is not found as a command. Try a web search for xslt-config not found, there seemed to be some helpful results. -- 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: What's the best way to write this regular expression?
On Mar 8, 3:40 pm, John Salerno johnj...@gmail.com wrote: Now I have no idea what to do. Hmph, I suppose I should have more patience. I realized that the easy_install for lxml only tried to install a binary version, which doesn't exist for the version it found (the latest, 2.3.3). I just had to look through the previous versions and find the one with a binary installation for Windows (2.3) and it was as simple as a single click to install! And the easy_install method did work for Beautiful Soup, so I should be all set now! -- http://mail.python.org/mailman/listinfo/python-list
Finding MIME type for a data stream
I'm pulling image data from a database blob, and serving it from a web2py app. I have to send the correct Content-Type header, so I need to detect the image type. Everything that I've found on the web so far, needs a file name on the disk, but I only have the data. It looks like the 'magic' package might be of use, but I can't find any documentation for it. Also, it seems like image/png works for other types of image data, while image/foo does not, yet I'm afraid that not every browser will play along as nicely. Thanks! Tobiah -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
On 03/08/2012 04:55 PM, Tobiah wrote: I'm pulling image data from a database blob, and serving it from a web2py app. I have to send the correct Content-Type header, so I need to detect the image type. Everything that I've found on the web so far, needs a file name on the disk, but I only have the data. It looks like the 'magic' package might be of use, but I can't find any documentation for it. Also, it seems like image/png works for other types of image data, while image/foo does not, yet I'm afraid that not every browser will play along as nicely. Thanks! Tobiah First step, ask the authors of the database what format of data this blob is in. Failing that, write the same data locally as a binary file, and see what application can open it. Or if you're on a Linux system, run file on it. file can identify most data formats (not just images) just by looking at the data. That assumes, of course, that there's any consistency in the data coming out of the database. What happens if next time this blob is an Excel spreadsheet? -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On 03/08/2012 04:40 PM, John Salerno wrote: SNIP http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Nothing to do with Python, but you'd save us all a lot of space and bandwidth if you learned how to copy/paste from a Windows cmd window. If you're just doing it rarely, you can right click on the top bar to get a menu. I think you want mark. Then you select the text you'd like to put in the clipboard. Alternatively, you can put the console in quick-edit mode (I think it's called, it's been a long time since I ran Windows). That's an option you set on one cmd window, and it sticks for future windows. In quick-edit, you just right-click-drag on the cmd window to select a rectangle of text. Then you can Ctrl-V to paste it into email, or into a text editor, or wherever else you need it. Hard to imagine not using this mode, or its Linux equivalent, which is always available. If that wasn't clear enough, or it doesn't work for you, somebody will explain it better. Or ask me, and I'll launch a VirtualBox with Windows to get you going. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Decoding unicode is not supported in unusual situation
On 3/7/2012 6:18 PM, Ben Finney wrote: Steven D'Apranosteve+comp.lang.pyt...@pearwood.info writes: On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: I think that's a Python bug. If the latter succeeds as a no-op, the former should also succeed as a no-op. Neither should ever get any errors when ‘s’ is a ‘unicode’ object already. No. The semantics of the unicode function (technically: a type constructor) are well-defined, and there are two distinct behaviours: Right. The real problem is that Python 2.7 doesn't have distinct str and bytes types. type(bytes() returns type 'str' str is assumed to be ASCII 0..127, but that's not enforced. bytes and str should have been distinct types, but that would have broken much old code. If they were distinct, then constructors could distinguish between string type conversion (which requires no encoding information) and byte stream decoding. So it's possible to get junk characters in a str, and they won't convert to Unicode. I've had this happen with databases which were supposed to be ASCII, but occasionally a non-ASCII character would slip through. This is all different in Python 3.x, where str is Unicode and bytes really are a distinct type. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
Thanks, I had no idea about either option, since I don't use the command prompt very much. Needless to say, the Linux console is much nicer :) On Thu, Mar 8, 2012 at 4:19 PM, Dave Angel d...@davea.name wrote: On 03/08/2012 04:40 PM, John Salerno wrote: SNIP http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Nothing to do with Python, but you'd save us all a lot of space and bandwidth if you learned how to copy/paste from a Windows cmd window. If you're just doing it rarely, you can right click on the top bar to get a menu. I think you want mark. Then you select the text you'd like to put in the clipboard. Alternatively, you can put the console in quick-edit mode (I think it's called, it's been a long time since I ran Windows). That's an option you set on one cmd window, and it sticks for future windows. In quick-edit, you just right-click-drag on the cmd window to select a rectangle of text. Then you can Ctrl-V to paste it into email, or into a text editor, or wherever else you need it. Hard to imagine not using this mode, or its Linux equivalent, which is always available. If that wasn't clear enough, or it doesn't work for you, somebody will explain it better. Or ask me, and I'll launch a VirtualBox with Windows to get you going. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
On 03/08/2012 02:11 PM, Dave Angel wrote: On 03/08/2012 04:55 PM, Tobiah wrote: I'm pulling image data from a database blob, and serving it from a web2py app. I have to send the correct Content-Type header, so I need to detect the image type. Everything that I've found on the web so far, needs a file name on the disk, but I only have the data. It looks like the 'magic' package might be of use, but I can't find any documentation for it. Also, it seems like image/png works for other types of image data, while image/foo does not, yet I'm afraid that not every browser will play along as nicely. Thanks! Tobiah First step, ask the authors of the database what format of data this blob is in. Failing that, write the same data locally as a binary file, and see what application can open it. Or if you're on a Linux system, run file on it. file can identify most data formats (not just images) just by looking at the data. That assumes, of course, that there's any consistency in the data coming out of the database. What happens if next time this blob is an Excel spreadsheet? I should simplify my question. Let's say I have a string that contains image data called 'mystring'. I want to do mime_type = some_magic(mystring) and get back 'image/jpg' or 'image/png' or whatever is appropriate for the image data. Thanks! Tobiah -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
Also, I realize that I could write the data to a file and then use one of the modules that want a file path. I would prefer not to do that. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
On 03/08/2012 05:28 PM, Tobiah wrote: snip I should simplify my question. Let's say I have a string that contains image data called 'mystring'. I want to do mime_type = some_magic(mystring) and get back 'image/jpg' or 'image/png' or whatever is appropriate for the image data. Thanks! Tobiah I have to assume you're talking python 2, since in python 3, strings cannot generally contain image data. In python 2, characters are pretty much interchangeable with bytes. Anyway, I don't know any way in the standard lib to distinguish arbitrary image formats. (There very well could be one.) The file program I referred to was an external utility, which you could run with the multiprocessing module. if you're looking for a specific, small list of file formats, you could make yourself a signature list. Most (not all) formats distinguish themselves in the first few bytes. For example, a standard zip file starts with PK for Phil Katz. A Windows exe starts with MZ for Mark Zbikowsky. And I believe a jpeg file starts hex(d8) (ff) (e0) (ff) If you'd like to see a list of available modules, help() is your friend. You can start with help(modules) to see quite a long list. And I was surprised how many image related things already are there. So maybe there's something I don't know about that could help. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
RE: Decoding unicode is not supported in unusual situation
Right. The real problem is that Python 2.7 doesn't have distinct str and bytes types. type(bytes() returns type 'str' str is assumed to be ASCII 0..127, but that's not enforced. bytes and str should have been distinct types, but that would have broken much old code. If they were distinct, then constructors could distinguish between string type conversion (which requires no encoding information) and byte stream decoding. So it's possible to get junk characters in a str, and they won't convert to Unicode. I've had this happen with databases which were supposed to be ASCII, but occasionally a non-ASCII character would slip through. bytes and str are just aliases for each other. id( bytes ) 505366496 id( str ) 505366496 type( bytes ) type 'type' type( str ) type 'type' bytes == str True bytes is str True And I do not think they were ever intended to be just ASCII because chr() takes 0 - 256 (non-inclusive) and returns a str. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- -Original Message- From: python-list-bounces+ramit.prasad=jpmorgan@python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of John Nagle Sent: Thursday, March 08, 2012 4:24 PM To: python-list@python.org Subject: Re: Decoding unicode is not supported in unusual situation On 3/7/2012 6:18 PM, Ben Finney wrote: Steven D'Apranosteve+comp.lang.pyt...@pearwood.info writes: On Thu, 08 Mar 2012 08:48:58 +1100, Ben Finney wrote: I think that's a Python bug. If the latter succeeds as a no-op, the former should also succeed as a no-op. Neither should ever get any errors when ‘s’ is a ‘unicode’ object already. No. The semantics of the unicode function (technically: a type constructor) are well-defined, and there are two distinct behaviours: This is all different in Python 3.x, where str is Unicode and bytes really are a distinct type. John Nagle -- http://mail.python.org/mailman/listinfo/python-list This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't get around HTTP/401 response using SUDS
El 08/03/12 16:44, Adam Tauno Williams escribió: SUDS version 0.4 pn x86_64 Python 2.7 I'm having a bear of a time getting HTTP Basic Authentication to work for a SOAP request via suds. Also using an HTTP proxy server. In WireShark I just see a request - GET http://./services/services/JobService-0.0.1?wsdl HTTP/1.1 Accept-Encoding: identity Host: ... Connection: close User-Agent: Python-urllib/2.7 This doesn't contain any authentication credentials so the response is HTTP/401, and the client doesn't retry with credentials. The response does come from the remote as I can see there is a WWW-Authenticate header and it is from an Apache Tomcat server - so it makes it through the proxy server. Code url = 'http://../services/services/JobService-0.0.1?wsdl' proxy = urllib2.ProxyHandler({'http': 'http://.:3128'}) transport = suds.transport.http.HttpAuthenticated() transport.urlopener = urllib2.build_opener(proxy) client = suds.client.Client(url, transport=transport, username='**', password='') I've tried the above as well as the method described at http://blogs.oucs.ox.ac.uk/inapickle/2011/05/14/exchange-web-services-suds-and-python/ It has the same problem. Back Trace Traceback (most recent call last): File etrace.py, line 30, inmodule client = suds.client.Client(url, transport=transport, username='***', password='*') File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py, line 112, in __init__ self.wsdl = reader.open(url) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/reader.py, line 152, in open d = self.fn(url, self.options) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/wsdl.py, line 136, in __init__ d = reader.open(url) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/reader.py, line 79, in open d = self.download(url) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/reader.py, line 95, in download fp = self.options.transport.open(Request(url)) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/transport/http.py, line 173, in open return HttpTransport.open(self, request) File /usr/local/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/transport/http.py, line 64, in open raise TransportError(str(e), e.code, e.fp) suds.transport.TransportError: HTTP Error 401: Unauthorized When I've got issues like yours, I usually try using a console client (telnet/curl/wget,...) adding all needed headers/data manually so I'm totally sure the request is OK, if everything goes Ok you know your python code need to be reviewed but when you are under proxies you can find a lot of not python related issues (bad gateways, using proxy when it shouldn't or vice-versa, requests changed by proxy,). wireshark can be very useful but in situations like this I usually prefer tcpflow output, I think the request/response flow showed is really useful, but that's a personal preference. HTH, bye -- http://mail.python.org/mailman/listinfo/python-list
RE: What's the best way to write this regular expression?
Alternatively, you can put the console in quick-edit mode (I think it's called, it's been a long time since I ran Windows). That's an option you set on one cmd window, and it sticks for future windows. In quick-edit, you just right-click-drag on the cmd window to select a rectangle of text. Then you can Ctrl-V to paste it into email, or into a text editor, or wherever else you need it. Hard to imagine not using this mode, or its Linux equivalent, which is always available. Actually in quick-edit mode (XP and higher) you just select with left click and then hit enter which copies it to the clipboard. If you also enable insert mode (not sure if this is Win7 specific) you can even right click to paste into the console, just like Linux. Needless to say, the Linux console is much nicer :) True. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On 03/08/2012 06:02 PM, Prasad, Ramit wrote: Actually in quick-edit mode (XP and higher) you just select with left click and then hit enter which copies it to the clipboard. If you also enable insert mode (not sure if this is Win7 specific) you can even right click to paste into the console, just like Linux. Needless to say, the Linux console is much nicer :) True. I was confusing the left-mouse-drag and the right-click. You are correct about both the copying and the pasting, and they do both work from XP onwards. As I said, I haven't used Windows much in quite a while. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
Dave Angel wrote: On 03/08/2012 04:40 PM, John Salerno wrote: SNIP http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Nothing to do with Python, but you'd save us all a lot of space and bandwidth if you learned how to copy/paste from a Windows cmd window. On Windows XP it is: Mouse - Right-click on title bar Left-click on Edit Left-click on Mark Right-click and drag to select desired text enter to copy text to clipboard Keyboard alt-space e k or enter arrows to move cursor, shift-arrows to select text enter to copy text to clipboard ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
I have to assume you're talking python 2, since in python 3, strings cannot generally contain image data. In python 2, characters are pretty much interchangeable with bytes. Yeah, python 2 if you're looking for a specific, small list of file formats, you could make yourself a signature list. Most (not all) formats distinguish themselves in the first few bytes. Yeah, maybe I'll just do that. I'm alowing users to paste images into a rich-text editor, so I'm pretty much looking at .png, .gif, or .jpg. Those should be pretty easy to distinguish by looking at the first few bytes. Pasting images may sound weird, but I'm using a jquery widget called cleditor that takes image data from the clipboard and replaces it with inline base64 data. The html from the editor ends up as an email, and the inline images cause the emails to be tossed in the spam folder for most people. So I'm parsing the emails, storing the image data, and replacing the inline images with an img tag that points to a web2py app that takes arguments that tell it which image to pull from the database. Now that I think of it, I could use php to detect the image type, and store that in the database. Not quite as clean, but that would work. Tobiah -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
On 8-3-2012 23:34, Tobiah wrote: Also, I realize that I could write the data to a file and then use one of the modules that want a file path. I would prefer not to do that. Thanks Use StringIO then, instead of a file on disk Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding MIME type for a data stream
On Thursday, 8 March 2012 23:40:13 UTC, Tobiah wrote: I have to assume you're talking python 2, since in python 3, strings cannot generally contain image data. In python 2, characters are pretty much interchangeable with bytes. Yeah, python 2 if you're looking for a specific, small list of file formats, you could make yourself a signature list. Most (not all) formats distinguish themselves in the first few bytes. Yeah, maybe I'll just do that. I'm alowing users to paste images into a rich-text editor, so I'm pretty much looking at .png, .gif, or .jpg. Those should be pretty easy to distinguish by looking at the first few bytes. Pasting images may sound weird, but I'm using a jquery widget called cleditor that takes image data from the clipboard and replaces it with inline base64 data. The html from the editor ends up as an email, and the inline images cause the emails to be tossed in the spam folder for most people. So I'm parsing the emails, storing the image data, and replacing the inline images with an img tag that points to a web2py app that takes arguments that tell it which image to pull from the database. Now that I think of it, I could use php to detect the image type, and store that in the database. Not quite as clean, but that would work. Tobiah Something like the following might be worth a go: (untested) from PIL import Image img = Image.open(StringIO(blob)) print img.format HTH Jon. PIL: http://www.pythonware.com/library/pil/handbook/image.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
John Salerno johnj...@gmail.com wrote: So much work just to get a 3rd party module installed! New! Try out the beta release of Beautiful Soup 4. (Last updated February 28, 2012) easy_install beautifulsoup4 or pip install beautifulsoup4 or download a tarball. http://www.crummy.com/software/BeautifulSoup/ Worked fine under both Python 2.7 3.2 using pip. -- http://mail.python.org/mailman/listinfo/python-list
Re: What's the best way to write this regular expression?
On Thursday, March 8, 2012 9:38:51 PM UTC-6, alex23 wrote: John Salerno johnj...@gmail.com wrote: So much work just to get a 3rd party module installed! New! Try out the beta release of Beautiful Soup 4. (Last updated February 28, 2012) easy_install beautifulsoup4 or pip install beautifulsoup4 or download a tarball. http://www.crummy.com/software/BeautifulSoup/ Worked fine under both Python 2.7 3.2 using pip. Yeah, but first I had to figure out how to install easy_install :) -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI components in python
Hi Janaki, Python will mostly use either the pygtk library or pyqt library for any rich and production quality GUI. So you must try figuring out if either of these 2 libraries are used. Other than this, there is tkinter which i guess comes with Python as default. Happy hacking. Krishnakant. On 07/03/12 19:14, janaki rajamani wrote: Hi I am stuck with the brain workshop software implemented using python. The code involves a lot of GUI elements and i am familar only with the basic python programming. I would like to know whether there are built in classes to support GUI elements or arethey project dependant. -- http://mail.python.org/mailman/listinfo/python-list
how to get plots made faster
The following is the part of my code which is running faster locally and more slowly remotely via ssh on the same machine. Note I am trying to generate a multi-page report. ## create plots and write to a pdf file from scipy import * import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages # open a multi-page pdf file pp = PdfPages('history_plot.pdf') F=loadtxt('hist.dat',comments='%') t=F[:,0] E=F[:,13] plt.plot(t,E) h1=plt.ylabel('Energy', fontsize=16) h1=plt.xlabel('Time', fontsize=16) pp.savefig() plt.clf() VdotB=F[:,14] plt.plot(t,VdotB) pp.savefig() pp.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get plots made faster
On 09/03/2012 04:40, amar Singh wrote: The following is the part of my code which is running faster locally and more slowly remotely via ssh on the same machine. Note I am trying to generate a multi-page report. ## create plots and write to a pdf file from scipy import * import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages # open a multi-page pdf file pp = PdfPages('history_plot.pdf') F=loadtxt('hist.dat',comments='%') t=F[:,0] E=F[:,13] plt.plot(t,E) h1=plt.ylabel('Energy', fontsize=16) h1=plt.xlabel('Time', fontsize=16) pp.savefig() plt.clf() VdotB=F[:,14] plt.plot(t,VdotB) pp.savefig() pp.close() I can't help directly but you may be better off asking on the matplotlib users mailing list see https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI components in python
On 03/07/2012 06:44 AM, janaki rajamani wrote: Hi I am stuck with the brain workshop software implemented using python. The code involves a lot of GUI elements and i am familar only with the basic python programming. I would like to know whether there are built in classes to support GUI elements or arethey project dependant. brain workshop appears to use the pyglet library: http://www.pyglet.org/ -- http://mail.python.org/mailman/listinfo/python-list
[issue14228] SIGINT (Ctrl-C) not caught at startup
New submission from telmich nico-bugs.python@schottelius.org: Hello, pressing ctrl-c or having sigint delivered to the python process in its startup phase results in random tracebacks displayed. This is related to issue3137, but actually happening in Python 3.2.2 on archlinux. We noticed this during development of the cdist project (http://www.nico.schottelius.org/software/cdist/), where we call a shell via subprocess.check_call() which calls us again (under a different name and thus different behaviour. So the call chain is like this: cdist = /bin/sh -e script = cdist_as_different_name (i.e. __file) A simple test case to reproduce the problem needs the two files caller.py and shellpart.sh in a directory: % ln -s caller.py __testpython % chmod a+x * % ./caller.py Indirect child being called Indirect child being called Indirect child being called Indirect child being called ^Ccaught signint in parent Traceback (most recent call last): File /usr/lib/python3.2/site.py, line 58, in module import traceback File /usr/lib/python3.2/traceback.py, line 3, in module import linecache File /usr/lib/python3.2/linecache.py, line 10, in module import tokenize File /usr/lib/python3.2/tokenize.py, line 28, in module import re File /usr/lib/python3.2/re.py, line 121, in module [10:02] brief:python-traceback-test% import functools File /usr/lib/python3.2/functools.py, line 2, in module KeyboardInterrupt Pressing Ctrl-C results in various different tracebacks and I don't see any way to catch the SIGINT reliably currently, as the code executed seems to be *before* my code is being executed. There is another related bug at debian that references the same problem: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652926 -- files: shellpart.sh messages: 155152 nosy: telmich priority: normal severity: normal status: open title: SIGINT (Ctrl-C) not caught at startup type: crash versions: Python 3.2 Added file: http://bugs.python.org/file24755/shellpart.sh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14228] SIGINT (Ctrl-C) not caught at startup
telmich nico-bugs.python@schottelius.org added the comment: And here's the actual python code -- Added file: http://bugs.python.org/file24756/caller.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Éric Araujo mer...@netwok.org added the comment: For devguide/documenting, If you show me markup, also show me what output it gives me. Would this really be useful? If you’re looking at that page, you want to know what markup to use for what situation; why do you care about output? I want to see how it looks like. It's kinda tedious to keep building the markup just to verify how it's rendered. I’m not sure I understand; if there were example output in the doc, you’d only have to build the devguide once to see how markup is rendered, wouldn’t you? Yes you didn't understand, sorry for my inadequate explanation. I want to see how the output of the markup looks like, without having to do the rendering (running sphinx-build) myself. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14216] ImportError: No module named binascii
Ramchandra Apte maniandra...@gmail.com added the comment: See http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1chap=3. What it says might be the cause of the problem. -- nosy: +ramchandra.apte ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14216 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14217] text output pretends to be code
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Éric Araujo mer...@netwok.org added the comment: Use this: .. code-block:: none output etc. Thanks much. I've attached a patch. -- Added file: http://bugs.python.org/file24757/tis-not-code-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14217 ___diff -r b8be6ac4395d Doc/tutorial/classes.rst --- a/Doc/tutorial/classes.rst Wed Mar 07 08:55:52 2012 +0100 +++ b/Doc/tutorial/classes.rst Thu Mar 08 12:03:20 2012 +0200 @@ -180,7 +180,9 @@ scope_test() print(In global scope:, spam) -The output of the example code is:: +The output of the example code is: + +.. code-block:: none After local assignment: test spam After nonlocal assignment: nonlocal spam ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14191] argparse: nargs='*' doesn't get out-of-order positional parameters
Steven Bethard steven.beth...@gmail.com added the comment: Hence, I conclude that, unless this was spelled out in the PEP and I missed it, that having such boundaries is a bug Practically speaking, we just can't change this because it will break existing argparse scripts. Argparse has had this behavior since 2006 when it was first released, and I guarantee you that many scripts expect and rely on this behavior. As I said earlier, the only reasonable solution is to document the current behavior more explicitly, and then add a new constructor parameter or method or something to enable the behavior you want. I looked a bit a guilherme's patch, and I think it's not really the right direction. We definitely shouldn't be modifying the action classes like _StoreAction. All changes should be within _parse_known_args. The parsing algorithm is so different for the proposed behavior, that I wonder if it wouldn't be easier to just create a new ArgumentParser subclass, ArgumentParserAllowingOptionalsInsidePositionals (or whatever), that just overrides _parse_known_args and rewrites it entirely. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14227] console w/ cp65001 displays extra characters for non-ascii strings.
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +haypo, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14217] text output pretends to be code
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti stage: - patch review type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14217 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14227] console w/ cp65001 displays extra characters for non-ascii strings.
STINNER Victor victor.stin...@gmail.com added the comment: See the issue #1602. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14227 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 6c218b9c5c4c by Jason R. Coombs in branch '2.7': Extracted Windows directory detection from NullImporter.__init__. This greatly simplifies the code and fixes issue6727. http://hg.python.org/cpython/rev/6c218b9c5c4c New changeset 92f4d4eebed1 by Jason R. Coombs in branch '2.7': Adding regression test for issue6727 http://hg.python.org/cpython/rev/92f4d4eebed1 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Changes by Jason R. Coombs jar...@jaraco.com: -- hgrepos: -104 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Jason R. Coombs jar...@jaraco.com added the comment: I've gone ahead and pushed the changesets for Python 2.7. I'll continue to hold off on Python 3.2/3.3 until I can review. Perhaps Brian and I can review these changes at PyCon. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Florent Xicluna florent.xicl...@gmail.com added the comment: It breaks the compilation on few buildbots. Python/import.c:130:14: error: #if with no expression -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Jason R. Coombs jar...@jaraco.com added the comment: I see that. Thanks. I'm on it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6333] logging: ValueError: I/O operation on closed file
Pekka Klärck pekka.kla...@gmail.com added the comment: The same problem that caused problems to py.test caused problems also to Robot Framework: http://code.google.com/p/robotframework/issues/detail?id=1079 I was surprised to notice this issue was closed as invalid although the problem didn't occur with Python 2.7 anymore. After a little more digging I noticed that the proposed fix has actually been done in r84282 as part of fixing issue 9051. The fix doesn't check for `closed` attribute but instead silences possible ValueError. We also noticed a variation of the problem: If the registered handler ever tries to write anything to its stream you also get an exception. We decided to silence all these errors with this code: import logging logging.raiseExceptions = False Finally, I consider it a separate bug that logging.StreamHandler uses sys.stderr by default. It should use sys.__stderr__ instead. -- nosy: +pekka.klarck ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6333 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9408] curses: Link against libncursesw instead of libncurses
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9408 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14228] SIGINT (Ctrl-C) not caught at startup
Antoine Pitrou pit...@free.fr added the comment: Try to enclose the whole code (including the imports) in the try...except block. I'm not sure why this matters, though. If you want Python to have a different return code when terminated by a KeyboardInterrupt, then I agree it is a valid feature request. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Éric Araujo mer...@netwok.org added the comment: I don’t understand why you don’t want to build the doc if you want to see what the output looks like. You should build the doc anyway before making a patch to make sure there are no errors, and it does not take that long. As I don’t understand your problem, I disagree to making the doc longer for this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6333] logging: ValueError: I/O operation on closed file
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: Re. the fix to #9501, the swallowing of exceptions was done for specific reasons noted in the comments in the exception clause which does the swallowing. This only happens during application shutdown - not all ValueErrors on flush() or close() are swallowed. In general, swallowing these will mask logic errors which close a stream prematurely. If you pass a stream to a logging.StreamHandler, make sure you remove the handler from any loggers you attached it to, then close it. Otherwise (if you just close the underlying stream) the StreamHandler might still try to use it, leading to the error. Unattaching the handler and closing it tells logging you're done with writing to that stream, so subsequent logging calls won't try to write to that stream. I'm not aware that every file-like object (including duck-typed ones) will have a 'closed' attribute, so checking for that may not help. If you want to set sys.stderr to a StringIO() and then create a StreamHandler from it, that's fine. The sequence should be: set sys.stderr to StringIO instance create a StreamHandler with sys.stderr add that handler to a logger when finished, remove that handler from a logger close the handler (StreamHandler does not close the underlying stream) restore sys.stderr close the StringIO instance access the contents of the StringIO instance using getvalue() If things are not done in that order, it's possible for arbitrary code (e.g. in a 3rd-party library) to log an event, because of which logging then tries to write to the stream. If that stream is closed, you get the ValueError - that's a warning that something isn't being done correctly, and the answer is not to just swallow that exception. Re. your proposed fix - it may be fine in your specific scenario, but I wouldn't recommend it in general because it may mask logic errors in a program. Regarding your preference for sys.__stderr__ rather than sys.stderr, that's all it is - a preference. You can easily pass the exact stream that you want to StreamHandler, including sys.__stderr__, so the fact that it picks sys.stderr by default shouldn't bother you - just be explicit. Of course, that default - whatever the rights and wrongs of it - cannot be changed without breaking existing code, so it has to stay that way. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6333 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Jason R. Coombs jar...@jaraco.com added the comment: The Unix tests are now passing again. Some Windows buildbots are failing because they do not have the symlink privilege. I'll add a guard in the test to not run it if it doesn't have privilege to symlink. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14144] urllib2 HTTPRedirectHandler not forwarding POST data in redirect
Senthil Kumaran sent...@uthcode.com added the comment: I am closing this issue as I feel that the requirement may not be addressed by a change. If there is patch for HowTo, we can tackle that in another issue. Thank you for contribution. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6727] ImportError when package is symlinked on Windows
Brian Curtin br...@python.org added the comment: The @support.skip_unless_symlink decorator could be helpful there. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6727 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14228] SIGINT (Ctrl-C) not caught at startup
telmich nico-bugs.python@schottelius.org added the comment: This does not change a thing: Indirect child being called ^CTraceback (most recent call last): File /usr/lib/python3.2/functools.py, line 176, in wrapper caught signint in parent result = cache[key] KeyError: (class 'str', '[ \\f\\t]*((\\r?\\n|#[^\\r\\n]*|([bB]?[rR]?\'\'\'|[bB]?[rR]?))|(([0-9]+[jJ]|(([0-9]+\\.[0-9]*|\\.[0-9]+)([eE][-+]?[0-9]+)?|[0-9]+[eE][-+]?[0-9]+)[jJ])|(([0-9]+\\.[0-9]*|\\.[0-9]+)([eE][-+]?[0-9]+)?|[0-9]+[eE][-+]?[0-9]+)|(0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+|(?:0+|[1-9][0-9]*)))|((\\*\\*=?|=?|=?|!=|//=?|-|[+\\-*/%|^=]=?|~)|[][(){}]|(\\r?\\n|\\.\\.\\.|[:;.,@]))|([bB]?[rR]?\'[^\\n\']*(?:.[^\\n\']*)*(\'|\\r?\\n)|[bB]?[rR]?[^\\n]*(?:.[^\\n]*)*(|\\r?\\n))|\\w+)', 32) During handling of the above exception, another exception occurred: Traceback (most recent call last): File /usr/lib/python3.2/site.py, line 58, in module import traceback File /usr/lib/python3.2/traceback.py, line 3, in module import linecache File /usr/lib/python3.2/linecache.py, line 10, in module import tokenize File /usr/lib/python3.2/tokenize.py, line 118, in module [19:02] brief:python-traceback-test% _compile, (Token, PseudoToken, Single3, Double3)) File /usr/lib/python3.2/tokenize.py, line 115, in _compile return re.compile(expr, re.UNICODE) File /usr/lib/python3.2/re.py, line 206, in compile return _compile(pattern, flags) File /usr/lib/python3.2/re.py, line 255, in _compile return _compile_typed(type(pattern), pattern, flags) File /usr/lib/python3.2/functools.py, line 180, in wrapper result = user_function(*args, **kwds) File /usr/lib/python3.2/re.py, line 267, in _compile_typed return sre_compile.compile(pattern, flags) File /usr/lib/python3.2/sre_compile.py, line 495, in compile code = _code(p, flags) File /usr/lib/python3.2/sre_compile.py, line 480, in _code _compile(code, p.data, flags) File /usr/lib/python3.2/sre_compile.py, line 101, in _compile _compile(code, av[1], flags) File /usr/lib/python3.2/sre_compile.py, line 142, in _compile _compile(code, av, flags) File /usr/lib/python3.2/sre_compile.py, line 101, in _compile _compile(code, av[1], flags) File /usr/lib/python3.2/sre_compile.py, line 142, in _compile _compile(code, av, flags) File /usr/lib/python3.2/sre_compile.py, line 101, in _compile _compile(code, av[1], flags) File /usr/lib/python3.2/sre_compile.py, line 142, in _compile _compile(code, av, flags) File /usr/lib/python3.2/sre_compile.py, line 57, in _compile _compile_charset(av, flags, code, fixup) File /usr/lib/python3.2/sre_compile.py, line 183, in _compile_charset for op, av in _optimize_charset(charset, fixup): File /usr/lib/python3.2/sre_compile.py, line 253, in _optimize_charset data = _mk_bitmap(charmap) File /usr/lib/python3.2/sre_compile.py, line 270, in _mk_bitmap if m MAXCODE: KeyboardInterrupt [19:03] brief:python-trace -- Added file: http://bugs.python.org/file24758/caller.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14228] SIGINT (Ctrl-C) not caught at startup
telmich nico-bugs.python@schottelius.org added the comment: Regarding feature request: I think this is a *bug*, not a feature request: For me, it is impossible to handle SIGINT correctly with my code, because it is half-handled (exception raised, but impossible to catch) by python itself. Imho this behaviour should not be possible. Instead python could do the standard sigint behaviour, before reading python code (= exit). When starting to read python shipped code (i.e. stuff that comes with python and is always loaded), it should either implement a handler for sigint OR have sigint signal handler set to ignore. As soon as control flow is passed over to user code, raising KeyboardInterrupt is fine and I can catch that by enclosing all parts (including import statements) into a try: ... block that does what I want. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14191] argparse: nargs='*' doesn't get out-of-order positional parameters
Glenn Linderman v+pyt...@g.nevcal.com added the comment: Ah yes, argparse had a life outside the stdlib, so now I understand your compatibility concerns. Mind you, I think the overall technology of argparse is superior to optparse, which is why, together with the optparse deprecation, I am trying to port to use it... so consider me a fan, not an enemy. But... However, it seems that while the esoteric extensions required in optparse were a known incompatibility at the time the PEP was written, the incompatibility with intermixed positional and optional parameters slipped under the radar... but is actually a more serious compatibility problem for general use. I see three possible ways forward, maybe there are others. 1) un-deprecate optparse, explaining and documenting this functional difference between optparse and argparse. The deprecation of optparse is what makes this missing capability a bug, rather than a feature enhancement. 2) add features to argparse to make it capable of parsing all the same command lines as unextended optparse. (I'm of the opinion that folks that extended optparse can learn to extend argparse in similar or more capable manners; not having such extensions, I'm not qualified to state whether there are optparse extensions that cannot be ported to use standard or extended argparse capabilities.) The documentation for such features should clearly state that former users of argparse may be interested in using this feature, and should state why; further, the deprecation notice in optparse should be updated to point out that porting to argparse may need to use this particular argparse capability to achieve command line compatibility with optparse, and that the capability is not available until (specified release). 3) If there is an already existing way (my t14.py is a half-hearted attempt to find it) to parse scattered positional parameters, it could be explicitly documented rather than writing new capabilities per #2. However, since you as author jumped to the new capabilities option straightway, I suspect this is not really a possibility. The rest of this is concerned option #2, which seems the best way forward to me, with my current knowledge. You mention ArgumentParserAllowingOptionalsInsidePositionals and that is extremely lengthy, might I suggest something like ArgumentParserIntermixed ? What would be the scope of the effort, and what release(s) might be a possible target? (since it is a bug, it can be backported, but since the cure will be implemented as a new capability, that might be problematical for point releases, somehow? I'm not the expert in that area.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14228] SIGINT (Ctrl-C) not caught at startup
Antoine Pitrou pit...@free.fr added the comment: Regarding feature request: I think this is a *bug*, not a feature request: For me, it is impossible to handle SIGINT correctly with my code, because it is half-handled (exception raised, but impossible to catch) by python itself. In the trace you just posted, I see caught signint in parent (at the beginning), so the exception was indeed caught. When starting to read python shipped code (i.e. stuff that comes with python and is always loaded), it should either implement a handler for sigint OR have sigint signal handler set to ignore. Well, it does implement a SIGINT handler, and that handler raises KeyboardInterrupt. QED. You can override that behaviour and register your own handler using the standard signal module. http://docs.python.org/dev/library/signal.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14229] On KeyboardInterrupt, the exit code should mirror the signal number
New submission from Antoine Pitrou pit...@free.fr: Compare: $ ./python -c import subprocess, signal, time; p = subprocess.Popen(['cat']); time.sleep(1); p.send_signal(signal.SIGINT); print(p.wait()) -2 with: $ ./python -c import subprocess, signal, time; p = subprocess.Popen(['python', '-c', 'input()']); time.sleep(1); p.send_signal(signal.SIGINT); print(p.wait()) Traceback (most recent call last): File string, line 1, in module KeyboardInterrupt 1 Python's behaviour apparently breaks a common assumption towards Unix processes (see bug reported at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652926). A solution would be to add a signal number attribute to KeyboardInterrupt, and use that value when computing the process exit code. -- components: Interpreter Core messages: 155174 nosy: loewis, neologix, pitrou priority: normal severity: normal status: open title: On KeyboardInterrupt, the exit code should mirror the signal number type: enhancement versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14229 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14228] SIGINT (Ctrl-C) not caught at startup
Antoine Pitrou pit...@free.fr added the comment: Opened issue14229 for the signal number as exit code enhancement as mentioned on the Debian issue tracker. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Okay, let me try again: I want the documentation tutorial to tell me, for example, (1) here is the markup for a code block, and (2) here is what it looks like. At the moment, I only get (1)... point is I do not want to have to rebuild a reST file each time I want to see what some specific markup (e.g. a code block) would look like. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14229] On KeyboardInterrupt, the exit code should mirror the signal number
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- nosy: +nadeem.vawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14229 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Éric Araujo mer...@netwok.org added the comment: I don’t get why you want to know what it looks like, and then, I don’t get why you can’t build the doc or look at docs.python.org. Also, not getting what you talk about re-building: building the devguide or docs once should be enough. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14220] yield from kills generator on re-entry
Changes by Benjamin Peterson benja...@python.org: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14220 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Éric Araujo mer...@netwok.org added the comment: It looks like I have a hard time putting myself in your shoes and seeing what you want, so I’m going to shut up for a while and let Ezio and Sandro state their opinion on your original request. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Sandro Tosi sandro.t...@gmail.com added the comment: eheh yeah it seems so :) What I think Tshepang wants is this: - the devguide contains the description of how to document python - that documentation is about a set of ReST coding commands that generate the desired output - currently the devguide reports only the ReST code block without, right below to that block, the resulting highlitening. - add the resulting visual output right below the description of the code to use. so something like blablabla you have to use ``word`` to have the word in bold (or whatever it generates, I'm too lazy to check :) ) for example: insert here the visual output of a ReST doc where ``word`` is used Tshepang: did I get it correctly? Éric: is it (at least a bit) clearer? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14218] include rendered output in addition to markup
Tshepang Lekhonkhobe tshep...@gmail.com added the comment: Sandro Tosi sandro.t...@gmail.com added the comment: Tshepang: did I get it correctly? Éric: is it (at least a bit) clearer? that's exactly what I tried to convey -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6333] logging: ValueError: I/O operation on closed file
Pekka Klärck pekka.kla...@gmail.com added the comment: @vinay.sajip the problem is that many tools that don't do anything with logging module intercept sys.stdout and sys.stderr. Such tools typically aren't even aware of libraries they use (or test) using logging and much less about them registering StreamHandler using sys.stderr. It's great that nowadays you don't always get ValueError at exit anymore. Now you only get them if the StreamHandler itself tries to use the stream after sys.stderr is restored and the intercepting stream closed. Typically this only happens in error situations so the problem isn't so severe. IMHO nobody should ever register StreamHandler with sys.stderr because you cannot be sure has someone intercepted it or not. There's a strong convention that sys.__stderr__ should not be intercepted so using it is safe. I strongly believe StreamHandler should be changed to use sys.__stderr__ by default. That shouldn't cause problems because a) if sys.stderr isn't intercepted sys.stderr is sys.__stderr__, and b) if sys.stderr is intercepted you most likely already have problems. I know stuff like this cannot be changed other than in major releases and there should perhaps even be a deprecation period. I also acknowledge that it might be too much work to be worth the effort. Mentioning this issue in the docs might be a good idea nevertheless. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6333 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14230] Delegating generator is not always visible to debugging tools such as inspect pdb
New submission from Mark Shannon m...@hotpy.org: Delegating generators do not show always up in stack traces, such as inspect.stack(). The show up during the first delegation, but not thereafter. I have attached a patch. It alters the way the YIELD_FROM bytecode works; it loops back on itself. This ensures the delegator's frame is always in the trace. Unfortunately I started working on it before Benjamin fixed issue 14220 (rev 3357eac1ba62). By the nature of it, this patch necessarily fixes most of issue 14220, so I have just included the tests for issue 14220 in this patch as well. So in order to apply this, 3357eac1ba62 will have to be backed out. Sorry for the overlap. -- components: Interpreter Core files: yieldfrom.patch keywords: patch messages: 155182 nosy: Mark.Shannon priority: normal severity: normal status: open title: Delegating generator is not always visible to debugging tools such as inspect pdb type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file24759/yieldfrom.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14230 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14220] yield from kills generator on re-entry
Mark Shannon m...@hotpy.org added the comment: I've just added issue 14230 which overlaps with this issue somewhat. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14220 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13842] Cannot pickle Ellipsis or NotImplemented
Changes by Łukasz Langa luk...@langa.pl: -- assignee: - lukasz.langa nosy: +lukasz.langa ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13842 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1692335] Fix exception pickling: Move initial args assignment to BaseException.__new__
Changes by Łukasz Langa luk...@langa.pl: -- assignee: - lukasz.langa nosy: +lukasz.langa ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1692335 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8754] quote bad module name in ImportError-like messages
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8754 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6333] logging: ValueError: I/O operation on closed file
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: IMHO nobody should ever register StreamHandler with sys.stderr because you cannot be sure has someone intercepted it or not. There's a strong convention that sys.__stderr__ should not be intercepted so using it is safe. Actually, I believe it is reasonable to intercept sys.stderr, even with logging in use, because you might be testing that logging actually works in a common scenario (use of StreamHandler in the default configuration). To do that, you would need to capture sys.stderr and check that its contents contain logged messages. For example, the Python test suite contains specific tests which intercept (and restore) sys.stderr, for this very purpose. If one is careful to follow the sequence of events I mentioned in my last response, it should be safe to intercept sys.stderr. You only have to remember that if you have passed it to logging to use for I/O, logging may try to use it at times you don't expect (e.g. because of logging by third-party code). Just remove it from logging before you close it, and all will be well. This, of course, applies to any stream you pass to logging - not just sys.stderr or a replacement for it like a StringIO. Using sys.__stderr__ is of course doable right now by your code; as you are the first one to mention this as desirable, I think it quite likely that people are working with the existing default without any problems. So it's unlikely that this default will change (as it doesn't need to - you can be explicit about the stream you want to use). If there is a lot of adverse feedback about the default (unlikely, since it's been there ever since logging was added to Python - about 10 years ago) then I will of course reconsider. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6333 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14191] argparse: nargs='*' doesn't get out-of-order positional parameters
Steven Bethard steven.beth...@gmail.com added the comment: Thinking about it a bit more, it strikes me that maybe you could get the behavior you want by declaring two parsers, one with just optionals, and one with just positionals. Then: optional_args, remaining_args = optionals.parse_known_args() args = positionals.parse_args(remaining_args) vars(args).update(vars(optional_args)) Basically, you first parse out all the optional arguments, then you parse out the positional arguments from what's left after the optional arguments are stripped out. This approach seems to work for your t14.py. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14199] Keep a refence to mro in _PyType_Lookup() and super_getattro()
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 21e245ed3747 by Victor Stinner in branch 'default': Close #14199: _PyType_Lookup() and super_getattro() keep a strong reference to http://hg.python.org/cpython/rev/21e245ed3747 -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14199 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14191] argparse: nargs='*' doesn't get out-of-order positional parameters
Steven Bethard steven.beth...@gmail.com added the comment: Actually, that could be even simpler: args, remaining_args = optionals.parse_known_args() args = positionals.parse_args(remaining_args, args) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14211] Don't rely on borrowed _PyType_Lookup() reference in PyObject_GenericSetAttr()
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 579f845ac396 by Victor Stinner in branch 'default': Issue #14211: _PyObject_GenericSetAttrWithDict() keeps a strong reference to http://hg.python.org/cpython/rev/579f845ac396 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14211] Don't rely on borrowed _PyType_Lookup() reference in PyObject_GenericSetAttr()
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 2cc44cd8098e by Victor Stinner in branch 'default': Issue #14211: Oops, I removed the wrong file :-) http://hg.python.org/cpython/rev/2cc44cd8098e -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14231] Fix or drop Lib/test/crashers/borrowed_ref_1.py
New submission from STINNER Victor victor.stin...@gmail.com: Lib/test/crashers/borrowed_ref_1.py contains the docstring: _PyType_Lookup() returns a borrowed reference. This attacks the call in dictobject.c. The file was added by Armin in 2006 by the changeset 4dd1a9383e47. I just fixed #14211 which was a similar bug (Lib/test/crashers/borrowed_ref_2.py), but I'm unable to reproduce this one. Extract of dict_subscript(): missing = _PyObject_LookupSpecial((PyObject *)mp, PyId___missing__); if (missing != NULL) { res = PyObject_CallFunctionObjArgs(missing, key, NULL); Py_DECREF(missing); return res; } I fail to see how missing can be destroyed before being used. Is it a problem that missing is destroyed while we are calling it? How can I trigger the crash in gdb? -- components: Interpreter Core messages: 155190 nosy: arigo, haypo priority: normal severity: normal status: open title: Fix or drop Lib/test/crashers/borrowed_ref_1.py type: crash versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14231 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14211] Don't rely on borrowed _PyType_Lookup() reference in PyObject_GenericSetAttr()
Changes by STINNER Victor victor.stin...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14211 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14231] Fix or drop Lib/test/crashers/borrowed_ref_1.py
Armin Rigo ar...@users.sourceforge.net added the comment: Crashes for me on Python 2.5 and 2.6, but no longer on Python 2.7. The problem may have been fixed in the meantime. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14231 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14232] obmalloc: mmap() returns MAP_FAILED on error, not 0
New submission from STINNER Victor victor.stin...@gmail.com: Python fails to catch memory allocation error in its memory allocator when mmap() is used. Attached patch fixes the issue. -- components: Interpreter Core files: obmalloc_map_failed.patch keywords: patch messages: 155192 nosy: haypo, neologix, pitrou priority: normal severity: normal status: open title: obmalloc: mmap() returns MAP_FAILED on error, not 0 versions: Python 2.7, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file24760/obmalloc_map_failed.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14232 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14231] Fix or drop Lib/test/crashers/borrowed_ref_1.py
STINNER Victor victor.stin...@gmail.com added the comment: Oh, it looks like the following commit fixed the issue without touching to the crasher test: ba6376dff6c4. Armin, Benjamin: can you confirm? -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14231 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14205] Raise an error if a dict is modified during a lookup
STINNER Victor victor.stin...@gmail.com added the comment: Guido: So, what do you think? Do you like the new behaviour, or would you prefer a softer solution like retrying N times? Python 3.3 retries the lookup an unlimited number of times which lead to a crash, that's the issue fixed by my change. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14205 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14233] argparse: append action fails to override default values
New submission from guilherme-pg guilherme.p.g...@gmail.com: Trying to set a default value to arguments whose action is append causes argparse to raise AttributeError when such arguments are provided in the command line (see attached test case t1.py). This happens because _AppendAction doesn't expect the presence of a default value for the argument: when the command line is parsed and the argument is found, _AppendAction attempts to append the new value to the list of old values, if any, or the old list. In case there is already a non-list default value, it attempts to append the new value to it, which raises the exception. Is this intended behavior? If so, shouldn't ArgumentError be raised instead? It should also be easy to fix this issue otherwise, making _StoreAction ensure the old values are stored in a list before appending. -- components: Library (Lib) files: t1.py messages: 155195 nosy: bethard, guilherme-pg priority: normal severity: normal status: open title: argparse: append action fails to override default values type: crash versions: Python 3.3 Added file: http://bugs.python.org/file24761/t1.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14233 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14205] Raise an error if a dict is modified during a lookup
Guido van Rossum gu...@python.org added the comment: I'm still torn. Can you implement the counter without adding an extra field to the dict object? I worry that we'll get the same objection we had when MAL proposed collision counting as a solution to the hash DoS attack. The numbers 0, 1 and infinity are special; all others are to be treated with skepticism. I'm prepared to make the current semantic change a 3.3 feature, but I'm not sure it's safe to backport. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14205 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14205] Raise an error if a dict is modified during a lookup
STINNER Victor victor.stin...@gmail.com added the comment: Can you implement the counter without adding an extra field to the dict object? Add a counter requires to change the prototype of the C lookup function: PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, Py_hash_t hash); I don't know if it is a problem for ABI compatibility or extension modules. I suppose that it is safer and simpler to not change it :-) I worry that we'll get the same objection we had when MAL proposed collision counting as a solution to the hash DoS attack. The numbers 0, 1 and infinity are special; all others are to be treated with skepticism. Is it really useful to only retry once? Retrying once means that it would work in most cases, but not in some corner cases. For example, retrying once may hide the problem if you have only 1 client (1 thread), but you get the exception when you have more clients (more threads). Or do I misunderstand the problem? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14205 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com