Re: Proper place for everything
On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: In article 509441cb$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a strange question, but I might as well start somewhere. Thank you for your honesty, but trolling is not welcome. However if you have actual issues about Python, either pro or con, and hope to have a serious, respectful dialog where both parties listen to each other, feel free to raise them here. Keep in mind three things: [snip three things] You forgot the fourth point. Apparently so did you :) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
On Wednesday, September 5, 2012 10:41:19 PM UTC+8, Steven D'Aprano wrote: On Wed, 05 Sep 2012 10:00:09 -0400, Dave Angel wrote: On 09/05/2012 09:19 AM, Franck Ditter wrote: Thanks to all, but : - I should have said that I work with Python 3. Does that matter ? - May I reformulate the queston : a is b and id(a) == id(b) both mean : a et b share the same physical address. Is that True ? Thanks, No, id() has nothing to do with physical address. The Python language does not specify anything about physical addresses. Some implementations may happen to use physical addresses, others arbitrary integers. And they may reuse such integers, or not. Up to the implementation. True. In principle, some day there might be a version of Python that runs on some exotic quantum computer where the very concept of physical address is meaningless. Or some sort of peptide or DNA computer, where the calculations are performed via molecular interactions rather than by flipping bits in fixed memory locations. But less exotically, Frank isn't entirely wrong. With current day computers, it is reasonable to say that any object has exactly one physical location at any time. In Jython, objects can move around; in CPython, they can't. But at any moment, any object has a specific location, and no other object can have that same location. Two objects cannot both be at the same memory address at the same time. So, for current day computers at least, it is reasonable to say that a is b implies that a and b are the same object at a single location. The second half of the question is more complex: id(a) == id(b) *only* implies that a and b are the same object at the same location if they exist at the same time. If they don't exist at the same time, then you can't conclude anything. -- Steven The function id(x) might not be implemented as an address in the user space. Do we need to distinguish archived objets and objects in the memory? -- http://mail.python.org/mailman/listinfo/python-list
Re: is implemented with id ?
On 4/11/12 06:09:24, Aahz wrote: In article mailman.3250.1351999198.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Sun, Nov 4, 2012 at 2:10 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: /* Shortcut for empty or interned objects */ if (v == u) { Py_DECREF(u); Py_DECREF(v); return 0; } result = unicode_compare(u, v); where v and u are pointers to the unicode object. There's a shortcut if they're the same. There's no shortcut if they're both interned and have different pointers, which is a guarantee that they're distinct strings. They'll still be compared char-for-char until there's a difference. Without looking at the code, I'm pretty sure there's a hash check first. In 3.3, there is no such check. It was recently proposed on python-dev to add such a check, but AFAIK, no action was taken. -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
/ ru...@yahoo.com wrote on Fri 2.Nov'12 at 11:39:10 -0700 / (I also hope I haven't just been suckered by a troll attempt, windows/unix is better then unix/windows being an age-old means of trolling.) No, i'm not a troll. I was just adding my opinion to the thread, I assumed that was allowed. I didn't say UNIX is better than Windows, did I; I just feel that Windows is not -- for me anyway -- the most suitable plaform for learning about the science of computing and coding, etc... being a computer science student that's the view i have and share with those I learn with and from. Why must people be accused of trolling everytime they make a statement that conveys a preference over one platform or language, for example, than the other. Provoking someone by labeling them a troll or implying they might be is a bit childish really. -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
In article 5096202c$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: In article 509441cb$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a strange question, but I might as well start somewhere. Thank you for your honesty, but trolling is not welcome. However if you have actual issues about Python, either pro or con, and hope to have a serious, respectful dialog where both parties listen to each other, feel free to raise them here. Keep in mind three things: [snip three things] You forgot the fourth point. Apparently so did you :) Amongst the points are such diverse elements as... -- http://mail.python.org/mailman/listinfo/python-list
surprising += for lists
Hi everybody! I was just smacked by some very surprising Python 2.7 behaviour. I was assembling some 2D points into a list: points = [] points += (3, 5) points += (4, 6) What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, 5, 4, 6]. My interpretations thereof is that the tuple (x, y) is iterable, so the elements are appended one after the other. Actually, I should have used points.append(), but that's a different issue. Now, what really struck me was the fact that [] + (3, 5) will give me a type error. Here I wonder why the augmented assignment behaves so much different. Can anyone help me understand this? Thanks! Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: surprising += for lists
Quick aside, you can insert tuples without much effort: `points += ((3,5),)` And also that I can't do the reverse, i.e.: foo = tuple() foo += [5,6] Traceback (most recent call last): File stdin, line 1, in module TypeError: can only concatenate tuple (not list) to tuple On Sun, Nov 4, 2012 at 10:57 PM, Ulrich Eckhardt dooms...@knuut.de wrote: Hi everybody! I was just smacked by some very surprising Python 2.7 behaviour. I was assembling some 2D points into a list: points = [] points += (3, 5) points += (4, 6) What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, 5, 4, 6]. My interpretations thereof is that the tuple (x, y) is iterable, so the elements are appended one after the other. Actually, I should have used points.append(), but that's a different issue. Now, what really struck me was the fact that [] + (3, 5) will give me a type error. Here I wonder why the augmented assignment behaves so much different. Can anyone help me understand this? Thanks! Uli -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: who can give me some practical tutorials on django 1.4 or 1.5?
On Sun, 2012-11-04 at 13:29 +0800, Levi Nie wrote: Who can give me some practical tutorials on django 1.4 or 1.5? Thank you. Is the official[1] tutorial not practical enough? [1] https://docs.djangoproject.com/en/1.4/intro/tutorial01/ -- http://mail.python.org/mailman/listinfo/python-list
Re: surprising += for lists
On 11/04/2012 06:57 AM, Ulrich Eckhardt wrote: Hi everybody! I was just smacked by some very surprising Python 2.7 behaviour. I was assembling some 2D points into a list: points = [] points += (3, 5) points += (4, 6) What I would have expected is to have [(3, 5), (4, 6)], instead I got [3, 5, 4, 6]. mylist += is equivalent to mylist.extend. And as you say, what you wanted was append. My interpretations thereof is that the tuple (x, y) is iterable, You're confusing cause and effect. If it weren't iterable, it'd be an error. It would NOT just somehow change to be equivalent to append. points.extend(4) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'int' object is not iterable so the elements are appended one after the other. Actually, I should have used points.append(), but that's a different issue. Now, what really struck me was the fact that [] + (3, 5) will give me a type error. Here I wonder why the augmented assignment behaves so much different. What I wonder about is why list's __add__ is so fussy. Can anyone help me understand this? Thanks! Uli I'd also point out that when using the extend() function call, we'd have to spell it: points.extend((3,5)) The extra parentheses are to make it clear to the compiler that this is a single argument, a tuple, and not two arguments. And similarly, points.append((3,5)) to get your original desired behavior. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
__unicode__() works, unicode() blows up.
Environment: Python-2.7.3 Ubuntu Precise mongoengine 0.6.20 I have a class which includes a __unicode__() method: class User(mongoengine.Document): def __unicode__(self): return self.username If I create an instance of this class by calling the constructor directly, self.username is None. When I pass that to unicode(), it blows up. However, calling __unicode__() directly, works as expected: u = User() print u.username None print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. Why is it, that no matter how long you stare at a problem, the answer comes to you moments after you hit the Post button? :-) The problem is that __unicode__() is supposed to return a Unicode object, and unicode() enforces that. The fix is to change: def __unicode__(self): return self.username to be: def __unicode__(self): return unicode(self.username) This never got noticed before because normally, self.username already is a unicode string, so it just works. -- http://mail.python.org/mailman/listinfo/python-list
Missing modules compiling python3.3
I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel _dbm _gdbm _lzma _sqlite3 _tkinter readline To find the necessary bits, look in setup.py in detect_modules() for the module's name. And also the test_urlwithfrag test fails, but when trying to do(as suggested in the README) ./python -m test -v test_urlwithfrag I get an error[ImportError: No module named 'test.test_urlwithfrag' ] and when doing ./python -m test -v test_urllib2net it skips the test saying it's normal on linux(then why make test runs it and it fails???) What am I missing? Should I install those modules manually? Is this expected? -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing modules compiling python3.3
Am 04.11.2012 15:42, schrieb Giacomo Alzetta: I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel _dbm _gdbm _lzma _sqlite3 _tkinter readline To find the necessary bits, look in setup.py in detect_modules() for the module's name. Hello Giacomo, your installation is lacking a couple of dependencies and header files. It's very easy to install the dependencies on Ubuntu: sudo apt-get build-dep python3.2 sudo apt-get install liblzma-dev HTH Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing modules compiling python3.3
Giacomo Alzetta wrote: I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel You haven't installed the development headers for those modules giving errors. So for curses you'll need to install libncurses5-dev, lzma-dev etc. Sorry, I can't remember the package names as it's a while since I did this. Andy -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up.
On 4 November 2012 13:32, Roy Smith r...@panix.com wrote: Environment: Python-2.7.3 Ubuntu Precise mongoengine 0.6.20 I have a class which includes a __unicode__() method: class User(mongoengine.Document): def __unicode__(self): return self.username If I create an instance of this class by calling the constructor directly, self.username is None. When I pass that to unicode(), it blows up. However, calling __unicode__() directly, works as expected: u = User() print u.username None print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. class Foo: ... def __unicode__(self): return Bar # NOT Unicode ... Foo().__unicode__() 'Bar' unicode(Foo()) u'Bar' unicode(x) calls x.__unicode__() *and then* coerces the result to Unicode. None cannot be coerced to Unicode. -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
In article roy-30ba92.08410804112...@news.panix.com, Roy Smith r...@panix.com wrote: In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. Why is it, that no matter how long you stare at a problem, the answer comes to you moments after you hit the Post button? :-) The problem is that __unicode__() is supposed to return a Unicode object, and unicode() enforces that. The fix is to change: def __unicode__(self): return self.username to be: def __unicode__(self): return unicode(self.username) This never got noticed before because normally, self.username already is a unicode string, so it just works. You apparently need more coffee when programming after waking up! (Or even worse, staying up all night.) -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Normal is what cuts off your sixth finger and your tail... --Siobhan -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On 04-Nov-2012 12:13, Jamie Paul Griffin wrote: / ru...@yahoo.com wrote on Fri 2.Nov'12 at 11:39:10 -0700 / (I also hope I haven't just been suckered by a troll attempt, windows/unix is better then unix/windows being an age-old means of trolling.) No, i'm not a troll. I was just adding my opinion to the thread, I assumed that was allowed. I didn't say UNIX is better than Windows, did I; I just feel that Windows is not -- for me anyway -- the most suitable plaform for learning about the science of computing and coding, etc... being a computer science student that's the view i have and share with those I learn with and from. Why must people be accused of trolling everytime they make a statement that conveys a preference over one platform or language, for example, than the other. Provoking someone by labeling them a troll or implying they might be is a bit childish really. Well stated Jamie --- I agree. I don't believe that all members of this list label you as a troll. --V -- http://mail.python.org/mailman/listinfo/python-list
Re: surprising += for lists
On 11/4/2012 7:45 AM, Dave Angel wrote: What I wonder about is why list's __add__ is so fussy. Guido's reason is that it is not clear what the types of [1,2] + (3,4), (1,2) + [3,4], [] + range(4), range(2) + [3,4], etcetera should be. Such mixtures may be bugs. Seq.__add__ exists to implement '+'. [].extend() will clearly be a list, and accepts any iterable. I believe the same logic is used for set operations. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: __unicode__() works, unicode() blows up. (Never mind!)
On 11/4/2012 8:41 AM, Roy Smith wrote: In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on here? I thought (http://docs.python.org/2/library/functions.html#unicode) the latter two calls should be identical, but obviously they're not. Why is it, that no matter how long you stare at a problem, the answer comes to you moments after you hit the Post button? :-) The problem is that __unicode__() is supposed to return a Unicode object, and unicode() enforces that. The fix is to change: def __unicode__(self): return self.username to be: def __unicode__(self): return unicode(self.username) This never got noticed before because normally, self.username already is a unicode string, so it just works. The same principle applies to some of the other special methods that sit behind builtin functions. class C: def __len__(self): return '42' # whoops len(C()) Traceback (most recent call last): File pyshell#9, line 1, in module len(C()) TypeError: 'str' object cannot be interpreted as an integer class C: def __len__(self): return -42 # whoops again len(C()) Traceback (most recent call last): File pyshell#12, line 1, in module len(C()) ValueError: __len__() should return = 0 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: who can give me some practical tutorials on django 1.4 or 1.5?
On 11/4/2012 7:35 AM, Albert Hopkins wrote: On Sun, 2012-11-04 at 13:29 +0800, Levi Nie wrote: Who can give me some practical tutorials on django 1.4 or 1.5? Thank you. Is the official[1] tutorial not practical enough? [1] https://docs.djangoproject.com/en/1.4/intro/tutorial01/ There is also django-users list https://www.djangoproject.com/community/ -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Proper place for everything
everyone on this list is troll On Sun, Nov 4, 2012 at 6:17 AM, Roy Smith r...@panix.com wrote: In article 5096202c$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 03 Nov 2012 22:19:19 -0700, Aahz wrote: In article 509441cb$0$29967$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 02 Nov 2012 04:20:20 -0700, Jason Benjamin wrote: Anybody know of the appropriate place to troll and flame about various Python related issues? I'm kind of mad about some Python stuff and I need a place to vent where people may or may not listen, but at at least respond. Thought this would be a strange question, but I might as well start somewhere. Thank you for your honesty, but trolling is not welcome. However if you have actual issues about Python, either pro or con, and hope to have a serious, respectful dialog where both parties listen to each other, feel free to raise them here. Keep in mind three things: [snip three things] You forgot the fourth point. Apparently so did you :) Amongst the points are such diverse elements as... -- http://mail.python.org/mailman/listinfo/python-list -- Cheers, Jeff Jeffries III CEO: www.willyoubemyfriend.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On 01/11/2012 09:55, Jamie Paul Griffin wrote: / Robert Miles wrote on Wed 31.Oct'12 at 0:39:02 -0500 / For those of you running Linux: You may want to look into whether NoCeM is compatible with your newsreader and your version of Linux. It checks newsgroups news.lists.filters and alt.nocem.misc for lists of spam posts, and will automatically hide them for you. Not available for other operating systems, though, except possibly Unix. Anybody serious about programming should be using a form of UNIX/Linux if you ask me. It's inconceivable that these systems should be avoided if you're serious about Software Engineering and Computer Science, etc. For UNIX there are loads of decent news reading software and mail user agents to learn and use. slrn is a good one and point it at gmane.org as someone else pointed out. I can't even imagine using a browser or Google Groups, etc. now. Anybody serious about programming should know that an OS is a combination of the hardware and software. Can the *Nix variants now do proper clustering or are they still decades behind VMS? Never used the other main/mini frame systems myself but perhaps they are still vastly superior to this highly overrated *Nix crap. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Sun, Nov 4, 2012 at 11:39 AM, Mark Lawrence breamore...@yahoo.co.ukwrote: Anybody serious about programming should know that an OS is a combination of the hardware and software. Can the *Nix variants now do proper clustering or are they still decades behind VMS? Never used the other main/mini frame systems myself but perhaps they are still vastly superior to this highly overrated *Nix crap. What relevance does clustering have for a desktop workstation OS? -- http://mail.python.org/mailman/listinfo/python-list
Re: install pyOpenSSL in python2.7
On 2012-11-03, at 2:58 AM, 水静流深 wrote: i have install pyOpenSSL-0.11 in python2.7 this way: download pyOpenSSL-0.11.tar.gz #tar -zvxf pyOpenSSL-0.11.tar.gz #cd pyOpenSSL-0.11 #python setup.py install import OpenSSL Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py, line 45, in module from OpenSSL import rand, SSL ImportError: /usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.so: undefined symbol: SSLv2_method how can i fix the problem? ImportError: /usr/local/lib/python2.7/dist-packages/OpenSSL/SSL.so: undefined symbol: SSLv2_method -- http://mail.python.org/mailman/listinfo/python-list The pyOpenSSL home page at https://launchpad.net/pyopenssl says that the latest version is 0.11, but that is not true. The latest version is 0.13. You can get it on PyPI here http://pypi.python.org/pypi/pyOpenSSL SSLv2 is no longer supported in OpenSSL, and version 0.13 no longer expects it. - John -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing modules compiling python3.3
Il giorno domenica 4 novembre 2012 15:56:03 UTC+1, mm0fmf ha scritto: Giacomo Alzetta wrote: I'm trying to compile python3.3 on my (K)ubuntu 12.04, but some modules are missing. In particular when doing make test I get: Python build finished, but the necessary bits to build these modules were not found: _bz2 _curses_curses_panel You haven't installed the development headers for those modules giving errors. So for curses you'll need to install libncurses5-dev, lzma-dev etc. Sorry, I can't remember the package names as it's a while since I did this. Andy That's right! Sorry, but I thought I installed those some months ago for an other python installation, but probably I've also removed them :s The test_urlwithfrag is still failing though. -- http://mail.python.org/mailman/listinfo/python-list
PDFBuilder can now take multiple input files from command line
Here is the blog post about it: http://jugad2.blogspot.in/2012/11/pdfbuilder-can-now-take-multiple-input.html In short: removed the temporary hard-coding, refactored the code some. PDFBuilder can now use multiple input files (of type .csv / .tdv), specified on the command-line, to create a composite PDF from those inputs. .tdv = Tab Delimited Values, such as commonly used in UNIX tools like sed / grep / awk and friends. - Vasudev Ram www.dancingbison.com -- http://mail.python.org/mailman/listinfo/python-list
Re: No more Python support in NetBeans 7.0
On Thursday, March 24, 2011 10:32:44 AM UTC-4, Kees Bakker wrote: Hi, Sad news (for me, at least), in the upcoming version 7.0 of NetBeans there will be no Python plugin anymore. I have been using NetBeans for Python development for a while now and I was very happy with it. See this archive for details: http://netbeans.org/projects/www/lists/nbpython-dev/archive/2010-11/message/0 http://netbeans.org/projects/www/lists/nbpython-dev/archive/2011-01/message/0 -- Kees It is sad indeed. I would have preferred to use netbeans for all my coding and now I have to use both netbeans and a python IDE. I have been using PyCharm for a year now and I am very happy with it. It is the best I have used for python development with django, html, javascript and css support as well. I recommend trying it out. However I am not happy about having to use different IDEs as I find myself coding in both python and php from project to project. Jetbrains IDEA Ultimate edition has both php and python support but is way out of my budget. -- http://mail.python.org/mailman/listinfo/python-list
Web application for drawing directed graphs from the output of Python's cProfile
I recently built startgraphi.com. It's a web application that draws directed graphs of running times and function calls from the output of Python's cProfile. It also creates a sortable table of running times and function calls. I hope someone finds it useful. -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Nov 4, 4:14 pm, Jamie Paul Griffin ja...@kode5.net wrote: / ru...@yahoo.com wrote on Fri 2.Nov'12 at 11:39:10 -0700 / (I also hope I haven't just been suckered by a troll attempt, windows/unix is better then unix/windows being an age-old means of trolling.) No, i'm not a troll. I was just adding my opinion to the thread, I assumed that was allowed. I didn't say UNIX is better than Windows, did I; I just feel that Windows is not -- for me anyway -- the most suitable plaform for learning about the science of computing and coding, etc... being a computer science student that's the view i have and share with those I learn with and from. Why must people be accused of trolling everytime they make a statement that conveys a preference over one platform or language, for example, than the other. Provoking someone by labeling them a troll or implying they might be is a bit childish really. Hi Jamie Among people who know me, I am a linux nerd: My sister scolded me yesterday because I put files on her computer without spaces: DoesAnyoneWriteLikeThis?!?! Your post reminds me: As someone who has taught CS for 25 years, Ive not only been party to his Unix-fanboy viewpoint but have even actively fostered it. Over time Ive come to have some pangs of conscience about this. Evidently this kind of attitude has helped no one: not my students, not the corporations they join, not the society at large. So now, on my blog I maintain a record of the foibles of CS academics. http://blog.languager.org/2011/02/cs-education-is-fat-and-weak-1.html is a history of CS as it is normally given. http://blog.languager.org/2011/02/cs-education-is-fat-and-weak-2.html is the above deconstructed with stupidities of academic CS factored in. -- http://mail.python.org/mailman/listinfo/python-list
Multi-dimensional list initialization
So, here I was thinking oh, this is a nice, easy way to initialize a 4D matrix (running 2.7.3, non-core libs not allowed): m = [[None] * 4] * 4 The way to get what I was after was: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] (Obviously, I could have just hardcoded the initialization, but I'm too lazy to type all that out ;)) The behaviour I encountered seems a little contradictory to me. [None] * 4 creates four distinct elements in a single array while [[None] * 4] * 4 creates one distinct array of four distinct elements, with three references to it: a = [None] * 4 a[0] = 'a' a ['a', None, None, None] m = [[None] * 4] * 4 m[0][0] = 'm' m [['m', None, None, None], ['m', None, None, None], ['m', None, None, None], ['m', None, None, None]] Is this expected behaviour and if so, why? In my mind either result makes sense, but the inconsistency is what throws me off. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list
Re: No more Python support in NetBeans 7.0
On 2012-11-04, at 4:45 PM, bkube...@gmail.com wrote: However I am not happy about having to use different IDEs as I find myself coding in both python and php from project to project. One of the many reasons Vim is my editor of choice. Demian Brecht @demianbrecht http://demianbrecht.github.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Mon, Nov 5, 2012 at 5:10 PM, rusi rustompm...@gmail.com wrote: Among people who know me, I am a linux nerd: My sister scolded me yesterday because I put files on her computer without spaces: DoesAnyoneWriteLikeThis?!?! My filenames seldom have spaces in them, but that has nothing to do with how I write English. Names are names. They're not essays, they are not written as full sentences. When a name contains spaces, it must be delimited (or the space must be escaped, if your environment permits) any time it occurs inside some other context - most commonly, as a command-line argument. Back when I was using MS-DOS 5, it was possible to have file names with spaces. It wasn't easy to manipulate them from the command line, but you could reference them using globs (eg replace the space(s) with ? and hope that there are no false hits). OS/2, when working on a FAT filesystem, would create files called EA DATA. SF or WP ROOT. SF or WP SHARE. SF (two spaces in each), and most DOS/Windows programs wouldn't (couldn't) touch them - they were safe repositories for system metadata (on smarter filesystems, that sort of thing would be stored as file attributes, not as separate files). It's nothing to do with operating system. File names are names, and spaces in them are seldom worth the hassle unless you manipulate those files solely using a GUI. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On 11/04/2012 10:27 PM, Demian Brecht wrote: So, here I was thinking oh, this is a nice, easy way to initialize a 4D matrix (running 2.7.3, non-core libs not allowed): m = [[None] * 4] * 4 The way to get what I was after was: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] FYI: The behavior is the same in python 3.2 m=[[None]*4]*4 produces a nested list with all references being to the first instance of the inner list construction. I agree, the result is very counter-intuitive; hmmm... but I think you meant: m = [[None] * 4, [None] * 4, [None] * 4, [None] *4 ] rather than: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] ? :) ? I asked a why question on another thread, and watched several dodges to the main question; I'll be watching to see if you get anything other than That's the way it's defined in the API. IMHO -- that's not a real answer. My guess is that the original implementation never considered anything beyond a 1d list. :) A more precise related question might be: is there a way to force the replication operator to use copying rather than referencing? :/ -- http://mail.python.org/mailman/listinfo/python-list
python destructor
Hello there folks, I have a bit of a special issue. I'll start by disclosing myself for what i am doing. I am a postgraduate student and I really have good reasons to do what I am doing. At least i think so. And not the issue. I am building a python web service. This web service has some generic objects and I use a metaclass to customize the classes. Second I use a non-conventional object oriented database, dybase (http://www.garret.ru/dybase/doc/dybase.html#introduction) Now these is a OODBMS claiming to support ACID transactions. The instances of my objects are recursively organizing themselves into a hierarchical tree-like structure. When I make an instance of this object persistent dybase actually can recursively save all tree structure. Everything works well here. I altered the main class situated at the root of my class hierarchy to actually store inside the__dict__ not the instances of its children but their unique ID's. Then when I set a child attribute I create it and instead of being stored in the instance the child goes to a database index object. Thus it becomes Universally addressable. The a parent retrieves the child it actually fetches it from the database. In this way I ended up with very small objects.However these objects can regenerate the treelike structure as if they were storing there children in the __dict__. The issue is how to give the instances access to the database and properly handle the opening and closing of the database. It seems futile to me to actually open/close the connection through a context. Because the database is a file it will issue an IO operation on every attribute access and we all know __getattribute__ is used extremely often. For this reason I thought the best way would be to wrap the dybase Storage (main class) into a local storage version which would have __del__ method. The local Storage is a new style class..it opens the DB file but the __del__ is never called. This is because the Storage class has at least 2 cyclic references. So my Storage class never closes the database. I would like this class to close the database when it is garbage collected. The class is a Singleton FYI as well but this might not be relevant or even necessary. So my question is: what s the best way to force __del__ on a singleton that has cyclic references. Should i use weakref and alter the original source? Is there a way i can force a singleton to garbage collect itself?. I am by no means a software engineer so i would appreciate any advice from some experts on the matter. Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On Sun, Nov 4, 2012 at 10:27 PM, Demian Brecht demianbre...@gmail.com wrote: So, here I was thinking oh, this is a nice, easy way to initialize a 4D matrix (running 2.7.3, non-core libs not allowed): m = [[None] * 4] * 4 The way to get what I was after was: m = [[None] * 4, [None] * 4, [None] * 4, [None * 4]] (Obviously, I could have just hardcoded the initialization, but I'm too lazy to type all that out ;)) The behaviour I encountered seems a little contradictory to me. [None] * 4 creates four distinct elements in a single array while [[None] * 4] * 4 creates one distinct array of four distinct elements, with three references to it: Incorrect. In /both/ cases, the result is a list of length 4, whose elements are 4 (references to) the exact same object as the original list's element. Put simply, the list multiplication operator never copies objects; it just makes additional references to them. However, unlike a list object (as in your latter example), the object `None` is completely immutable (and what's more, a singleton value), so you just-so-happen *not to be able to* run into the same problem of mutating an object (assignment to an index of a list constitutes mutation of that list) that is referenced in multiple places, for you cannot mutate None in the first place!: x = None x.a = 42 Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'NoneType' object has no attribute 'a' # it doesn't overload any mutating operators: type(None).__dict__.keys() ['__hash__', '__repr__', '__doc__'] # and it obviously has no instance variables, # so, we can't modify it in any way whatsoever! (Lists, on the other hand, define item assignment, .pop(), .remove(), and a few other mutator methods.) a = [None] * 4 a[0] = 'a' a ['a', None, None, None] m = [[None] * 4] * 4 m[0][0] = 'm' m [['m', None, None, None], ['m', None, None, None], ['m', None, None, None], ['m', None, None, None]] Is this expected behavior Yes. It's also a FAQ: http://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list and if so, why? It's a general (albeit AFAIK unstated) principle that Python never copies objects unless you explicitly ask it to. You have encountered one example of this rule in action. In my mind either result makes sense, but the inconsistency is what throws me off. It is perfectly consistent, once you understand what list multiplication actually does. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebert c...@rebertia.com wrote: x = None x.a = 42 Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'NoneType' object has no attribute 'a' Python needs a YouGottaBeKiddingMeError for times when you do something utterly insane like this. Attributes of None??!? :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] sys.py3k
On Mon, Nov 5, 2012 at 9:33 AM, Steven D'Aprano st...@pearwood.info wrote: On 05/11/12 08:49, anatoly techtonik wrote: if sys.py3k: # some py2k specific code pass # Bring back reload in Python 3. try: reload except NameError: from imp import reload try: any except NameError: # Python 2.4 compatibility. def any(items): for item in items: if item: return True return False Take the best of both worlds: try: # py3k reload except NameError: from imp import reload Now you can grep your code for py3k without changing the language! Never underestimate the value of comment tokens. Universal ones like TODO or private ones like NULLSAFE, all it takes is grep or your editor's Find function to make them all obvious. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: No more Python support in NetBeans 7.0
On Mon, Nov 5, 2012 at 5:29 PM, Demian Brecht demianbre...@gmail.com wrote: On 2012-11-04, at 4:45 PM, bkube...@gmail.com wrote: However I am not happy about having to use different IDEs as I find myself coding in both python and php from project to project. One of the many reasons Vim is my editor of choice. Same here. My IDE needs are very simple. Give me an editor that lets me manipulate multiple files at once, can one-key invoke make, and preferably has syntax highlighting, and I'm happy. So for me, SciTE is my editor and IDE. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On Nov 5, 11:40 am, Chris Angelico ros...@gmail.com wrote: On Mon, Nov 5, 2012 at 5:10 PM, rusi rustompm...@gmail.com wrote: Among people who know me, I am a linux nerd: My sister scolded me yesterday because I put files on her computer without spaces: DoesAnyoneWriteLikeThis?!?! My filenames seldom have spaces in them, but that has nothing to do with how I write English. Names are names. They're not essays, they are not written as full sentences. When a name contains spaces, it must be delimited (or the space must be escaped, if your environment permits) any time it occurs inside some other context - most commonly, as a command-line argument. Back when I was using MS-DOS 5, it was possible to have file names with spaces. It wasn't easy to manipulate them from the command line, but you could reference them using globs (eg replace the space(s) with ? and hope that there are no false hits). OS/2, when working on a FAT filesystem, would create files called EA DATA. SF or WP ROOT. SF or WP SHARE. SF (two spaces in each), and most DOS/Windows programs wouldn't (couldn't) touch them - they were safe repositories for system metadata (on smarter filesystems, that sort of thing would be stored as file attributes, not as separate files). It's nothing to do with operating system. File names are names, and spaces in them are seldom worth the hassle unless you manipulate those files solely using a GUI. ChrisA So you and I (and probably many on this list) agree! -- http://mail.python.org/mailman/listinfo/python-list
Re: Applying a paid third party ssl certificate
ehsmenggro...@gmail.com writes: I haven't quite figured out how to apply a paid ssl cert, say RapidSSL free SSL test from Python's recent sponsor sslmatrix.com and what to do with that to make Python happy. This good fellow suggests using the PEM format. I tried and failed. http://www.minnmyatsoe.com/category/python-2/ The self signed cert recepies found all work swell, but some browsers (webkit) gets very upset indeed. I want to use ajax requests from clients (e.g autocompletion, stats collection etc) and put that in a python program without hogging down the main apache stack, but without a proper ssl cert this doesn't work. Does anyone have any ideas what to do? From your description, I derive that you want your client (python program) to autenticate itself via an SSL certificate. If my assumption is correct, I would start with a look at the Python documentation for HTTPS connections. When I remember right, they have 2 optional parameters to specify a client certificate and to specify trusted certificates (when server presented certificates should be verified). Once, you have determined how to present the client certificate for the base HTTPS connection, you may need to look at the documentation or source code of higher level apis (such as urllib2) to learn how to pass on your certificate down to the real connection. You may also have a look at PyPI. You may find there packages facilitating Python's SSL support. -- http://mail.python.org/mailman/listinfo/python-list
Re: Multi-dimensional list initialization
On 11/04/2012 11:27 PM, Chris Angelico wrote: On Mon, Nov 5, 2012 at 6:07 PM, Chris Rebertc...@rebertia.com wrote: x = None x.a = 42 Traceback (most recent call last): File stdin, line 1, inmodule AttributeError: 'NoneType' object has no attribute 'a' Python needs a YouGottaBeKiddingMeError for times when you do something utterly insane like this. Attributes of None??!? :) ChrisA Hmmm? Everything in Python is an object. Therefore! SURE. None *does* have attributes! ( even if not useful ones... ) eg: None.__getattribute__( __doc__ ) doesn't produce an error. In C, in Linux, at the end of the file errno.h, where all error codes are listed eg:( EIO, EAGAIN, EBUSY, E) They had a final error like the one you dreamed up, it was called EIEIO; and the comment read something like, All the way around Elmer's barn. :) The poster just hit that strange wall -- *all* built in types are injection proof; and that property is both good and bad... -- http://mail.python.org/mailman/listinfo/python-list
[issue13349] Non-informative error message in index() and remove() functions
Sean Ochoa added the comment: After discussing with folks on the #python-dev tonight, I learned that I was testing with a list and I should've been using a set. I'm working on a patch now, and I'm almost ready to have it reviewed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13349 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5288] tzinfo objects with sub-minute offsets are not supported (e.g. UTC+05:53:28)
Fergus Noble added the comment: GPS time doesn't include leap seconds so I think datetime is a good representation. If datetime doesn't know about leap seconds then there would still be some issues with finding the timedelta between a GPS time and a UTC time straddling a leap second but I guess a similar issue also exists with two UTC times. For my application all the times I am dealing with are in a short period and will have the same UTC offset so its a little easier, I can probably avoid most of these issues. However, wouldn't it be possible to implement the general case with a non-constant utcoffset function (and new fromutc implementation) in the tzinfo class? Of course there is no way to properly handle UTC times more than 6 months or so in the future... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5288 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11842] slice.indices with negative step and default stop
Mark Dickinson added the comment: Agreed. Closing. -- resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11842 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12634] Random Remarks in class documentation
Changes by Yongzhi Pan fossi...@users.sourceforge.net: -- nosy: +fossilet ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12634 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11383] compilation seg faults on insanely large expressions
Nick Coghlan added the comment: I've started looking into what would be needed to fix this. The basic problem is that the compilation process involves many recursive operations, but doesn't contain *any* calls to the recursion control functions (http://docs.python.org/3/c-api/exceptions.html#recursion-control). Files to be investigated: Python/ast.c Python/symtable.c Python/compile.c Suspicion should fall immediately on any functions in these files which end with _stmt and _expr. The reason as that these are the self-recursive constructs in the Python grammar: statements can contain other statements (via the compound statements with their nested suites) and expressions can contain other expressions. The symtable analysis also recurses through the block stack via the analyze_block function, making that another candidate for flagging with the recursive call functions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11383 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11383] compilation seg faults on insanely large expressions
Nick Coghlan added the comment: One caveat on this idea: it may not be possible to use the standard recursion limiting functions here, since the Python level recursion limit is generally set quite low (1000 by default on my Fedora system). While this crash *is* a design flaw in our compiler implementation, whatever enforced limit we choose, we run the risk of breaking currently working applications. Thus, adjusting the target versions to 3.4. The problem still *affects* all versions since 2.5, I'm just indicating that any fix is almost certainly going to be too intrusive to risk in a maintenance release. -- versions: +Python 3.4 -Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11383 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16392] import crashes on circular imports in ext modules
Stefan Behnel added the comment: The problem is a) that the module does not necessarily know to which place it eventually gets installed (Cython relies on the distutils Extension not lying to it, for example, which people do from time to time), and b) that the call to Py_InitModule() only receives the plain module name, not the package path. And yes, as mentioned in the other issue, passing a pointer to a context description struct into the module init function would have been the right thing to change for Py3 and still is the right thing to change for Py4. BTW, I can confirm that registering the module in sys.modules explicitly right after creation works around this issue. Given that Cython needs to know the FQMN at compile time anyway, this works for us. It still leaves the problem open for other extension code. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11383] compilation seg faults on insanely large expressions
Serhiy Storchaka added the comment: Isn't it a duplicate of issue5765? -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11383 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11383] compilation seg faults on insanely large expressions
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - duplicate superseder: - stack overflow evaluating eval(() * 3) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11383 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Nick Coghlan added the comment: We want to minimise the risk of breaking working code. Making it easy to adjust this recursion limit separately from the main recursion limit by using a scaling factor is a good way to do that. It shouldn't increase the maintenance burden in any significant way, since the ratio of the stack depth increase in the compiler vs the main interpreter loop should be relatively constant across platforms. Autogenerated code could easily hit the 1000 term limit - if anything, I'd be inclined to set it *higher* than 4 rather than lower, as breaking previously working code in a maintenance release is a bad thing, regardless of our opinion of the sanity of that code. -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains
Daniel Urban added the comment: I've attached a patch addressing the comments on Rietveld. I've added another modification: inspect.signature uses inspect.unwrap. (It already tried to unwrap the function, but it wasn't protected from infinite recursion. I don't know if this worth fixing in 3.3.) -- Added file: http://bugs.python.org/file27876/inspect_unwrap_3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13266 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Serhiy Storchaka added the comment: I don't understand what you mean---can you elaborate? The Python implementation of this method only 40 lines length, including blank lines, docstring and comments. The C implementation requires over 160 lines and less clear. Are there ways to use in Python interpreter core Python implementation for method of builtin class slice. As already used C implementations for some Python-implemented classes. May be add the file _builtins.py where Python version of some cumbersome methods will be implemented? Then execute the followed code on interpreter initialization: from _builtins import slice_indices slice.indices = slice_indices del slice_indices (or an analog in C). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16400] update default PyPI behavior in docs re: listing versions
New submission from Chris Jerdonek: There is a mismatch between what PyPI and the docs say regarding listing versions of packages on PyPI. The current docs say, By default PyPI will list all versions of a given package. (from http://docs.python.org/3.4/distutils/packageindex.html ) However, PyPI says (and behaves) the opposite way, By default, each new release will hide all other release from the regular display. (from the releases management page of a project) -- assignee: eric.araujo components: Distutils, Documentation keywords: easy messages: 174769 nosy: chris.jerdonek, eric.araujo, loewis, tarek priority: normal severity: normal status: open title: update default PyPI behavior in docs re: listing versions type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16400 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Serhiy Storchaka added the comment: The patch looks good to me. Now benchmarks and special casing for Py_ssize_t values needed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Mark Dickinson added the comment: Now benchmarks and special casing for Py_ssize_t values needed. I thought about that, but I don't think it's worth it. I did some quick timings, and as expected the new version of slice.indices is somewhat slower than the original. But I think adding a special case for Py_ssize_t values would be premature optimization. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16389] re._compiled_typed's lru_cache causes significant degradation of the mako_v2 bench
Serhiy Storchaka added the comment: Here is a patch which reverts 3.1 implementation (and adds some optimization). Microbenchmark: $ ./python -m timeit -s import re re._compile('', 0) Results: 3.1: 1.45 usec per loop 3.2: 4.45 usec per loop 3.3: 9.91 usec per loop 3.4patched: 0.89 usec per loop -- keywords: +patch Added file: http://bugs.python.org/file27877/re_compile_cache.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16389 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16401] mention PKG-INFO in the documentation
New submission from Chris Jerdonek: Currently, the documentation makes no mention of the PKG-INFO file. It would be useful if the documentation mentioned what this file is and how it is created (e.g. via the sdist command), and also linked to PEP 314. This can be covered somewhere in the distutils documentation: http://docs.python.org/3.4/distutils/index.html Index entries should also be created as appropriate. -- assignee: eric.araujo components: Distutils, Documentation messages: 174773 nosy: chris.jerdonek, eric.araujo, ezio.melotti, georg.brandl, tarek priority: normal severity: normal status: open title: mention PKG-INFO in the documentation type: enhancement versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16401 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Serhiy Storchaka added the comment: Look at compute_slice_indices() in Objects/rangeobject.c. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16401] mention PKG-INFO in the documentation
Chris Jerdonek added the comment: PEP 345 can also be linked to (Metadata version 1.2). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16401 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Mark Dickinson added the comment: Hmm: one more thing that needs to be fixed before this can be committed---the error messages for maltyped start, stop and step are less informative than they used to be. Before the patch: slice(0, 2.3, 4).indices(5) Traceback (most recent call last): File stdin, line 1, in module TypeError: slice indices must be integers or None or have an __index__ method After the patch: slice(0, 2.3, 4).indices(5) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'float' object cannot be interpreted as an integer I'll fix this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Antoine Pitrou added the comment: Autogenerated code could easily hit the 1000 term limit - if anything, I'd be inclined to set it *higher* than 4 rather than lower, as breaking previously working code in a maintenance release is a bad thing, regardless of our opinion of the sanity of that code. We can simply apply the 1000 limit in Python 3.4 and mark the bug as won't fix in other versions. I don't think adding a scaling factor just to cope with hypothetical silly code is a good thing in the long term. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Mark Dickinson added the comment: New patch that fixes the error message for badly typed slice arguments. Also tweaks a couple of other details: - replace Py_GE with Py_GT, Py_LE with Py_LT in the out-of-range comparisons, as suggested by Serhiy; this also makes it more closely match the Python reference implementation (since max(x, y) and min(x, y) both return x when x and y are equal) - make sure exception messages match between the Python reference implementation and the C version. Look at compute_slice_indices() in Objects/rangeobject.c. Will do. I'm not quite sure I even understand how that code's managing to work at the moment: I see the Py_ssize_t case, but I don't see the fallback code for the case when things are too large for a Py_ssize_t. -- Added file: http://bugs.python.org/file27878/issue14794_v4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13424] Add examples for open’s new opener argument
Serhiy Storchaka added the comment: Isn't it be clearer? import os dir_fd = os.open('somedir', os.O_RDONLY) def opener(path, flags): ... return os.open(path, flags, dir_fd=dir_fd) ... with open('spamspam.txt', 'w', opener=opener) as f: ... print('This will be written to somedir/spamspam.txt', file=f) ... os.close(dir_fd) # don't leak a file descriptor Or if you want stronger example: import os, contextlib, functools @contextlib.contextmanager ... def open_relative(dirname): ... dir_fd = os.open(dirname, os.O_RDONLY) ... def opener(path, flags): ... return os.open(path, flags, dir_fd=dir_fd) ... try: ... yield functools.partial(open, opener=opener) ... finally: ... os.close(dir_fd) ... with open_relative('somedir') as open: ... with open('spamspam.txt', 'w') as f: ... print('This will be written to somedir/spamspam.txt', file=f) ... Frankly speaking, all of these examples looks unconvincing to me. Even the second example could be implemented without an opener argument. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13424 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16183] ZipExtFile object close without file handle closed
Changes by Serhiy Storchaka storch...@gmail.com: -- components: -Windows ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16183 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Serhiy Storchaka added the comment: compute_slice_indices() and slice_indices() looks as partially duplicates. I think the similar code should be merged and reused. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16108] Include maintainer information in register/upload
Chris Jerdonek added the comment: Previous issues like this include issue 962772 (from 5/2004) and issue 3686 (from 8/2008). Copying the nosy lists from those issues. This issue affects me also because I maintain a project that I did not author. However, PyPI lists me as the author because of distutils's maintainer/author replacement logic when generating PKG-INFO. This issue has come up before, and PyPI continues to list maintainers as authors because of it. Whether or not we start sending both pieces of data, can PyPI perhaps be updated to display Contact instead of Author when Metadata-Version 1.1 is used? This seems better to me because distutils is not actually sending the author but rather contact information in this case (method get_contact())? http://hg.python.org/cpython/file/63b45c959a2a/Lib/distutils/dist.py#l1025 -- nosy: +akitada, chris.jerdonek, jbelmonte, lemburg, skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16402] range slicing swallows exceptions from __index__ methods.
New submission from Mark Dickinson: class A(object): ... def __index__(self): raise ZeroDivisionError ... [66062 refs] a = A() [66065 refs] range(10)[0:a] Traceback (most recent call last): File stdin, line 1, in module TypeError: slice indices must be integers or None or have an __index__ method [66105 refs] -- assignee: mark.dickinson messages: 174782 nosy: mark.dickinson priority: normal severity: normal status: open title: range slicing swallows exceptions from __index__ methods. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16402 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16402] range slicing swallows exceptions from __index__ methods.
Mark Dickinson added the comment: Here's a patch. -- keywords: +patch stage: - patch review type: - behavior versions: +Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file27879/issue16402.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16402 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14794] slice.indices raises OverflowError
Mark Dickinson added the comment: Agreed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16403] update distutils docs to say that maintainer replaces author
New submission from Chris Jerdonek: As discussed in issue 16108 and other issues referenced there, distutils lists the maintainer as the author in PKG-INFO when the maintainer is provided. However, the documentation does not state this. This issue is to update the distutils documentation to state this, e.g. here: http://docs.python.org/dev/distutils/setupscript.html#additional-meta-data and here: http://docs.python.org/dev/distutils/apiref.html#distutils.core.setup -- assignee: eric.araujo components: Distutils, Documentation keywords: easy messages: 174785 nosy: chris.jerdonek, eric.araujo, ezio.melotti, georg.brandl, tarek priority: normal severity: normal status: open title: update distutils docs to say that maintainer replaces author type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16403 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16108] Include maintainer information in register/upload
Chris Jerdonek added the comment: I also created issue 16403 to update the distutils docs to say that distutils lists the maintainer as the author in PKG-INFO when maintainer is provided. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16402] range slicing swallows exceptions from __index__ methods.
Changes by Mark Dickinson dicki...@gmail.com: -- components: +Interpreter Core ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16402 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16402] range slicing swallows exceptions from __index__ methods.
Roundup Robot added the comment: New changeset 94d15358ad6e by Mark Dickinson in branch '3.2': Issue #16402: In range slicing, fix shadowing of exceptions from __index__ method. http://hg.python.org/cpython/rev/94d15358ad6e New changeset 2b656a2cf7ef by Mark Dickinson in branch '3.3': Issue #16402: Merge fix from 3.2 http://hg.python.org/cpython/rev/2b656a2cf7ef New changeset f02555353544 by Mark Dickinson in branch 'default': Issue #16402: Merge fix from 3.3 http://hg.python.org/cpython/rev/f02555353544 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16402 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16402] range slicing swallows exceptions from __index__ methods.
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16402 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16235] Add python-config.sh for use during cross compilation.
Ray Donnelly added the comment: I agree in principle about not having to maintain two implementations but I would worry about breaking external packages that depend on the python implementation. In the meantime, please find an updated version of this patch that adds support for --configdir -- Added file: http://bugs.python.org/file27880/-add-python-config-sh.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16235 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
Serhiy Storchaka added the comment: I quote from Gregory P. Smith (msg91897): The decryption provided by the zipfile module is for the worthless 32-bit crc based encryption of zipfiles. I think promoting the use of that is a bad idea. zipfile can be used by people to get their data out of such files. We should not encourage them to put it and/or their code into such a stupid format. I think that the effort required for speedup of this almost useless feature is excessive. If someone want to implement the strong encryption for zip files - welcome. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16235] Add python-config.sh for use during cross compilation.
Ray Donnelly added the comment: I also checked the Windows releases and python-config isn't included. However, I don't think there's a good reason for that. python-config would in theory work fine if people wanted to link their programs to Python on Windows, as would python-config.sh given a posix-y shell that e.g. Cygwin or MSYS provide. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16235 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
Serhiy Storchaka added the comment: See also criticism in the original discussion: http://mail.python.org/pipermail/python-dev/2009-August/091450.html . -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16108] Include maintainer information in register/upload
Stefan Krah added the comment: Would that result in displaying both author and maintainer info on the PyPI page? For what cases is it useful? It gives due credit to the original author if another person maintains the package. I think it's a matter of common courtesy not to suppress author information (or worse, list the maintainer as the author). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16108 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
Robert de Vries added the comment: My use case is decrypting files of 100's of megabytes. This is so slow that it is quite useless. About an hour or so. I do agree that the encryption is worthless, but that is not important for my use case where I want to discourage people from reverse engineering the contents. If it is so dangerous as some people have pointed out, it should be removed at the cost of not supporting a standard feature of ZIP files. In my opinion you either support a feature and you support it good (efficient) or you don't. As it stands now, users will be disappointed in using a supported feature. Some people argue that adding C code to Python is dangerous as it will lead to bugs, vulnerabilities etc. You could dismiss every addition with C code to Python with this argument, so there must be some positive aspects to outweigh the negative side. The negative side is fairly small (50 lines of very simple C code), plus some standard Python glue code. The benefit is a 100 fold increase in performance and the removal of 1 line of documentation telling that this feature is extremely slow. (patch attached) -- Added file: http://bugs.python.org/file27881/doc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
R. David Murray added the comment: We aren't particularly interested in helping people make their files slightly harder to reverse engineer, either, so I don't think that is a good enough reason for accepting this. There might be other reasons that are good enough, but I don't think that is one of them. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
Christian Heimes added the comment: From the zlib FAQ: 38. How can I encrypt/decrypt zip files with zlib? zlib doesn't support encryption. The original PKZIP encryption is very weak and can be broken with freely available programs. To get strong encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib compression. For PKZIP compatible encryption, look at http://www.info-zip.org/ I don't see the point of a weak and easily breakable encryption. -- nosy: +christian.heimes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Roundup Robot added the comment: New changeset ab02cd145f56 by Nick Coghlan in branch '3.3': Issue #5765: Apply a hard recursion limit in the compiler http://hg.python.org/cpython/rev/ab02cd145f56 New changeset bd1db93d76e1 by Nick Coghlan in branch 'default': Issue #5765: Merge from 3.3 http://hg.python.org/cpython/rev/bd1db93d76e1 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Nick Coghlan added the comment: You can take the scaling factor out if you really want, but it adds no real maintenance overhead, and better reflects the real stack usage. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Nick Coghlan added the comment: However, agreed on the won't fix for 3.2 and 2.7, although I'd consider it at least for 2.7 if someone went through and worked out a patch that applies cleanly. For 3.2, this really isn't the kind of thing we'd want to do in the final regular maintenance release. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Antoine Pitrou added the comment: You can take the scaling factor out if you really want, but it adds no real maintenance overhead, and better reflects the real stack usage. Can you also add a related snippet in Tools/scripts/find_recursionlimit.py ? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Nick Coghlan added the comment: Note: if you do take the scaling factor out, don't forget to track down the reasons behind the original commit that added the test that broke *without* the scaling factor. For me, the test suite fails without it is reason enough for me to say its needed - someone decided at some point to ensure that level of nesting worked, so if we're going to go back on that, we need to know the original reason why the test was added. I think it's easier just to keep that code working, since we have a solution that *doesn't* break it and really isn't that complicated. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Roundup Robot added the comment: New changeset cf2515d0328b by Nick Coghlan in branch '3.3': Issue #5765: Also check the compiler when finding the recursion limit http://hg.python.org/cpython/rev/cf2515d0328b New changeset 3712028a0c34 by Nick Coghlan in branch 'default': Issue #5765: Merge from 3.3 http://hg.python.org/cpython/rev/3712028a0c34 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Nick Coghlan added the comment: The sanity check in the recursion limit finding script is definitely a good idea, so I added that (as the commits show). For the record, running that script on the 3.3 branch with my 4 GB RAM Fedora 17 ASUS Zenbook finds a maximum recursion limit around 16800, at which point test_add is the first one to die. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
Robert de Vries added the comment: If the encryption is so horrible why is there any support (with bad performance) at all in Python? It would be better to remove it altogether. This prevents users from building software using this feature only to find out later how bad the performance is. (This is the main reason why I have submitted this patch.) If the support had not been in Python I would not have used this feature to begin with. To reiterate my previous point. Either support something and do it well, or don't. Don't do a half job. Please note that there are more attempts to fix this, so I am not completely alone here. http://pypi.python.org/pypi/czipfile -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Mark Shannon added the comment: I don't think there is any need for a scaling factor. Expressions in auto-generated trees will tend to be trees of binary operator rather lists of purely unary operators. A tree of a billion items only has a depth of ~30. There is no way an expression tree 1000 deep could possibly have any sane behaviour. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Antoine Pitrou added the comment: The sanity check in the recursion limit finding script is definitely a good idea, so I added that (as the commits show). Didn't you make a mistake in the recursion factor there? Or is it really 10 rather than 3? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10030] Patch for zip decryption speedup
Antoine Pitrou added the comment: If the encryption is so horrible why is there any support (with bad performance) at all in Python? It would be better to remove it altogether. We don't remove it as it would break existing programs which rely on this feature. However adding a bunch of C code to improve performance of such a questionable feature is controversial. I wouldn't be against the acceleration myself, however I am not interested in reviewing or accepting it, sorry. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16298] httplib.HTTPResponse.read could potentially leave the socket opened forever
Antoine Pitrou added the comment: The patch is probably trivial - however I would still like some verification. Would it be correct to call self.close() when fp.read returns ''? In case self.length is not present, I don't see a way around this anyway. When it is present, and fp.read returns '', how should we go about that? We can either return less data, or raise an exception to indicate that the connection terminated prematurely. It's probably better to return less data. No need to break user programs when they download from a slightly misbehaved Web site. The patch should include some kind of unit test, if possible. See Lib/test/test_httplib.py. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16298 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5765] stack overflow evaluating eval(() * 30000)
Nick Coghlan added the comment: Antoine: The scaling is deliberate higher in the recursion limit finder because we just want to ensure it hits the recursion limit (or blows the stack, if the scaling is wrong). In the tests, I cut it finer because I wanted to ensure we were straddling the allowed/disallowed boundary fairly closely in order to properly test the code that accounts for the *existing* recursion depth when initialising the compiler's internal state. Mark: same answer I gave Antoine earlier. Without the scaling factor, a test fails. If you want to advocate for removing or changing that test instead, track down why it was added and provide a rationale for why it's no longer applicable. However, before you invest too much time in that, note that the trees generated by binary operators of the same precedence in CPython are *not* balanced (IIRC, the LHS is handled as a leaf expression), thus they also suffer from this recursion problem (if you look at the patch I committed, I added an extra test beyond those Andrea provided: a multiplication expression with a ridiculously large number of terms). I agree that path is the only one generated code is likely to hit, though, which is why I added a specific test for it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5765 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16404] Uses of PyLong_FromLong that don't check for errors
New submission from Ned Batchelder: Examining the CPython sources, there are a number of places where PyLong_FromLong is used without checking its return value. In places where it is done correctly, PyErr_Occurred is often used to avoid having to check every call. Here are places where it isn't done properly. I can make patches if desired, though I can't build and test on Windows. This code is from CPython tip, but the same issues exist in the 2.7 branch. In Modules/arraymodule.c: static PyObject * array_buffer_info(arrayobject *self, PyObject *unused) { PyObject* retval = NULL; retval = PyTuple_New(2); if (!retval) return NULL; PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self-ob_item)); PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_SIZE(self; return retval; } In Modules/ossaudiodev.c /* Construct the return value: a (fmt, channels, rate) tuple that tells what the audio hardware was actually set to. */ rv = PyTuple_New(3); if (rv == NULL) return NULL; PyTuple_SET_ITEM(rv, 0, PyLong_FromLong(fmt)); PyTuple_SET_ITEM(rv, 1, PyLong_FromLong(channels)); PyTuple_SET_ITEM(rv, 2, PyLong_FromLong(rate)); return rv; These 7 lines could be replaced simply with: return Py_BuildValue((iii), fmt, channels, rate); In Python/sysmodule.c, where the PyUnicode_FromString is far more worrisome: static PyObject * sys_getwindowsversion(PyObject *self) { PyObject *version; int pos = 0; OSVERSIONINFOEX ver; ver.dwOSVersionInfoSize = sizeof(ver); if (!GetVersionEx((OSVERSIONINFO*) ver)) return PyErr_SetFromWindowsErr(0); version = PyStructSequence_New(WindowsVersionType); if (version == NULL) return NULL; PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwMajorVersion)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwMinorVersion)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwBuildNumber)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwPlatformId)); PyStructSequence_SET_ITEM(version, pos++, PyUnicode_FromString(ver.szCSDVersion)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wServicePackMajor)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wServicePackMinor)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wSuiteMask)); PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType)); return version; } In Doc/extending/extending.rst, as an example of a correct function!: void no_bug(PyObject *list) { PyObject *item = PyList_GetItem(list, 0); Py_INCREF(item); PyList_SetItem(list, 1, PyLong_FromLong(0L)); PyObject_Print(item, stdout, 0); Py_DECREF(item); } -- messages: 174809 nosy: nedbat priority: normal severity: normal status: open title: Uses of PyLong_FromLong that don't check for errors versions: Python 2.7, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16404 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16405] Explain how to set up the whitespace commit hook locally
New submission from Nick Coghlan: Setting up the same commit checks locally that the main repo enforces for incoming patch sets can save a great deal of frustration with the server rejecting hg push for changes (this can be especially frustrating if you have already merged changes across branches). The committer section of the devguide [1] should explain how to: 1. Check out the hooks repo from hg.python.org 2. Configure the whitespace checking hook by adding this to hgrc for the relevant repo(s) (adjusting the path appropriately for the checked out location of the hooks repo): [hooks] commit = python:~/devel/hg_hooks/checkwhitespace.py:check_whitespace_single [1] http://docs.python.org/devguide/committing.html#committing-and-pushing-changes -- components: Devguide messages: 174810 nosy: ezio.melotti, ncoghlan priority: normal severity: normal stage: needs patch status: open title: Explain how to set up the whitespace commit hook locally type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16392] import crashes on circular imports in ext modules
Brett Cannon added the comment: It sounds like Cython has its fix and CPython knows what should eventually be changed in Python 4 to bring extension module initialization closer to how Python module code is initialized. Maybe we should add a warning in some documentation somewhere about this and then close the issue? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16392 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16405] Explain how to set up the whitespace commit hook locally
Ezio Melotti added the comment: Configuring the editor to remove trailing whitespace, and using make patchcheck are other valid solutions to this problem. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com