From ned at nedbatchelder.com Sun May 1 00:49:11 2011 From: ned at nedbatchelder.com (Ned Batchelder) Date: Sat, 30 Apr 2011 18:49:11 -0400 Subject: [Python-Dev] sys.settrace: behavior doesn't match docs Message-ID: <4DBC91E7.9060402@nedbatchelder.com> This week I learned something new about trace functions (how to write a C trace function that survives a sys.settrace(sys.gettrace()) round-trip), and while writing up what I learned, I was surprised to discover that trace functions don't behave the way I thought, or the way the docs say they behave. The docs say: The trace function is invoked (with /event/ set to 'call') whenever a new local scope is entered; it should return a reference to a local trace function to be used that scope, or None if the scope shouldn't be traced. The local trace function should return a reference to itself (or to another function for further tracing in that scope), or None to turn off tracing in that scope. It's that last part that's wrong: returning None from the trace function only has an effect on the first call in a new frame. Once the trace function returns a function for a frame, returning None from subsequent calls is ignored. A "local trace function" can't turn off tracing in its scope. To demonstrate: import sys UPTO_LINE = 1 def t(frame, event, arg): num = frame.f_lineno print("line %d" % num) if num < UPTO_LINE: return t def try_it(): print("twelve") print("thirteen") print("fourteen") print("fifteen") UPTO_LINE = 1 sys.settrace(t) try_it() UPTO_LINE = 13 sys.settrace(t) try_it() Produces: line 11 twelve thirteen fourteen fifteen line 11 line 12 twelve line 13 thirteen line 14 fourteen line 15 fifteen line 15 The first call to try_it() returns None immediately, preventing tracing for the rest of the function. The second call returns None at line 13, but the rest of the function is traced anyway. This behavior is the same in all versions from 2.3 to 3.2, in fact, the 100 lines of code in sysmodule.c responsible for Python tracing functions are completely unchanged through those versions. (A deeper mystery that I haven't looked into yet is why Python 3.x intersperses all of these lines with "line 18" interjections.) I'm writing this email because I'm not sure whether this is a behavior bug or a doc bug. One of them is wrong, since they disagree. The documented behavior makes sense, and is what people have all along thought the trace function did. The actual behavior is a bit more complicated to explain, but is what people have actually been experiencing. FWIW, PyPy implements the documented behavior. Should we fix the code or the docs? I'd be glad to supply a patch for either. --Ned. -------------- next part -------------- An HTML attachment was scrubbed... URL: From guido at python.org Sun May 1 02:43:27 2011 From: guido at python.org (Guido van Rossum) Date: Sat, 30 Apr 2011 17:43:27 -0700 Subject: [Python-Dev] sys.settrace: behavior doesn't match docs In-Reply-To: <4DBC91E7.9060402@nedbatchelder.com> References: <4DBC91E7.9060402@nedbatchelder.com> Message-ID: I think you need to go back farther in time. :-) In Python 2.0 the call_trace function in ceval.c has a completely different signature (but the docs are the same). I haven't checked all history but somewhere between 2.0 and 2.3, SET_LINENO-less tracing was added, and that's where the implementation must have gone wrong. So I think we should fix the code. --Guido On Sat, Apr 30, 2011 at 3:49 PM, Ned Batchelder wrote: > This week I learned something new about trace functions (how to write a C > trace function that survives a sys.settrace(sys.gettrace()) round-trip), and > while writing up what I learned, I was surprised to discover that trace > functions don't behave the way I thought, or the way the docs say they > behave. > > The docs say: > > The trace function is invoked (with event set to 'call') whenever a new > local scope is entered; it should return a reference to a local trace > function to be used that scope, or None if the scope shouldn?t be traced. > > The local trace function should return a reference to itself (or to another > function for further tracing in that scope), or None to turn off tracing in > that scope. > > It's that last part that's wrong: returning None from the trace function > only has an effect on the first call in a new frame.? Once the trace > function returns a function for a frame, returning None from subsequent > calls is ignored.? A "local trace function" can't turn off tracing in its > scope. > > To demonstrate: > > import sys > > UPTO_LINE = 1 > > def t(frame, event, arg): > ??? num = frame.f_lineno > ??? print("line %d" % num) > ??? if num < UPTO_LINE: > ??????? return t > > def try_it(): > ??? print("twelve") > ??? print("thirteen") > ??? print("fourteen") > ??? print("fifteen") > > UPTO_LINE = 1 > sys.settrace(t) > try_it() > > UPTO_LINE = 13 > sys.settrace(t) > try_it() > > Produces: > > line 11 > twelve > thirteen > fourteen > fifteen > line 11 > line 12 > twelve > line 13 > thirteen > line 14 > fourteen > line 15 > fifteen > line 15 > > The first call to try_it() returns None immediately, preventing tracing for > the rest of the function.? The second call returns None at line 13, but the > rest of the function is traced anyway.? This behavior is the same in all > versions from 2.3 to 3.2, in fact, the 100 lines of code in sysmodule.c > responsible for Python tracing functions are completely unchanged through > those versions.? (A deeper mystery that I haven't looked into yet is why > Python 3.x intersperses all of these lines with "line 18" interjections.) > > I'm writing this email because I'm not sure whether this is a behavior bug > or a doc bug.? One of them is wrong, since they disagree.? The documented > behavior makes sense, and is what people have all along thought the trace > function did.? The actual behavior is a bit more complicated to explain, but > is what people have actually been experiencing.? FWIW, PyPy implements the > documented behavior. > > Should we fix the code or the docs?? I'd be glad to supply a patch for > either. > > --Ned. > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/guido%40python.org > > -- --Guido van Rossum (python.org/~guido) From techtonik at gmail.com Sun May 1 12:40:43 2011 From: techtonik at gmail.com (anatoly techtonik) Date: Sun, 1 May 2011 13:40:43 +0300 Subject: [Python-Dev] 2to3 status, repositories and HACKING guide In-Reply-To: References: Message-ID: Is there any high-level overview of 2to3 tool that people can use as a quick start for writing their own fixers? Source doesn't explain much (to me at least), and some kind of "learn by example" would really help a lot. In particular, I find the syntax of tree matchers the most unclear part. -- anatoly t. On Fri, Mar 25, 2011 at 9:12 PM, Benjamin Peterson wrote: > The main cpython repo. > > 2011/3/25 anatoly techtonik : >> Hi, Benjamin, >> >> Is your repository for 2to3 is still actual? >> http://svn.python.org/view/sandbox/trunk/2to3/ >> >> Which should I use to start hacking on 2to3? >> >> -- >> anatoly t. >> >> >> >> On Wed, Mar 23, 2011 at 9:01 AM, anatoly techtonik wrote: >>> Hi, >>> >>> Currently 2to3 page at http://wiki.python.org/moin/2to3 lists >>> http://svn.python.org/view/sandbox/trunk/2to3 as a repository for 2to3 >>> tool. There is also an outdated repository at http://hg.python.org/ >>> and the page says that the code is finally integrated into CPython 2.6 >>> - you can see it at >>> http://hg.python.org/cpython/file/default/Lib/lib2to3. So, what >>> version is more up-to-date? >>> >>> In svn repository there is a HACKING guide advising to use >>> find_pattern.py script for writing new fixer. However, there is no >>> find_pattern.py in CPython repository, no HACKING guide, no any >>> documentation about how to write fixers or description of PATTERN >>> format. Did I miss something? >>> -- >>> anatoly t. >>> >> > > > > -- > Regards, > Benjamin > From ncoghlan at gmail.com Sun May 1 13:27:44 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sun, 1 May 2011 21:27:44 +1000 Subject: [Python-Dev] Not-a-Number (was PyObject_RichCompareBool identity shortcut) In-Reply-To: References: <4DB7E3EA.3030208@avl.com> <87d3k79jvt.fsf@uwakimon.sk.tsukuba.ac.jp> <4DB90748.4030501@g.nevcal.com> <4DB916DE.1050302@g.nevcal.com> <4DB927F4.3040206@dcs.gla.ac.uk> <871v0la5yg.fsf@uwakimon.sk.tsukuba.ac.jp> Message-ID: On Sat, Apr 30, 2011 at 3:11 AM, Guido van Rossum wrote: > Decimal, for that reason, has a context that lets one specify > different behaviors when a NaN is produced. Would it make sense to add > a float context that also lets one specify what should happen? That > could include returning Inf for 1.0/0.0 (for experts), or raising > exceptions when NaNs are produced (for the numerically naive like > myself). > > I could see a downside too, e.g. the correctness of code that > passingly uses floats might be affected by the context settings. > There's also the question of whether the float context should affect > int operations; floats vs. ints is another can of worms since (in > Python 3) we attempt to tie them together through 1/2 == 0.5, but ints > have a much larger range than floats. Given that we delegate most float() behaviour to the underlying CPU and C libraries (and then the math module tries to cope with any cross-platform discrepancies), introducing context handling isn't easy, and would likely harm the current speed advantage that floats hold over the decimal module. We decided that losing the speed advantage of native integers was worthwhile in order to better unify the semantics of int and long for Py3k, but both the speed differential and the semantic gap between float() and decimal.Decimal() are significantly larger. However, I did find Terry's suggestion of using the warnings module to report some of the floating point corner cases that currently silently produce unexpected results to be an interesting one. If those operations issued a FloatWarning, then users could either silence them or turn them into errors as desired. Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From benjamin at python.org Sun May 1 17:44:10 2011 From: benjamin at python.org (Benjamin Peterson) Date: Sun, 1 May 2011 10:44:10 -0500 Subject: [Python-Dev] 2to3 status, repositories and HACKING guide In-Reply-To: References: Message-ID: 2011/5/1 anatoly techtonik : > Is there any high-level overview of 2to3 tool that people can use as a > quick start for writing their own fixers? No. > > Source doesn't explain much (to me at least), and some kind of "learn > by example" would really help a lot. In particular, I find the syntax of > tree matchers the most unclear part. I think you can learn a lot by reading through the current fixers in lib2to3/fixers/. -- Regards, Benjamin From g.brandl at gmx.net Sun May 1 18:31:20 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Sun, 01 May 2011 18:31:20 +0200 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: On 30.04.2011 16:53, anatoly techtonik wrote: > On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray wrote: >> >> The hardest part is debugging the TAL when you make a mistake, but >> even that isn't a whole lot worse than any other templating language. > > How much in % is it worse than Django templating language? I'm just guessing here, but I'd say 47.256 %. Georg From g.brandl at gmx.net Sun May 1 19:57:51 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Sun, 01 May 2011 19:57:51 +0200 Subject: [Python-Dev] Python 3.2.1 Message-ID: Hi, I'd like to release Python 3.2.1 on May 21, with a release candidate on May 14. Please bring any issues you think need to be fixed in it to my attention by assigning "release blocker" status in the tracker. Georg From raymond.hettinger at gmail.com Sun May 1 20:22:02 2011 From: raymond.hettinger at gmail.com (Raymond Hettinger) Date: Sun, 1 May 2011 11:22:02 -0700 Subject: [Python-Dev] Python 3.2.1 In-Reply-To: References: Message-ID: <5D8F6095-D052-47F6-A65B-D578A4460F20@gmail.com> On May 1, 2011, at 10:57 AM, Georg Brandl wrote: > I'd like to release Python 3.2.1 on May 21, with a release candidate > on May 14. Please bring any issues you think need to be fixed in it > to my attention by assigning "release blocker" status in the tracker. Thanks to http://www.python.org/dev/daily-dmg/ , I've been able to work off of the head every day. Python 3.2.1 is in pretty good shape :-) Raymond -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sun May 1 20:45:06 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 01 May 2011 14:45:06 -0400 Subject: [Python-Dev] Not-a-Number (was PyObject_RichCompareBool identity shortcut) In-Reply-To: References: <4DB7E3EA.3030208@avl.com> <87d3k79jvt.fsf@uwakimon.sk.tsukuba.ac.jp> <4DB90748.4030501@g.nevcal.com> <4DB916DE.1050302@g.nevcal.com> <4DB927F4.3040206@dcs.gla.ac.uk> <871v0la5yg.fsf@uwakimon.sk.tsukuba.ac.jp> Message-ID: On 5/1/2011 7:27 AM, Nick Coghlan wrote: > However, I did find Terry's suggestion of using the warnings module to > report some of the floating point corner cases that currently silently > produce unexpected results to be an interesting one. If those > operations issued a FloatWarning, then users could either silence them > or turn them into errors as desired. I would like to take credit for that, but I was actually seconding Alexander's insight and idea. I may have added the specific name after looking at the currently list and seeing UnicodeWarning and BytesWarning, so why not a FloatWarning. I did read the warnings doc more carefully to verify that it would really put the user in control, which was apparently the intent of the committee. I am not sure whether FloatWarnings should ignored or printed by default. Ignored would, I guess, match current behavior, unless something else is changed as part of a more extensive overhaul. -f and -ff are available to turn ignored FloatWarning into print or raise exception, as with BytesWarning. I suspect that these would get at lease as much usage as -b and -bb. So I see 4 questions: 1. Add FloatWarning? 2. If yes, default disposition? 3. Add command line options? 4. Use the addition of FloatWarning as an opportunity to change other defaults, given that user will have more options? -- Terry Jan Reedy From brian.curtin at gmail.com Sun May 1 22:51:55 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Sun, 1 May 2011 15:51:55 -0500 Subject: [Python-Dev] Windows 2000 Support Message-ID: I'm currently writing a post about the process of removing OS/2 and VMS support and thought about a discussion of Windows 2000 some time back. http://mail.python.org/pipermail/python-dev/2010-March/098074.html makes a proposal for beginning to walk away from 2000, but doesn't appear to come to any conclusion. Was anything decided off the list? I don't see anything in PEP-11 and don't see any changes in the installer made around Windows 2000. If nothing was decided, should anything be done for 3.3? -------------- next part -------------- An HTML attachment was scrubbed... URL: From victor.stinner at haypocalc.com Mon May 2 12:06:47 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Mon, 2 May 2011 12:06:47 +0200 Subject: [Python-Dev] Raise OSError or RuntimeError in the OS module? Message-ID: <201105021206.47384.victor.stinner@haypocalc.com> Hi, I introduced recently the signal.pthread_sigmask() function (issue #8407). pthread_sigmask() (the C function) returns an error code using errno codes. I choosed to raise a RuntimeError using this error code, but I am not sure that RuntimeError is the best choice. It is more an OS error than a runtime error: should signal.pthread_sigmask() raise an OSError instead? signal.signal() raises a RuntimeError if setting the signal handler failed. signal.siginterrupt() raises also a RuntimeError on error. signal.setitimer() and signal.getitimer() have their own exception class: signal.ItimerError, raised on setimer() and getitimer() error. Victor From ned at nedbatchelder.com Mon May 2 13:27:40 2011 From: ned at nedbatchelder.com (Ned Batchelder) Date: Mon, 02 May 2011 07:27:40 -0400 Subject: [Python-Dev] sys.settrace: behavior doesn't match docs In-Reply-To: References: <4DBC91E7.9060402@nedbatchelder.com> Message-ID: <4DBE952C.2070005@nedbatchelder.com> Indeed, the 2.0 code is very different, and got this case right. I'm a little surprised no one is arguing that changing this code now could break some applications. Maybe the fact no one noticed the docs were wrong proves that no one ever tried returning None from a local trace function. --Ned. On 4/30/2011 8:43 PM, Guido van Rossum wrote: > I think you need to go back farther in time. :-) In Python 2.0 the > call_trace function in ceval.c has a completely different signature > (but the docs are the same). I haven't checked all history but > somewhere between 2.0 and 2.3, SET_LINENO-less tracing was added, and > that's where the implementation must have gone wrong. So I think we > should fix the code. > > --Guido > > On Sat, Apr 30, 2011 at 3:49 PM, Ned Batchelder wrote: >> This week I learned something new about trace functions (how to write a C >> trace function that survives a sys.settrace(sys.gettrace()) round-trip), and >> while writing up what I learned, I was surprised to discover that trace >> functions don't behave the way I thought, or the way the docs say they >> behave. >> >> The docs say: >> >> The trace function is invoked (with event set to 'call') whenever a new >> local scope is entered; it should return a reference to a local trace >> function to be used that scope, or None if the scope shouldn?t be traced. >> >> The local trace function should return a reference to itself (or to another >> function for further tracing in that scope), or None to turn off tracing in >> that scope. >> >> It's that last part that's wrong: returning None from the trace function >> only has an effect on the first call in a new frame. Once the trace >> function returns a function for a frame, returning None from subsequent >> calls is ignored. A "local trace function" can't turn off tracing in its >> scope. >> >> To demonstrate: >> >> import sys >> >> UPTO_LINE = 1 >> >> def t(frame, event, arg): >> num = frame.f_lineno >> print("line %d" % num) >> if num< UPTO_LINE: >> return t >> >> def try_it(): >> print("twelve") >> print("thirteen") >> print("fourteen") >> print("fifteen") >> >> UPTO_LINE = 1 >> sys.settrace(t) >> try_it() >> >> UPTO_LINE = 13 >> sys.settrace(t) >> try_it() >> >> Produces: >> >> line 11 >> twelve >> thirteen >> fourteen >> fifteen >> line 11 >> line 12 >> twelve >> line 13 >> thirteen >> line 14 >> fourteen >> line 15 >> fifteen >> line 15 >> >> The first call to try_it() returns None immediately, preventing tracing for >> the rest of the function. The second call returns None at line 13, but the >> rest of the function is traced anyway. This behavior is the same in all >> versions from 2.3 to 3.2, in fact, the 100 lines of code in sysmodule.c >> responsible for Python tracing functions are completely unchanged through >> those versions. (A deeper mystery that I haven't looked into yet is why >> Python 3.x intersperses all of these lines with "line 18" interjections.) >> >> I'm writing this email because I'm not sure whether this is a behavior bug >> or a doc bug. One of them is wrong, since they disagree. The documented >> behavior makes sense, and is what people have all along thought the trace >> function did. The actual behavior is a bit more complicated to explain, but >> is what people have actually been experiencing. FWIW, PyPy implements the >> documented behavior. >> >> Should we fix the code or the docs? I'd be glad to supply a patch for >> either. >> >> --Ned. >> >> >> _______________________________________________ >> Python-Dev mailing list >> Python-Dev at python.org >> http://mail.python.org/mailman/listinfo/python-dev >> Unsubscribe: >> http://mail.python.org/mailman/options/python-dev/guido%40python.org >> >> > > From mhammond at skippinet.com.au Mon May 2 14:47:11 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 02 May 2011 22:47:11 +1000 Subject: [Python-Dev] sys.settrace: behavior doesn't match docs In-Reply-To: <4DBE952C.2070005@nedbatchelder.com> References: <4DBC91E7.9060402@nedbatchelder.com> <4DBE952C.2070005@nedbatchelder.com> Message-ID: <4DBEA7CF.4030307@skippinet.com.au> On 2/05/2011 9:27 PM, Ned Batchelder wrote: ... > Maybe the fact no one noticed the docs > were wrong proves that no one ever tried returning None from a local > trace function. Or if they did, they should have complained by now. IMO, if the behaviour regresses from how it is documented and how it previously worked and no reports of the regression exist, we should just fix it without regard to people relying on the "new" functionality... Mark From ncoghlan at gmail.com Mon May 2 15:12:32 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Mon, 2 May 2011 23:12:32 +1000 Subject: [Python-Dev] sys.settrace: behavior doesn't match docs In-Reply-To: <4DBEA7CF.4030307@skippinet.com.au> References: <4DBC91E7.9060402@nedbatchelder.com> <4DBE952C.2070005@nedbatchelder.com> <4DBEA7CF.4030307@skippinet.com.au> Message-ID: On Mon, May 2, 2011 at 10:47 PM, Mark Hammond wrote: > On 2/05/2011 9:27 PM, Ned Batchelder wrote: > ... >> >> Maybe the fact no one noticed the docs >> were wrong proves that no one ever tried returning None from a local >> trace function. > > Or if they did, they should have complained by now. ?IMO, if the behaviour > regresses from how it is documented and how it previously worked and no > reports of the regression exist, we should just fix it without regard to > people relying on the "new" functionality... +1 Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From vinay_sajip at yahoo.co.uk Mon May 2 16:26:56 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 2 May 2011 14:26:56 +0000 (UTC) Subject: [Python-Dev] Socket servers in the test suite References: Message-ID: Nick Coghlan gmail.com> writes: > sure the urllib tests already fire up a local server). Starting down > the path of standardisation of that test functionality would be good. I've made a start with test_logging.py by implementing some potential server classes for use in tests: in the latest test_logging.py, the servers are between comments containing the text "server_helper". The basic approach for implementing socket servers is traditionally to use a request handler class which implements the custom logic, but for some testing applications this is overkill - you just want to be able to pass a handling callable which is, say, a test case method. So the signatures of the servers are all like this: __init__(self, listen_addr, handler, poll_interval ...) Initialise using the specified listen address and handler callable. Internally, a RequestHandler subclass will be used whose handle() delegates to the handler callable passed in. A zero port number can be passed in, and a port attribute will (after binding) have the actual port number used, so that clients can connect on that port. start() Start the server on a separate thread, using the poll_interval specified in the underlying poll()/select() call. Before this is called, the request handler class could be replaced with a subclass if need be. stop(timeout=None) Ask the server to stop and wait for the server thread to terminate. The server also has a ready attribute which is a threading.Event, set just when the server is entering its service loop. Typical mode of use would be: class ClientTestCase(unittest.TestCase): def setUp(self): self.server = TheAppropriateServerClass(('localhost', 0), self.handle_request, 0.01, ...) self.server.start() self.server.ready.wait() self.handled = threading.Event() def tearDown(self): self.server.stop(1.0) # wait up to 1 sec for thread to stop def handle_request(self, request): # Handle the request, e.g. by setting some attributes based on what # was received at the server # Set the flag to say we finished handling self.handled.set() def test_xxx(self): # set up client and send stuff to server # Wait for server to finish doing stuff self.handled.wait() # make assertions based on the attributes # set during request handling The server classes provided are TestSMTPServer, TestTCPServer, TestUDPServer and TestHTTPServer. There are examples of actual usage in test_logging.py: SMTPHandlerTest, SocketHandlerTest, DatagramHandlerTest, SysLogHandlerTest, HTTPHandlerTest. I'd like some comments on this suggested API. I have not yet looked at how to adapt other stdlib code than test_logging to use these classes, but the above usage mode seems convenient and sufficient for testing applications. No doubt people will be able to suggest problems with/improvements to the approach outlined above. Regards, Vinay Sajip From techtonik at gmail.com Mon May 2 18:06:58 2011 From: techtonik at gmail.com (anatoly techtonik) Date: Mon, 2 May 2011 19:06:58 +0300 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: On Sun, May 1, 2011 at 7:31 PM, Georg Brandl wrote: > On 30.04.2011 16:53, anatoly techtonik wrote: >> On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray wrote: >>> >>> The hardest part is debugging the TAL when you make a mistake, but >>> even that isn't a whole lot worse than any other templating language. >> >> How much in % is it worse than Django templating language? > > I'm just guessing here, but I'd say 47.256 %. That means switching to Django templates will make Roundup design plumbing work 47.256% more attractive for potential contributors. -- anatoly t. From benjamin at python.org Mon May 2 18:17:59 2011 From: benjamin at python.org (Benjamin Peterson) Date: Mon, 2 May 2011 11:17:59 -0500 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: 2011/5/2 anatoly techtonik : > On Sun, May 1, 2011 at 7:31 PM, Georg Brandl wrote: >> On 30.04.2011 16:53, anatoly techtonik wrote: >>> On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray wrote: >>>> >>>> The hardest part is debugging the TAL when you make a mistake, but >>>> even that isn't a whole lot worse than any other templating language. >>> >>> How much in % is it worse than Django templating language? >> >> I'm just guessing here, but I'd say 47.256 %. > > That means switching to Django templates will make Roundup design > plumbing work 47.256% more attractive for potential contributors. Perhaps some of those eager contributors would like to volunteer for the task. -- Regards, Benjamin From brian.curtin at gmail.com Mon May 2 18:19:28 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Mon, 2 May 2011 11:19:28 -0500 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: On Mon, May 2, 2011 at 11:06, anatoly techtonik wrote: > On Sun, May 1, 2011 at 7:31 PM, Georg Brandl wrote: > > On 30.04.2011 16:53, anatoly techtonik wrote: > >> On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray > wrote: > >>> > >>> The hardest part is debugging the TAL when you make a mistake, but > >>> even that isn't a whole lot worse than any other templating language. > >> > >> How much in % is it worse than Django templating language? > > > > I'm just guessing here, but I'd say 47.256 %. > > That means switching to Django templates will make Roundup design > plumbing work 47.256% more attractive for potential contributors. What if these "potential contributors" never surface? Then we've made a 47.256% change in attractiveness, which is a 1423.843% waste of time. -------------- next part -------------- An HTML attachment was scrubbed... URL: From techtonik at gmail.com Mon May 2 19:14:50 2011 From: techtonik at gmail.com (anatoly techtonik) Date: Mon, 2 May 2011 20:14:50 +0300 Subject: [Python-Dev] PEP 386 and dev repository versions workflow Message-ID: http://guide.python-distribute.org/quickstart.html proposes suffixing version of a module in repository with 'dev' in a way that after release of '1.0' version, the repository version is changed to '2.0dev'. This makes sense, but it is not compatible with PEP 386, which suggests using 2.0.devN, where N is a repository revision number. I'd expand PEP 386 to include 2.0dev use case. -- anatoly t. From ziade.tarek at gmail.com Mon May 2 19:19:28 2011 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Mon, 2 May 2011 19:19:28 +0200 Subject: [Python-Dev] PEP 386 and dev repository versions workflow In-Reply-To: References: Message-ID: On Mon, May 2, 2011 at 7:14 PM, anatoly techtonik wrote: > http://guide.python-distribute.org/quickstart.html proposes suffixing > version of a module in repository with 'dev' in a way that after > release of '1.0' version, the repository version is changed to > '2.0dev'. This makes sense, but it is not compatible with PEP 386, > which suggests using 2.0.devN, where N is a repository revision > number. I'd expand PEP 386 to include 2.0dev use case. This is a typo I'll fix, thanks for noticing > -- > anatoly t. > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/ziade.tarek%40gmail.com > -- Tarek Ziad? | http://ziade.org From g.rodola at gmail.com Mon May 2 20:27:57 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Mon, 2 May 2011 20:27:57 +0200 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: 2011/4/30 anatoly techtonik : > On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray wrote: >> >> The hardest part is debugging the TAL when you make a mistake, but >> even that isn't a whole lot worse than any other templating language. > > How much in % is it worse than Django templating language? > -- > anatoly t. > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/g.rodola%40gmail.com > Knowing both of them I can say ZPT is one of the few things I like about Zope and I find it a lot more powerful than Django templating system. Other than that, I don't see how changing the templating language can make any difference. If one does not contribute something because of the language used in templates... well, I think it wouldn't have been a particular good contribution anyway. =) --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From g.brandl at gmx.net Mon May 2 20:41:12 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Mon, 02 May 2011 20:41:12 +0200 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: On 02.05.2011 18:06, anatoly techtonik wrote: > On Sun, May 1, 2011 at 7:31 PM, Georg Brandl wrote: >> On 30.04.2011 16:53, anatoly techtonik wrote: >>> On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray wrote: >>>> >>>> The hardest part is debugging the TAL when you make a mistake, but >>>> even that isn't a whole lot worse than any other templating language. >>> >>> How much in % is it worse than Django templating language? >> >> I'm just guessing here, but I'd say 47.256 %. > > That means switching to Django templates will make Roundup design > plumbing work 47.256% more attractive for potential contributors. That's not true actually. It'll be 89.595 % more attractive. Georg From sijinjoseph at gmail.com Mon May 2 17:27:49 2011 From: sijinjoseph at gmail.com (Sijin Joseph) Date: Mon, 2 May 2011 11:27:49 -0400 Subject: [Python-Dev] Convert Py_Buffer to Py_UNICODE Message-ID: Hi - I am working on a patch where I have an argument that can either be a unicode string or binary data, I parse the argument using the PyArg_ParseTuple method using the s* format specification and get a Py_Buffer. I now need to convert this Py_Buffer object to a Py_Unicode and pass it into a function. What is the best way to do this? If I determine that the passed argument was binary using another flag parameter then I am passing Py_Buffer->buf as a pointer to the start of the data. This is in winsound module, here's the relevant code snippet sound_playsound(PyObject *s, PyObject *args) { Py_buffer *buffer; int flags; int ok; LPCWSTR pszSound; if (PyArg_ParseTuple(args, "s*i:PlaySound", &buffer, &flags)) { if (flags & SND_ASYNC && flags & SND_MEMORY) { /* Sidestep reference counting headache; unfortunately this also prevent SND_LOOP from memory. */ PyBuffer_Release(buffer); PyErr_SetString(PyExc_RuntimeError, "Cannot play asynchronously from memory"); return NULL; } if(flags & SND_MEMORY) { pszSound = buffer->buf; } else { /* pszSound = ????; */ } -- Sijin -------------- next part -------------- An HTML attachment was scrubbed... URL: From mal at egenix.com Mon May 2 21:12:27 2011 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 02 May 2011 21:12:27 +0200 Subject: [Python-Dev] Convert Py_Buffer to Py_UNICODE In-Reply-To: References: Message-ID: <4DBF021B.90602@egenix.com> Sijin Joseph wrote: > Hi - I am working on a patch where I have an argument that can either be a > unicode string or binary data, I parse the argument using the > PyArg_ParseTuple method using the s* format specification and get a > Py_Buffer. > > I now need to convert this Py_Buffer object to a Py_Unicode and pass it into > a function. What is the best way to do this? If I determine that the passed > argument was binary using another flag parameter then I am passing > Py_Buffer->buf as a pointer to the start of the data. I don't understand why you'd want to convert PyUnicode to PyBytes (encoded as UTF-8), only to decode it again afterwards in order to pass it to some other PyUnicode API. It'd be more efficient to use the "O" parser marker and then use PyObject_GetBuffer() to convert non-PyUnicode objects to a Py_buffer. > This is in winsound module, here's the relevant code snippet > > sound_playsound(PyObject *s, PyObject *args) > { > Py_buffer *buffer; > int flags; > int ok; > LPCWSTR pszSound; > > if (PyArg_ParseTuple(args, "s*i:PlaySound", &buffer, &flags)) { > if (flags & SND_ASYNC && flags & SND_MEMORY) { > /* Sidestep reference counting headache; unfortunately this also > prevent SND_LOOP from memory. */ > PyBuffer_Release(buffer); > PyErr_SetString(PyExc_RuntimeError, "Cannot play asynchronously > from memory"); > return NULL; > } > > if(flags & SND_MEMORY) { > pszSound = buffer->buf; > } > else { > /* pszSound = ????; */ > } > > -- Sijin > > > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/mal%40egenix.com -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 02 2011) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2011-06-20: EuroPython 2011, Florence, Italy 49 days to go ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From benjamin at python.org Mon May 2 21:25:44 2011 From: benjamin at python.org (Benjamin Peterson) Date: Mon, 2 May 2011 14:25:44 -0500 Subject: [Python-Dev] Issue Tracker In-Reply-To: References: <4D90EA06.3030003@stoneleaf.us> <20110328223112.76482a9d@pitrou.net> <20110329013756.99EB8D64A7@kimball.webabinitio.net> Message-ID: 2011/5/2 Georg Brandl : > On 02.05.2011 18:06, anatoly techtonik wrote: >> On Sun, May 1, 2011 at 7:31 PM, Georg Brandl wrote: >>> On 30.04.2011 16:53, anatoly techtonik wrote: >>>> On Tue, Mar 29, 2011 at 4:37 AM, R. David Murray wrote: >>>>> >>>>> The hardest part is debugging the TAL when you make a mistake, but >>>>> even that isn't a whole lot worse than any other templating language. >>>> >>>> How much in % is it worse than Django templating language? >>> >>> I'm just guessing here, but I'd say 47.256 %. >> >> That means switching to Django templates will make Roundup design >> plumbing work 47.256% more attractive for potential contributors. > > That's not true actually. > > It'll be 89.595 % more attractive. I don't understand why you're truncating to 3 digits. Let's be honest in that it will be sqrt(2)^(13e/2) % more attractive. -- Regards, Benjamin From tjreedy at udel.edu Mon May 2 22:49:54 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 02 May 2011 16:49:54 -0400 Subject: [Python-Dev] running/stepping python backwards In-Reply-To: References: Message-ID: <4DBF18F2.9040202@udel.edu> On 4/29/2011 10:13 PM, Adrian Johnston wrote: > This may seem like an odd question, but I?m intrigued by the idea of > using Python as a data definition language with ?undo? support. > > If I were to try and instrument the Python interpreter to be able to > step backwards, would that be an unduly difficult or inefficient thing > to do? The pydev list is for development of the next version of Python. Please direct your question to a more appropriate forum such as python-list. > (Please reply to me directly.) I did this time, but you should not expect that when posting to a public list. -- Terry Jan Reedy From martin at v.loewis.de Mon May 2 23:14:06 2011 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 02 May 2011 23:14:06 +0200 Subject: [Python-Dev] Windows 2000 Support In-Reply-To: References: Message-ID: <4DBF1E9E.5000006@v.loewis.de> Am 01.05.2011 22:51, schrieb Brian Curtin: > I'm currently writing a post about the process of removing OS/2 and VMS > support and thought about a discussion of Windows 2000 some time > back. http://mail.python.org/pipermail/python-dev/2010-March/098074.html makes > a proposal for beginning to walk away from 2000, but doesn't appear to > come to any conclusion. > > Was anything decided off the list? I don't see anything in PEP-11 and > don't see any changes in the installer made around Windows 2000. That's what you get for not following your own processes. It seems the discussion just stopped, with no action. I vaguely recall having made changes to the installer to produce a warning, but apparently never got to commit these changes. > If nothing was decided, should anything be done for 3.3? Most certainly. It seems we missed the chance of dropping support for W2k, so we still can't actively remove any code. However, I'd a) add it to PEP 11, and b) add a warning to the installer I stand by http://mail.python.org/pipermail/python-dev/2010-March/098101.html i.e. if there are patches that happen not to work on W2k, I'd accept them anyway - anybody interested in W2k would then have to provide fixes before 3.3rc1. So please go ahead and change PEP 11. While you are at it, also threaten to remove support for systems where the COMSPEC points to command.com (#2405). Regards, Martin From drsalists at gmail.com Mon May 2 23:19:38 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 2 May 2011 14:19:38 -0700 Subject: [Python-Dev] running/stepping python backwards In-Reply-To: <4DBF18F2.9040202@udel.edu> References: <4DBF18F2.9040202@udel.edu> Message-ID: On Mon, May 2, 2011 at 1:49 PM, Terry Reedy wrote: > > (Please reply to me directly.) > > I did this time, but you should not expect that when posting to a public > list. Actually, this is not only appropriate on some lists, on some lists one is actually strongly discouraged from doing anything else. EG: sun-managers, where replies are expected to be private, and the originator of the thread is expected to collect all (private) replies and summarize them, to keep the list traffic low and the S/N ratio high. -------------- next part -------------- An HTML attachment was scrubbed... URL: From barry at python.org Tue May 3 00:35:20 2011 From: barry at python.org (Barry Warsaw) Date: Mon, 2 May 2011 18:35:20 -0400 Subject: [Python-Dev] Python 2.6.7 schedule Message-ID: <20110502183520.1c9efdc0@neurotica.wooz.org> I'd like to make a Python 2.6.7 release candidate this Friday, May 6, with a final release scheduled for May 20. I've put these dates on the Python Release Schedule calendar. This will be a source-only security release. I see no release blockers for Python 2.6, so if you know of anything that must go into 2.6.7, please be sure there is a tracker issue for it, that 2.6 is marked as being affected, and with a release blocker priority. Cheers, -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From martin at v.loewis.de Tue May 3 01:09:42 2011 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 03 May 2011 01:09:42 +0200 Subject: [Python-Dev] Fwd: viewVC shows traceback on non utf-8 module markup In-Reply-To: <4DBB19A5.4010409@voidspace.org.uk> References: <4DBB19A5.4010409@voidspace.org.uk> Message-ID: <4DBF39B6.3050100@v.loewis.de> Am 29.04.2011 22:03, schrieb Michael Foord: > I know that the svn repo is now for legacy purposes only, but I doubt it > is intended that the online source browser should raise exceptions. It's certainly not. However, I don't plan to do anything about it, either (nor would I know that anybody else would). To view the source code of the file, use http://svn.python.org/view/python/trunk/Lib/heapq.py?view=co&content-type=text/plain Regards, Martin From brian.curtin at gmail.com Tue May 3 02:39:33 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Mon, 2 May 2011 19:39:33 -0500 Subject: [Python-Dev] Windows 2000 Support In-Reply-To: <4DBF1E9E.5000006@v.loewis.de> References: <4DBF1E9E.5000006@v.loewis.de> Message-ID: On Mon, May 2, 2011 at 16:14, "Martin v. L?wis" wrote: > Am 01.05.2011 22:51, schrieb Brian Curtin: > > I'm currently writing a post about the process of removing OS/2 and VMS > > support and thought about a discussion of Windows 2000 some time > > back. http://mail.python.org/pipermail/python-dev/2010-March/098074.htmlmakes > > a proposal for beginning to walk away from 2000, but doesn't appear to > > come to any conclusion. > > > > Was anything decided off the list? I don't see anything in PEP-11 and > > don't see any changes in the installer made around Windows 2000. > > That's what you get for not following your own processes. It seems the > discussion just stopped, with no action. I vaguely recall having made > changes to the installer to produce a warning, but apparently never > got to commit these changes. > > > If nothing was decided, should anything be done for 3.3? > > Most certainly. It seems we missed the chance of dropping support for > W2k, so we still can't actively remove any code. However, I'd > > a) add it to PEP 11, and > b) add a warning to the installer > > I stand by > > http://mail.python.org/pipermail/python-dev/2010-March/098101.html > > i.e. if there are patches that happen not to work on W2k, I'd accept > them anyway - anybody interested in W2k would then have to provide > fixes before 3.3rc1. > > So please go ahead and change PEP 11. While you are at it, also threaten > to remove support for systems where the COMSPEC points to command.com > (#2405). > Done and done - http://hg.python.org/peps/rev/b9390aa12855 I'll have a look at the installer and add some type of message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nadeem.vawda at gmail.com Tue May 3 16:22:27 2011 From: nadeem.vawda at gmail.com (Nadeem Vawda) Date: Tue, 3 May 2011 16:22:27 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: References: Message-ID: On Tue, May 3, 2011 at 3:19 PM, victor.stinner wrote: > +# Issue #10276 - check that inputs of 2 GB are handled correctly. > +# Be aware of issues #1202, #8650, #8651 and #10276 > +class ChecksumBigBufferTestCase(unittest.TestCase): > + ? ?int_max = 0x7FFFFFFF > + > + ? ?@unittest.skipUnless(mmap, "mmap() is not available.") > + ? ?def test_big_buffer(self): > + ? ? ? ?if sys.platform[:3] == 'win' or sys.platform == 'darwin': > + ? ? ? ? ? ?requires('largefile', > + ? ? ? ? ? ? ? ? ? ? 'test requires %s bytes and a long time to run' % > + ? ? ? ? ? ? ? ? ? ? str(self.int_max)) > + ? ? ? ?try: > + ? ? ? ? ? ?with open(TESTFN, "wb+") as f: > + ? ? ? ? ? ? ? ?f.seek(self.int_max-4) > + ? ? ? ? ? ? ? ?f.write("asdf") > + ? ? ? ? ? ? ? ?f.flush() > + ? ? ? ? ? ? ? ?try: > + ? ? ? ? ? ? ? ? ? ?m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) > + ? ? ? ? ? ? ? ? ? ?self.assertEqual(zlib.crc32(m), 0x709418e7) > + ? ? ? ? ? ? ? ? ? ?self.assertEqual(zlib.adler32(m), -2072837729) > + ? ? ? ? ? ? ? ?finally: > + ? ? ? ? ? ? ? ? ? ?m.close() > + ? ? ? ?except (IOError, OverflowError): > + ? ? ? ? ? ?raise unittest.SkipTest("filesystem doesn't have largefile support") > + ? ? ? ?finally: > + ? ? ? ? ? ?unlink(TESTFN) > + > + 0x7FFFFFFF is (2G-1) bytes. For a 2GB buffer, int_max should be 0x80000000. However, if you make this change, crc32() and adler32() raise OverflowErrors (see changeset a0681e7a6ded). This makes the test to erroneously report that the filesystem doesn't support large files. The assertEqual() tests should probably be changed to assertRaises(..., OverflowError). Also, the assignment to m needs to be moved outside of the inner try...finally block. If mmap() fails, the call to m.close() raises a new exception because m has not yet been bound. This seems to be causing failures on some of the 32-bit buildbots. As an aside, in this sort of situation is it better to just go and commit a fix myself, or is raising it on the mailing list first the right way to do things? Cheers, Nadeem From g.brandl at gmx.net Tue May 3 20:30:22 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Tue, 03 May 2011 20:30:22 +0200 Subject: [Python-Dev] Raise OSError or RuntimeError in the OS module? In-Reply-To: <201105021206.47384.victor.stinner@haypocalc.com> References: <201105021206.47384.victor.stinner@haypocalc.com> Message-ID: On 02.05.2011 12:06, Victor Stinner wrote: > Hi, > > I introduced recently the signal.pthread_sigmask() function (issue #8407). > pthread_sigmask() (the C function) returns an error code using errno codes. I > choosed to raise a RuntimeError using this error code, but I am not sure that > RuntimeError is the best choice. It is more an OS error than a runtime error: > should signal.pthread_sigmask() raise an OSError instead? > > signal.signal() raises a RuntimeError if setting the signal handler failed. > signal.siginterrupt() raises also a RuntimeError on error. > > signal.setitimer() and signal.getitimer() have their own exception class: > signal.ItimerError, raised on setimer() and getitimer() error. If it has an errno, it should be a subclass of EnvironmentError. Georg From brian.curtin at gmail.com Tue May 3 20:39:40 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 3 May 2011 13:39:40 -0500 Subject: [Python-Dev] Windows 2000 Support In-Reply-To: References: <4DBF1E9E.5000006@v.loewis.de> Message-ID: On Mon, May 2, 2011 at 19:39, Brian Curtin wrote: > On Mon, May 2, 2011 at 16:14, "Martin v. L?wis" wrote: > >> Am 01.05.2011 22:51, schrieb Brian Curtin: >> > I'm currently writing a post about the process of removing OS/2 and VMS >> > support and thought about a discussion of Windows 2000 some time >> > back. >> http://mail.python.org/pipermail/python-dev/2010-March/098074.html makes >> > a proposal for beginning to walk away from 2000, but doesn't appear to >> > come to any conclusion. >> > >> > Was anything decided off the list? I don't see anything in PEP-11 and >> > don't see any changes in the installer made around Windows 2000. >> >> That's what you get for not following your own processes. It seems the >> discussion just stopped, with no action. I vaguely recall having made >> changes to the installer to produce a warning, but apparently never >> got to commit these changes. >> >> > If nothing was decided, should anything be done for 3.3? >> >> Most certainly. It seems we missed the chance of dropping support for >> W2k, so we still can't actively remove any code. However, I'd >> >> a) add it to PEP 11, and >> b) add a warning to the installer >> >> I stand by >> >> http://mail.python.org/pipermail/python-dev/2010-March/098101.html >> >> i.e. if there are patches that happen not to work on W2k, I'd accept >> them anyway - anybody interested in W2k would then have to provide >> fixes before 3.3rc1. >> >> So please go ahead and change PEP 11. While you are at it, also threaten >> to remove support for systems where the COMSPEC points to command.com >> (#2405). >> > > Done and done - http://hg.python.org/peps/rev/b9390aa12855 > I'll have a look at the installer and add some type of message. > It turns out that you did make the change at some point for 2.7 being the last, but there was no corresponding 3.x version chosen. http://hg.python.org/cpython/rev/de53c52fbcbf changed the installer to list 3.3.0 as the last Windows 2000 release on the default branch. -------------- next part -------------- An HTML attachment was scrubbed... URL: From solipsis at pitrou.net Tue May 3 20:57:47 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 3 May 2011 20:57:47 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by References: Message-ID: <20110503205747.65a76522@pitrou.net> Hello, On Tue, 3 May 2011 16:22:27 +0200 Nadeem Vawda wrote: > > As an aside, in this sort of situation is it better to just go and > commit a fix myself, or is raising it on the mailing list first the > right way to do things? Raising it on the mailing-list makes it serve as a kind of post-commit review. Also, it ensures that the committer of the original patch understands the issues with it. cheers Antoine. From victor.stinner at haypocalc.com Tue May 3 22:38:43 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Tue, 03 May 2011 22:38:43 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: References: Message-ID: <1304455123.1971.5.camel@marge> Le mardi 03 mai 2011 ? 16:22 +0200, Nadeem Vawda a ?crit : > On Tue, May 3, 2011 at 3:19 PM, victor.stinner > wrote: > > +# Issue #10276 - check that inputs of 2 GB are handled correctly. > > +# Be aware of issues #1202, #8650, #8651 and #10276 > > +class ChecksumBigBufferTestCase(unittest.TestCase): > > + int_max = 0x7FFFFFFF > > + > > + @unittest.skipUnless(mmap, "mmap() is not available.") > > + def test_big_buffer(self): > > + if sys.platform[:3] == 'win' or sys.platform == 'darwin': > > + requires('largefile', > > + 'test requires %s bytes and a long time to run' % > > + str(self.int_max)) > > + try: > > + with open(TESTFN, "wb+") as f: > > + f.seek(self.int_max-4) > > + f.write("asdf") > > + f.flush() > > + try: > > + m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) > > + self.assertEqual(zlib.crc32(m), 0x709418e7) > > + self.assertEqual(zlib.adler32(m), -2072837729) > > + finally: > > + m.close() > > + except (IOError, OverflowError): > > + raise unittest.SkipTest("filesystem doesn't have largefile support") > > + finally: > > + unlink(TESTFN) > > + > > + > > 0x7FFFFFFF is (2G-1) bytes. For a 2GB buffer, int_max should be > 0x80000000. However, if you make this change, crc32() and adler32() > raise OverflowErrors (see changeset a0681e7a6ded). I don't want to check OverflowError: the test is supposed to compute the checksum of a buffer of 0x7FFFFFFF bytes, to check crc32() and adler32(). 0x7FFFFFFF is the biggest size supported by these functions (zlib doesn't use Py_ssize_t in Python 2.7). If you use a buffer of 0x80000000 bytes, you test PyArg_Parse*() functions, which have already a dedicated test (in test_xml_etree_c, it's not the best file to store such test...). > Also, the assignment to m needs to be moved outside of the inner > try...finally block. Yeah, I noticed this with buildbots: already fixed by dd58f8072216. > As an aside, in this sort of situation is it better to just go and > commit a fix myself, or is raising it on the mailing list first the > right way to do things? I'm not sure that you understood the test, so I think that it's better to ask first on IRC and/or the mailing list. Victor From nadeem.vawda at gmail.com Tue May 3 23:11:48 2011 From: nadeem.vawda at gmail.com (Nadeem Vawda) Date: Tue, 3 May 2011 23:11:48 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <1304455123.1971.5.camel@marge> References: <1304455123.1971.5.camel@marge> Message-ID: On Tue, May 3, 2011 at 10:38 PM, Victor Stinner wrote: > I don't want to check OverflowError: the test is supposed to compute the > checksum of a buffer of 0x7FFFFFFF bytes, to check crc32() and > adler32(). 0x7FFFFFFF is the biggest size supported by these functions > (zlib doesn't use Py_ssize_t in Python 2.7). I see. Since you mentioned issue 10276 in the commit message, I assumed you were testing for the underlying C functions truncating their arguments. It seems that I was mistaken. Sorry for the confusion. Cheers, Nadeem From victor.stinner at haypocalc.com Wed May 4 10:58:42 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Wed, 04 May 2011 10:58:42 +0200 Subject: [Python-Dev] The zombi thread of the Tcl library Message-ID: <1304499523.15694.11.camel@marge> Hi, I have a question: would it be possible to mask all signals in the Tcl thread? To understand the question, let's see the context... I'm working on signals, especially on pthread_sigmask(), and I'm trying to understand test_signal failures. test_signal fails if the _tkinter module is loaded, because _tkinter loads the Tcl library which create a thread waiting events in select(). For example, "python -m test test_pydoc test_signal" fails, because test_pydoc loads ALL Python modules. I opened an issue for test_pydoc: http://bugs.python.org/issue11995 _tkinter.c contains the following code: #if 0 /* This was not a good idea; through bindings, Tcl_Finalize() may invoke Python code but at that point the interpreter and thread state have already been destroyed! */ Py_AtExit(Tcl_Finalize); #endif Tcl_Finalize() exits the thread, but this function is never called in Python. Anyway, it is not possible to unload a module implemented in C. I would like to know if it would be possible to mask all signals in the Tcl thread, or if Tcl supports/uses signals. It is possible to mask all signals in the Tcl thread using: ---------- allsignals = range(1, signal.NSIG) oldmask = signal.pthread_sigmask(signal.SIG_BLOCK, allsignals) import _tkinter signal.pthread_sigmask(signal.SIG_SETMASK, oldmask) ---------- I'm not asking the question for test_signal: I have a patch fixing test_signal, even if the Tcl zombi thread is present (use pthread_kill() to send the signal directly to the main thread). (I wrote "zombi" thread because I was not aware that Tcl uses a thread, nor that test_pydoc loads all modules. The thread is valid, alive, and it's just a joke. The threads is more hidden than zombi.) Victor From marks at dcs.gla.ac.uk Wed May 4 11:08:33 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Wed, 04 May 2011 10:08:33 +0100 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <1304499523.15694.11.camel@marge> References: <1304499523.15694.11.camel@marge> Message-ID: <4DC11791.2000109@dcs.gla.ac.uk> Hi, The online documentation specifies which API function borrow and/or steal references (as opposed to the default behaviour). Yet, I cannot find this information anywhere in the source. Any clues as to where I should look? Cheers, Mark From amauryfa at gmail.com Wed May 4 11:35:19 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Wed, 4 May 2011 11:35:19 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <4DC11791.2000109@dcs.gla.ac.uk> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> Message-ID: Hi, Le mercredi 4 mai 2011, Mark Shannon a ?crit?: > The online documentation specifies which API function borrow and/or steal references (as opposed to the default behaviour). > Yet, I cannot find this information anywhere in the source. > > Any clues as to where I should look? It's in the file Doc/data/refcounts.dat in some custom format. -- Amaury -- Amaury Forgeot d'Arc From solipsis at pitrou.net Wed May 4 12:05:19 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 4 May 2011 12:05:19 +0200 Subject: [Python-Dev] The zombi thread of the Tcl library References: <1304499523.15694.11.camel@marge> Message-ID: <20110504120519.7a1bc105@pitrou.net> On Wed, 04 May 2011 10:58:42 +0200 Victor Stinner wrote: > > Tcl_Finalize() exits the thread, but this function is never called in > Python. Anyway, it is not possible to unload a module implemented in C. You could expose Tcl_Finalize() for debug purposes and call it in test_signal. Regards Antoine. From victor.stinner at haypocalc.com Wed May 4 13:54:20 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Wed, 04 May 2011 13:54:20 +0200 Subject: [Python-Dev] The zombi thread of the Tcl library In-Reply-To: <20110504120519.7a1bc105@pitrou.net> References: <1304499523.15694.11.camel@marge> <20110504120519.7a1bc105@pitrou.net> Message-ID: <1304510060.15694.13.camel@marge> Le mercredi 04 mai 2011 ? 12:05 +0200, Antoine Pitrou a ?crit : > On Wed, 04 May 2011 10:58:42 +0200 > Victor Stinner wrote: > > > > Tcl_Finalize() exits the thread, but this function is never called in > > Python. Anyway, it is not possible to unload a module implemented in C. > > You could expose Tcl_Finalize() for debug purposes and call it in > test_signal. Good idea. I opened an issue with a patch implementing Tcl_Finalize(): http://bugs.python.org/issue11998 I also added a workaround _tkinter border effect in test_signal. Buildbots look to be happy. Victor From ncoghlan at gmail.com Wed May 4 19:01:58 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Thu, 5 May 2011 03:01:58 +1000 Subject: [Python-Dev] New interest areas in Experts Index Message-ID: I just added two new interest areas in the Expert's Index [1] context managers: for any issues relating to proposals to add context management capabilities to objects in the stdlib, triagers should feel free to add me to the nosy list test coverage: this is specifically for anyone willing to help review and commit test coverage improvement patches (rather than the more general "testing" interest area that was already present) Cheers, Nick. [1] http://docs.python.org/devguide/experts -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From solipsis at pitrou.net Wed May 4 21:35:11 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Wed, 4 May 2011 21:35:11 +0200 Subject: [Python-Dev] cpython (2.7): Issue #11277: test_zlib tests a buffer of 1 GB on 32 bits References: Message-ID: <20110504213511.07e9f2bf@pitrou.net> On Wed, 04 May 2011 21:27:50 +0200 victor.stinner wrote: > http://hg.python.org/cpython/rev/7f3cab59ef3e > changeset: 69834:7f3cab59ef3e > branch: 2.7 > parent: 69827:affec521b330 > user: Victor Stinner > date: Wed May 04 21:27:39 2011 +0200 > summary: > Issue #11277: test_zlib tests a buffer of 1 GB on 32 bits What's the point? The issue with 2GB or 4GB buffers is that they cross the potential limit of a machine type (a signed or unsigned integer). I don't see any benefit in testing a 1GB buffer; the test could probably be removed instead. Regards Antoine. From greg.ewing at canterbury.ac.nz Thu May 5 00:04:51 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Thu, 05 May 2011 10:04:51 +1200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <4DC11791.2000109@dcs.gla.ac.uk> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> Message-ID: <4DC1CD83.3000603@canterbury.ac.nz> Mark Shannon wrote: > The online documentation specifies which API function borrow and/or > steal references (as opposed to the default behaviour). > Yet, I cannot find this information anywhere in the source. There are comments in some places, e.g. in listobject.h: *** WARNING *** PyList_SetItem does not increment the new item's reference count, but does decrement the reference count of the item it replaces, if not nil. It does *decrement* the reference count if it is *not* inserted in the list. Similarly, PyList_GetItem does not increment the returned item's reference count. If you're looking for evidence in the actual code, there's nothing particular to look for -- it's implicit in the way the function works overall. -- Greg From greg.ewing at canterbury.ac.nz Thu May 5 00:23:01 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Thu, 05 May 2011 10:23:01 +1200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> Message-ID: <4DC1D1C5.9010507@canterbury.ac.nz> Amaury Forgeot d'Arc wrote: > It's in the file Doc/data/refcounts.dat > in some custom format. However, it doesn't seem to quite convey the same information. It lists the "refcount effect" on each parameter, but translating that into the notion of borrowed or stolen references seems to require knowledge of what the function does. For example, PyDict_SetItem has: PyDict_SetItem:PyObject*:p:0: PyDict_SetItem:PyObject*:key:+1: PyDict_SetItem:PyObject*:val:+1: All of these parameters take borrowed references, but the key and val get incremented because they're being stored in the dict. So this file appears to be of limited usefulness. -- Greg From ethan at stoneleaf.us Thu May 5 00:40:42 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 04 May 2011 15:40:42 -0700 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <1304455123.1971.5.camel@marge> References: <1304455123.1971.5.camel@marge> Message-ID: <4DC1D5EA.7060608@stoneleaf.us> Victor Stinner wrote: > Le mardi 03 mai 2011 ? 16:22 +0200, Nadeem Vawda a ?crit : >> On Tue, May 3, 2011 at 3:19 PM, victor.stinner >> wrote: >>> +# Issue #10276 - check that inputs of 2 GB are handled correctly. >>> +# Be aware of issues #1202, #8650, #8651 and #10276 >>> +class ChecksumBigBufferTestCase(unittest.TestCase): >>> + int_max = 0x7FFFFFFF >>> + >>> + @unittest.skipUnless(mmap, "mmap() is not available.") >>> + def test_big_buffer(self): >>> + if sys.platform[:3] == 'win' or sys.platform == 'darwin': >>> + requires('largefile', >>> + 'test requires %s bytes and a long time to run' % >>> + str(self.int_max)) >>> + try: >>> + with open(TESTFN, "wb+") as f: >>> + f.seek(self.int_max-4) >>> + f.write("asdf") >>> + f.flush() >>> + try: >>> + m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) >>> + self.assertEqual(zlib.crc32(m), 0x709418e7) >>> + self.assertEqual(zlib.adler32(m), -2072837729) >>> + finally: >>> + m.close() >>> + except (IOError, OverflowError): >>> + raise unittest.SkipTest("filesystem doesn't have largefile support") >>> + finally: >>> + unlink(TESTFN) >>> + >>> + >> 0x7FFFFFFF is (2G-1) bytes. For a 2GB buffer, int_max should be >> 0x80000000. However, if you make this change, crc32() and adler32() >> raise OverflowErrors (see changeset a0681e7a6ded). > > I don't want to check OverflowError: the test is supposed to compute the > checksum of a buffer of 0x7FFFFFFF bytes The comment says 'check that inputs of 2 GB are handled correctly' but the file created is 1 byte short of 2Gb. Is the test wrong, or just wrongly commented? Or am I not understanding? ~Ethan~ From victor.stinner at haypocalc.com Thu May 5 11:33:27 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Thu, 05 May 2011 11:33:27 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <4DC1D5EA.7060608@stoneleaf.us> References: <1304455123.1971.5.camel@marge> <4DC1D5EA.7060608@stoneleaf.us> Message-ID: <1304588007.22418.7.camel@marge> Le mercredi 04 mai 2011 ? 15:40 -0700, Ethan Furman a ?crit : > Victor Stinner wrote: > > Le mardi 03 mai 2011 ? 16:22 +0200, Nadeem Vawda a ?crit : > >> On Tue, May 3, 2011 at 3:19 PM, victor.stinner > >> wrote: > >>> +# Issue #10276 - check that inputs of 2 GB are handled correctly. > >>> +# Be aware of issues #1202, #8650, #8651 and #10276 > >>> +class ChecksumBigBufferTestCase(unittest.TestCase): > >>> + int_max = 0x7FFFFFFF > >>> + > >>> + @unittest.skipUnless(mmap, "mmap() is not available.") > >>> + def test_big_buffer(self): > >>> + if sys.platform[:3] == 'win' or sys.platform == 'darwin': > >>> + requires('largefile', > >>> + 'test requires %s bytes and a long time to run' % > >>> + str(self.int_max)) > >>> + try: > >>> + with open(TESTFN, "wb+") as f: > >>> + f.seek(self.int_max-4) > >>> + f.write("asdf") > >>> + f.flush() > >>> + try: > >>> + m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) > >>> + self.assertEqual(zlib.crc32(m), 0x709418e7) > >>> + self.assertEqual(zlib.adler32(m), -2072837729) > >>> + finally: > >>> + m.close() > >>> + except (IOError, OverflowError): > >>> + raise unittest.SkipTest("filesystem doesn't have largefile support") > >>> + finally: > >>> + unlink(TESTFN) > >>> + > >>> + > >> 0x7FFFFFFF is (2G-1) bytes. For a 2GB buffer, int_max should be > >> 0x80000000. However, if you make this change, crc32() and adler32() > >> raise OverflowErrors (see changeset a0681e7a6ded). > > > > I don't want to check OverflowError: the test is supposed to compute the > > checksum of a buffer of 0x7FFFFFFF bytes > > The comment says 'check that inputs of 2 GB are handled correctly' but > the file created is 1 byte short of 2Gb. Is the test wrong, or just > wrongly commented? Or am I not understanding? If you write a byte after 2 GB of zeros, the file size is 2 GB+the few bytes. This trick is to create quickly a large file: some OSes support sparse files, zeros are not written on disk. But on Mac OS X and Windows, you really write 2 GB+some bytes. Victor From nadeem.vawda at gmail.com Thu May 5 11:43:19 2011 From: nadeem.vawda at gmail.com (Nadeem Vawda) Date: Thu, 5 May 2011 11:43:19 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <1304588007.22418.7.camel@marge> References: <1304455123.1971.5.camel@marge> <4DC1D5EA.7060608@stoneleaf.us> <1304588007.22418.7.camel@marge> Message-ID: On Thu, May 5, 2011 at 11:33 AM, Victor Stinner wrote: > Le mercredi 04 mai 2011 ? 15:40 -0700, Ethan Furman a ?crit : >> The comment says 'check that inputs of 2 GB are handled correctly' but >> the file created is 1 byte short of 2Gb. ?Is the test wrong, or just >> wrongly commented? ?Or am I not understanding? > > If you write a byte after 2 GB of zeros, the file size is 2 GB+the few > bytes. This trick is to create quickly a large file: some OSes support > sparse files, zeros are not written on disk. But on Mac OS X and > Windows, you really write 2 GB+some bytes. Ethan's point is that 0x7FFFFFFF is not 2GB - it is (2G-1) bytes. So the test and the preceding comment are inconsistent. From p.f.moore at gmail.com Thu May 5 11:53:59 2011 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 5 May 2011 10:53:59 +0100 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <1304588007.22418.7.camel@marge> References: <1304455123.1971.5.camel@marge> <4DC1D5EA.7060608@stoneleaf.us> <1304588007.22418.7.camel@marge> Message-ID: On 5 May 2011 10:33, Victor Stinner wrote: > If you write a byte after 2 GB of zeros, the file size is 2 GB+the few > bytes. This trick is to create quickly a large file: some OSes support > sparse files, zeros are not written on disk. But on Mac OS X and > Windows, you really write 2 GB+some bytes. FWIW, on Windows you can create sparse files, using DeviceIoControl(FILE_SET_SPARSE). It's probably too messy to be worth it for this case, though... Paul From giuott at gmail.com Thu May 5 12:14:34 2011 From: giuott at gmail.com (Giuseppe Ottaviano) Date: Thu, 5 May 2011 11:14:34 +0100 Subject: [Python-Dev] What if replacing items in a dictionary returns the new dictionary? In-Reply-To: References: <20110429143406.GA441@iskra.aviel.ru> Message-ID: On Fri, Apr 29, 2011 at 4:05 PM, Roy Hyunjin Han wrote: >> ? You can implement this in your own subclass of dict, no? > > Yes, I just thought it would be convenient to have in the language > itself, but the responses to my post seem to indicate that [not > returning the updated object] is an intended language feature for > mutable types like dict or list. In general nothing stops you to use a proxy object that returns itself after each method call, something like class using(object): def __init__(self, obj): self._wrappee = obj def unwrap(self): return self._wrappee def __getattr__(self, attr): def wrapper(*args, **kwargs): getattr(self._wrappee, attr)(*args, **kwargs) return self return wrapper d = dict() print using(d).update(dict(a=1)).update(dict(b=2)).unwrap() # prints {'a': 1, 'b': 2} l = list() print using(l).append(1).append(2).unwrap() # prints [1, 2] From amauryfa at gmail.com Thu May 5 12:38:32 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Thu, 5 May 2011 12:38:32 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <4DC1D1C5.9010507@canterbury.ac.nz> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: Hi, Le jeudi 5 mai 2011, Greg Ewing a ?crit?: > Amaury Forgeot d'Arc wrote: > > > It's in the file Doc/data/refcounts.dat > in some custom format. > > > However, it doesn't seem to quite convey the same information. > It lists the "refcount effect" on each parameter, but translating > that into the notion of borrowed or stolen references seems > to require knowledge of what the function does. > > For example, PyDict_SetItem has: > > PyDict_SetItem:PyObject*:p:0: > PyDict_SetItem:PyObject*:key:+1: > PyDict_SetItem:PyObject*:val:+1: > > All of these parameters take borrowed references, but the > key and val get incremented because they're being stored > in the dict. This is not always true, for example when the item is already present in the dict. It's not important to know what the function does to the object, Only the action on the reference is relevant. > > So this file appears to be of limited usefulness. -- Amaury -- Amaury Forgeot d'Arc From ethan at stoneleaf.us Thu May 5 14:07:04 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 05 May 2011 05:07:04 -0700 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <1304588007.22418.7.camel@marge> References: <1304455123.1971.5.camel@marge> <4DC1D5EA.7060608@stoneleaf.us> <1304588007.22418.7.camel@marge> Message-ID: <4DC292E8.9010904@stoneleaf.us> Victor Stinner wrote: > Le mercredi 04 mai 2011 ? 15:40 -0700, Ethan Furman a ?crit : >> Victor Stinner wrote: >>> Le mardi 03 mai 2011 ? 16:22 +0200, Nadeem Vawda a ?crit : >>>> On Tue, May 3, 2011 at 3:19 PM, victor.stinner >>>> wrote: >>>>> >>>>> + int_max = 0x7FFFFFFF >>>>> >>>>> + with open(TESTFN, "wb+") as f: >>>>> + f.seek(self.int_max-4) >>>>> + f.write("asdf") >>>>> + f.flush() >>>> >>>> 0x7FFFFFFF is (2G-1) bytes. For a 2GB buffer, int_max should be >>>> 0x80000000. However, if you make this change, crc32() and adler32() >>>> raise OverflowErrors (see changeset a0681e7a6ded). >>> >>> I don't want to check OverflowError: the test is supposed to compute the >>> checksum of a buffer of 0x7FFFFFFF bytes >> >> The comment says 'check that inputs of 2 GB are handled correctly' but >> the file created is 1 byte short of 2Gb. Is the test wrong, or just >> wrongly commented? Or am I not understanding? > > If you write a byte after 2 GB of zeros, the file size is 2 GB+the few > bytes. This trick is to create quickly a large file: some OSes support > sparse files, zeros are not written on disk. But on Mac OS X and > Windows, you really write 2 GB+some bytes. True, but that's not what's happening -- four bytes are being written at int_max - 4, and int_max is one less that 2GB; hence the resulting file is one less than 2GB. ~Ethan~ From victor.stinner at haypocalc.com Thu May 5 14:27:43 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Thu, 05 May 2011 14:27:43 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <4DC292E8.9010904@stoneleaf.us> References: <1304455123.1971.5.camel@marge> <4DC1D5EA.7060608@stoneleaf.us> <1304588007.22418.7.camel@marge> <4DC292E8.9010904@stoneleaf.us> Message-ID: <1304598463.27042.0.camel@marge> Le jeudi 05 mai 2011 ? 05:07 -0700, Ethan Furman a ?crit : > ... hence the resulting file is one less than 2GB. Yep, it's 0x7FFFFFFF because it's INT_MAX, the biggest value storable in an int. The zlib module stores the buffer size into an int in Python 2.7 (and Py_ssize_t in Python 3.3). Victor From ethan at stoneleaf.us Thu May 5 17:17:27 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 05 May 2011 08:17:27 -0700 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #10276: test_zlib checks that inputs of 2 GB are handled correctly by In-Reply-To: <1304598463.27042.0.camel@marge> References: <1304455123.1971.5.camel@marge> <4DC1D5EA.7060608@stoneleaf.us> <1304588007.22418.7.camel@marge> <4DC292E8.9010904@stoneleaf.us> <1304598463.27042.0.camel@marge> Message-ID: <4DC2BF87.40100@stoneleaf.us> Victor Stinner wrote: > Le jeudi 05 mai 2011 ? 05:07 -0700, Ethan Furman a ?crit : >> >> ... hence the resulting file is one less than 2GB. > > Yep, it's 0x7FFFFFFF because it's INT_MAX, the biggest value storable in > an int. The zlib module stores the buffer size into an int in Python 2.7 > (and Py_ssize_t in Python 3.3). So we are agreed that the file is not, in fact, 2GB in size... > On Tue, May 3, 2011 at 3:19 PM, victor.stinner > wrote: >> +# Issue #10276 - check that inputs of 2 GB are handled correctly. >> +# Be aware of issues #1202, #8650, #8651 and #10276 So why do the comments say we are testing a 2GB input? ~Ethan~ From starsareblueandfaraway at gmail.com Thu May 5 16:37:04 2011 From: starsareblueandfaraway at gmail.com (Roy Hyunjin Han) Date: Thu, 5 May 2011 10:37:04 -0400 Subject: [Python-Dev] What if replacing items in a dictionary returns the new dictionary? In-Reply-To: References: <20110429143406.GA441@iskra.aviel.ru> Message-ID: >> 2011/4/29 Roy Hyunjin Han : >> It would be convenient if replacing items in a dictionary returns the >> new dictionary, in a manner analogous to str.replace(). What do you >> think? >> >> # Current behavior >> x = {'key1': 1} >> x.update(key1=3) == None >> x == {'key1': 3} # Original variable has changed >> >> # Possible behavior >> x = {'key1': 1} >> x.replace(key1=3) == {'key1': 3} >> x == {'key1': 1} # Original variable is unchanged >> > 2011/5/5 Giuseppe Ottaviano : > In general nothing stops you to use a proxy object that returns itself > after each method call, something like > > class using(object): > def __init__(self, obj): > self._wrappee = obj > > def unwrap(self): > return self._wrappee > > def __getattr__(self, attr): > def wrapper(*args, **kwargs): > getattr(self._wrappee, attr)(*args, **kwargs) > return self > return wrapper > > > d = dict() > print using(d).update(dict(a=1)).update(dict(b=2)).unwrap() > # prints {'a': 1, 'b': 2} > l = list() > print using(l).append(1).append(2).unwrap() > # prints [1, 2] Cool! I never thought of that. That's a great snippet. I'll forward this to the python-ideas list. I don't think the python-dev people want this discussion to continue on their mailing list. From guido at python.org Thu May 5 19:00:54 2011 From: guido at python.org (Guido van Rossum) Date: Thu, 5 May 2011 10:00:54 -0700 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: On Thu, May 5, 2011 at 3:38 AM, Amaury Forgeot d'Arc wrote: > Hi, > > Le jeudi 5 mai 2011, Greg Ewing a ?crit?: >> Amaury Forgeot d'Arc wrote: >> >> >> It's in the file Doc/data/refcounts.dat >> in some custom format. >> >> >> However, it doesn't seem to quite convey the same information. >> It lists the "refcount effect" on each parameter, but translating >> that into the notion of borrowed or stolen references seems >> to require knowledge of what the function does. >> >> For example, PyDict_SetItem has: >> >> PyDict_SetItem:PyObject*:p:0: >> PyDict_SetItem:PyObject*:key:+1: >> PyDict_SetItem:PyObject*:val:+1: >> >> All of these parameters take borrowed references, but the >> key and val get incremented because they're being stored >> in the dict. > > This is not always true, for example when the item is already present > in the dict. > It's not important to know what the function does to the object, > Only the action on the reference is relevant. > >> >> So this file appears to be of limited usefulness. Seems you're in agreement with this. IMO when references are borrowed it is not very interesting. The interesting thing is when calling a function *steals* a reference. The other important thing to know is whether the caller ends up owning the return value (if it is an object) or not. I *think* you can tell the latter from the +1 for the return value; but the former (whether it steals a reference) is unclear from the data given. There's even an XXX comment about this in the file: # XXX NOTE: the 0/+1/-1 refcount information for arguments is # confusing! Much more useful would be to indicate whether the # function "steals" a reference to the argument or not. Take for # example PyList_SetItem(list, i, item). This lists as a 0 change for # both the list and the item arguments. However, in fact it steals a # reference to the item argument! -- --Guido van Rossum (python.org/~guido) From amauryfa at gmail.com Thu May 5 19:17:30 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Thu, 5 May 2011 19:17:30 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: 2011/5/5 Guido van Rossum : > Seems you're in agreement with this. IMO when references are borrowed > it is not very interesting. The interesting thing is when calling a > function *steals* a reference. The other important thing to know is > whether the caller ends up owning the return value (if it is an > object) or not. I *think* you can tell the latter from the +1 for the > return value; but the former (whether it steals a reference) is > unclear from the data given. There's even an XXX comment about this in > the file: > > # XXX NOTE: the 0/+1/-1 refcount information for arguments is > # confusing! ?Much more useful would be to indicate whether the > # function "steals" a reference to the argument or not. ?Take for > # example PyList_SetItem(list, i, item). ?This lists as a 0 change for > # both the list and the item arguments. ?However, in fact it steals a > # reference to the item argument! Should we change this file then? And only list functions that don't follow the usual conventions. But I'm sure that there are external tools which already use refcounts.dat in its present format. -- Amaury Forgeot d'Arc From guido at python.org Thu May 5 19:18:54 2011 From: guido at python.org (Guido van Rossum) Date: Thu, 5 May 2011 10:18:54 -0700 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: On Thu, May 5, 2011 at 10:17 AM, Amaury Forgeot d'Arc wrote: > 2011/5/5 Guido van Rossum : >> Seems you're in agreement with this. IMO when references are borrowed >> it is not very interesting. The interesting thing is when calling a >> function *steals* a reference. The other important thing to know is >> whether the caller ends up owning the return value (if it is an >> object) or not. I *think* you can tell the latter from the +1 for the >> return value; but the former (whether it steals a reference) is >> unclear from the data given. There's even an XXX comment about this in >> the file: >> >> # XXX NOTE: the 0/+1/-1 refcount information for arguments is >> # confusing! ?Much more useful would be to indicate whether the >> # function "steals" a reference to the argument or not. ?Take for >> # example PyList_SetItem(list, i, item). ?This lists as a 0 change for >> # both the list and the item arguments. ?However, in fact it steals a >> # reference to the item argument! > > Should we change this file then? > And only list functions that don't follow the usual conventions. > > But I'm sure that there are external tools which already use refcounts.dat > in its present format. Maybe we can *add* a column with the desired information? -- --Guido van Rossum (python.org/~guido) From g.brandl at gmx.net Thu May 5 20:08:51 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Thu, 05 May 2011 20:08:51 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: On 05.05.2011 19:00, Guido van Rossum wrote: > On Thu, May 5, 2011 at 3:38 AM, Amaury Forgeot d'Arc wrote: >> Hi, >> >> Le jeudi 5 mai 2011, Greg Ewing a ?crit : >>> Amaury Forgeot d'Arc wrote: >>> >>> >>> It's in the file Doc/data/refcounts.dat >>> in some custom format. >>> >>> >>> However, it doesn't seem to quite convey the same information. >>> It lists the "refcount effect" on each parameter, but translating >>> that into the notion of borrowed or stolen references seems >>> to require knowledge of what the function does. >>> >>> For example, PyDict_SetItem has: >>> >>> PyDict_SetItem:PyObject*:p:0: >>> PyDict_SetItem:PyObject*:key:+1: >>> PyDict_SetItem:PyObject*:val:+1: >>> >>> All of these parameters take borrowed references, but the >>> key and val get incremented because they're being stored >>> in the dict. >> >> This is not always true, for example when the item is already present >> in the dict. >> It's not important to know what the function does to the object, >> Only the action on the reference is relevant. >> >>> >>> So this file appears to be of limited usefulness. > > Seems you're in agreement with this. IMO when references are borrowed > it is not very interesting. The interesting thing is when calling a > function *steals* a reference. The other important thing to know is > whether the caller ends up owning the return value (if it is an > object) or not. I *think* you can tell the latter from the +1 for the > return value; but the former (whether it steals a reference) is > unclear from the data given. There's even an XXX comment about this in > the file: > > # XXX NOTE: the 0/+1/-1 refcount information for arguments is > # confusing! Much more useful would be to indicate whether the > # function "steals" a reference to the argument or not. Take for > # example PyList_SetItem(list, i, item). This lists as a 0 change for > # both the list and the item arguments. However, in fact it steals a > # reference to the item argument! We're not using the information about arguments anyway in the doc build. So we're free to change the file to list only return types, and parameters in the event of stolen references. Georg From solipsis at pitrou.net Thu May 5 20:09:30 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 5 May 2011 20:09:30 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: <20110505200930.0412d200@pitrou.net> On Thu, 5 May 2011 19:17:30 +0200 "Amaury Forgeot d'Arc" wrote: > 2011/5/5 Guido van Rossum : > > Seems you're in agreement with this. IMO when references are borrowed > > it is not very interesting. The interesting thing is when calling a > > function *steals* a reference. The other important thing to know is > > whether the caller ends up owning the return value (if it is an > > object) or not. I *think* you can tell the latter from the +1 for the > > return value; but the former (whether it steals a reference) is > > unclear from the data given. There's even an XXX comment about this in > > the file: > > > > # XXX NOTE: the 0/+1/-1 refcount information for arguments is > > # confusing! ?Much more useful would be to indicate whether the > > # function "steals" a reference to the argument or not. ?Take for > > # example PyList_SetItem(list, i, item). ?This lists as a 0 change for > > # both the list and the item arguments. ?However, in fact it steals a > > # reference to the item argument! > > Should we change this file then? > And only list functions that don't follow the usual conventions. +1 Regards Antoine. From raymond.hettinger at gmail.com Thu May 5 20:12:55 2011 From: raymond.hettinger at gmail.com (Raymond Hettinger) Date: Thu, 5 May 2011 11:12:55 -0700 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: On May 5, 2011, at 10:18 AM, Guido van Rossum wrote: > On Thu, May 5, 2011 at 10:17 AM, Amaury Forgeot d'Arc > wrote: >> 2011/5/5 Guido van Rossum : >>> Seems you're in agreement with this. IMO when references are borrowed >>> it is not very interesting. The interesting thing is when calling a >>> function *steals* a reference. The other important thing to know is >>> whether the caller ends up owning the return value (if it is an >>> object) or not. I *think* you can tell the latter from the +1 for the >>> return value; but the former (whether it steals a reference) is >>> unclear from the data given. There's even an XXX comment about this in >>> the file: >>> >>> # XXX NOTE: the 0/+1/-1 refcount information for arguments is >>> # confusing! Much more useful would be to indicate whether the >>> # function "steals" a reference to the argument or not. Take for >>> # example PyList_SetItem(list, i, item). This lists as a 0 change for >>> # both the list and the item arguments. However, in fact it steals a >>> # reference to the item argument! >> >> Should we change this file then? >> And only list functions that don't follow the usual conventions. >> >> But I'm sure that there are external tools which already use refcounts.dat >> in its present format. > > Maybe we can *add* a column with the desired information? +1 Raymond From benjamin at python.org Thu May 5 20:41:50 2011 From: benjamin at python.org (Benjamin Peterson) Date: Thu, 5 May 2011 13:41:50 -0500 Subject: [Python-Dev] [Python-checkins] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: References: Message-ID: 2011/5/5 raymond.hettinger : > http://hg.python.org/cpython/rev/1a56775c6e54 > changeset: ? 69857:1a56775c6e54 > branch: ? ? ?3.2 > parent: ? ? ?69855:97a4855202b8 > user: ? ? ? ?Raymond Hettinger > date: ? ? ? ?Thu May 05 11:35:50 2011 -0700 > summary: > ?Avoid codec spelling issues by just using the utf-8 default. Out of curiosity, what is the issue? > > files: > ?Lib/random.py | ?2 +- > ?1 files changed, 1 insertions(+), 1 deletions(-) > > > diff --git a/Lib/random.py b/Lib/random.py > --- a/Lib/random.py > +++ b/Lib/random.py > @@ -114,7 +114,7 @@ > ? ? ? ? if version == 2: > ? ? ? ? ? ? if isinstance(a, (str, bytes, bytearray)): > ? ? ? ? ? ? ? ? if isinstance(a, str): > - ? ? ? ? ? ? ? ? ? ?a = a.encode("utf8") > + ? ? ? ? ? ? ? ? ? ?a = a.encode() -- Regards, Benjamin From solipsis at pitrou.net Thu May 5 20:44:04 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 5 May 2011 20:44:04 +0200 Subject: [Python-Dev] cpython (merge 3.2 -> default): Avoid codec spelling issues by just using the utf-8 default. References: Message-ID: <20110505204404.5cfa02f2@pitrou.net> On Thu, 05 May 2011 20:38:27 +0200 raymond.hettinger wrote: > http://hg.python.org/cpython/rev/2bc784057226 > changeset: 69858:2bc784057226 > parent: 69856:b06ad8458b32 > parent: 69857:1a56775c6e54 > user: Raymond Hettinger > date: Thu May 05 11:38:06 2011 -0700 > summary: > Avoid codec spelling issues by just using the utf-8 default. > > files: > Lib/random.py | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > > diff --git a/Lib/random.py b/Lib/random.py > --- a/Lib/random.py > +++ b/Lib/random.py > @@ -114,7 +114,7 @@ > if version == 2: > if isinstance(a, (str, bytes, bytearray)): > if isinstance(a, str): > - a = a.encode("utf-8") > + a = a.encode() Isn't explicit better than implicit? By reading the new code it is not obvious that any thought was given to the choice of a codec, while stating "utf-8" explicitly hints that a decision was made. (also, I don't understand the spelling issue: "utf-8" just works) Regards Antoine. From alexander.belopolsky at gmail.com Thu May 5 21:01:29 2011 From: alexander.belopolsky at gmail.com (Alexander Belopolsky) Date: Thu, 5 May 2011 15:01:29 -0400 Subject: [Python-Dev] cpython (merge 3.2 -> default): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: <20110505204404.5cfa02f2@pitrou.net> References: <20110505204404.5cfa02f2@pitrou.net> Message-ID: On Thu, May 5, 2011 at 2:44 PM, Antoine Pitrou wrote: .. > (also, I don't understand the spelling issue: "utf-8" just works) This is probably referring to the fact that while encode() accepts many spelling variants, some are short-circuited in C code while others require codec lookup implemented in python. From solipsis at pitrou.net Thu May 5 21:07:07 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 05 May 2011 21:07:07 +0200 Subject: [Python-Dev] cpython (merge 3.2 -> default): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: References: <20110505204404.5cfa02f2@pitrou.net> Message-ID: <1304622427.3564.12.camel@localhost.localdomain> Le jeudi 05 mai 2011 ? 15:01 -0400, Alexander Belopolsky a ?crit : > On Thu, May 5, 2011 at 2:44 PM, Antoine Pitrou wrote: > .. > > (also, I don't understand the spelling issue: "utf-8" just works) > > This is probably referring to the fact that while encode() accepts > many spelling variants, some are short-circuited in C code while > others require codec lookup implemented in python. This sounds like a bug to fix (isn't it fixed it already, btw?) rather than add hackish workarounds for in stdlib code. Regards Antoine. From benjamin at python.org Thu May 5 21:13:34 2011 From: benjamin at python.org (Benjamin Peterson) Date: Thu, 5 May 2011 14:13:34 -0500 Subject: [Python-Dev] cpython (merge 3.2 -> default): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: References: <20110505204404.5cfa02f2@pitrou.net> Message-ID: 2011/5/5 Alexander Belopolsky : > On Thu, May 5, 2011 at 2:44 PM, Antoine Pitrou wrote: > .. >> (also, I don't understand the spelling issue: "utf-8" just works) > > This is probably referring to the fact that while encode() accepts > many spelling variants, some are short-circuited in C code while > others require codec lookup implemented in python. Isn't it cached after the first run? If this is the reasoning, I find it hard to believe that seed() is a large bottleneck in random. -- Regards, Benjamin From g.brandl at gmx.net Thu May 5 22:45:13 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Thu, 05 May 2011 22:45:13 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: On 05.05.2011 19:17, Amaury Forgeot d'Arc wrote: > 2011/5/5 Guido van Rossum : >> Seems you're in agreement with this. IMO when references are borrowed >> it is not very interesting. The interesting thing is when calling a >> function *steals* a reference. The other important thing to know is >> whether the caller ends up owning the return value (if it is an >> object) or not. I *think* you can tell the latter from the +1 for the >> return value; but the former (whether it steals a reference) is >> unclear from the data given. There's even an XXX comment about this in >> the file: >> >> # XXX NOTE: the 0/+1/-1 refcount information for arguments is >> # confusing! Much more useful would be to indicate whether the >> # function "steals" a reference to the argument or not. Take for >> # example PyList_SetItem(list, i, item). This lists as a 0 change for >> # both the list and the item arguments. However, in fact it steals a >> # reference to the item argument! > > Should we change this file then? > And only list functions that don't follow the usual conventions. > > But I'm sure that there are external tools which already use refcounts.dat > in its present format. I doubt it. And even if there are, the information in there is in parts highly outdated (because the docs don't use parameter info), and large numbers of functions are missing. Let's remove the cruft, and only keep interesting info. This will also make the file much more manageable. Georg From raymond.hettinger at gmail.com Thu May 5 22:55:07 2011 From: raymond.hettinger at gmail.com (Raymond Hettinger) Date: Thu, 5 May 2011 13:55:07 -0700 Subject: [Python-Dev] [Python-checkins] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: References: Message-ID: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> On May 5, 2011, at 11:41 AM, Benjamin Peterson wrote: > 2011/5/5 raymond.hettinger : >> http://hg.python.org/cpython/rev/1a56775c6e54 >> changeset: 69857:1a56775c6e54 >> branch: 3.2 >> parent: 69855:97a4855202b8 >> user: Raymond Hettinger >> date: Thu May 05 11:35:50 2011 -0700 >> summary: >> Avoid codec spelling issues by just using the utf-8 default. > > Out of curiosity, what is the issue? IIRC, the performance depended on how your spelled-it. I believe that is why the spelling got changed in Py3.3. Either way, the code is simpler by just using the default. Raymond From mal at egenix.com Fri May 6 00:32:59 2011 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 06 May 2011 00:32:59 +0200 Subject: [Python-Dev] [Python-checkins] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> References: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> Message-ID: <4DC3259B.5020804@egenix.com> Raymond Hettinger wrote: > > On May 5, 2011, at 11:41 AM, Benjamin Peterson wrote: > >> 2011/5/5 raymond.hettinger : >>> http://hg.python.org/cpython/rev/1a56775c6e54 >>> changeset: 69857:1a56775c6e54 >>> branch: 3.2 >>> parent: 69855:97a4855202b8 >>> user: Raymond Hettinger >>> date: Thu May 05 11:35:50 2011 -0700 >>> summary: >>> Avoid codec spelling issues by just using the utf-8 default. >> >> Out of curiosity, what is the issue? > > IIRC, the performance depended on how your spelled-it. > I believe that is why the spelling got changed in Py3.3. Not really. It got changed because we have canonical names for the codecs which the stdlib should use rather than rely on aliases. Performance-wise it only makes a difference if you use it in tight loops. > Either way, the code is simpler by just using the default. ... as long as the casual reader knows what the default it :-) I think it's better to make the choice explicit, if the code relies on a particular non-ASCII encoding. If it doesn't, than the default is fine. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, May 06 2011) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2011-06-20: EuroPython 2011, Florence, Italy 45 days to go ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From tjreedy at udel.edu Fri May 6 00:52:34 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 05 May 2011 18:52:34 -0400 Subject: [Python-Dev] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> References: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> Message-ID: On 5/5/2011 4:55 PM, Raymond Hettinger wrote: > Either way, the code is simpler by just using the default. I thought about this and decided that the purpose of having defaults is so one does not have to always spell it out. So use it. Readers can always look it up and learn. -- Terry Jan Reedy From alexander.belopolsky at gmail.com Fri May 6 00:54:11 2011 From: alexander.belopolsky at gmail.com (Alexander Belopolsky) Date: Thu, 5 May 2011 18:54:11 -0400 Subject: [Python-Dev] [Python-checkins] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: <4DC3259B.5020804@egenix.com> References: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> <4DC3259B.5020804@egenix.com> Message-ID: On Thu, May 5, 2011 at 6:32 PM, M.-A. Lemburg wrote: .. >> Either way, the code is simpler by just using the default. > > ... as long as the casual reader knows what the default it :-) > .. or cares. I this particular case, it hardly matters how random bits are encoded. From victor.stinner at haypocalc.com Fri May 6 01:14:14 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Fri, 06 May 2011 01:14:14 +0200 Subject: [Python-Dev] [Python-checkins] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: References: <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> <4DC3259B.5020804@egenix.com> Message-ID: <1304637254.12569.4.camel@marge> Le jeudi 05 mai 2011 ? 18:54 -0400, Alexander Belopolsky a ?crit : > On Thu, May 5, 2011 at 6:32 PM, M.-A. Lemburg wrote: > .. > >> Either way, the code is simpler by just using the default. > > > > ... as long as the casual reader knows what the default it :-) > > > > .. or cares. I this particular case, it hardly matters how random > bits are encoded. You don't get the same random number sequence if you use a different encoding. >>> r=random.Random() >>> r.seed('\xe9'.encode('iso-8859-1')); r.randint(0, 1000) 639 >>> r.seed('\xe9'.encode('utf-8')); r.randint(0, 1000) 992 So it is useful to know how the seed was computed. The real question is which encoding gives the most random numbers? :-) Victor From greg.ewing at canterbury.ac.nz Fri May 6 03:28:11 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 06 May 2011 13:28:11 +1200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: <4DC34EAB.9050001@canterbury.ac.nz> Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: > This is not always true, for example when the item is already present > in the dict. > It's not important to know what the function does to the object, > Only the action on the reference is relevant. Yes, that's the whole point. When using a functon, what you need to know is whether it borrows or steals a reference. But this file *doesn't tell* you that -- rather it assigns either 0 or +1 to a borrowed reference, apparently based on some notion of what the function "usually" does with that parameter. There does not seem to be enough information in that file to work out the borrowed/stolen statuses, which makes it seem rather useless. -- Greg From skip at pobox.com Fri May 6 03:52:08 2011 From: skip at pobox.com (skip at pobox.com) Date: Thu, 5 May 2011 20:52:08 -0500 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> Message-ID: <19907.21576.751581.958722@montanaro.dyndns.org> Georg> Let's remove the cruft, and only keep interesting info. This Georg> will also make the file much more manageable. If I was to do this from scratch I'd think hard about annotating the source code. No matter how hard you try, if you keep this information separate from the code and maintain it manually, it's going to get out-of-date. Skip From marks at dcs.gla.ac.uk Fri May 6 09:44:11 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Fri, 06 May 2011 08:44:11 +0100 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <19907.21576.751581.958722@montanaro.dyndns.org> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <19907.21576.751581.958722@montanaro.dyndns.org> Message-ID: <4DC3A6CB.5020809@dcs.gla.ac.uk> skip at pobox.com wrote: > Georg> Let's remove the cruft, and only keep interesting info. This > Georg> will also make the file much more manageable. > > If I was to do this from scratch I'd think hard about annotating the source > code. No matter how hard you try, if you keep this information separate > from the code and maintain it manually, it's going to get out-of-date. > What about #defining PY_STOLEN in some header? Then any stolen parameter can be prefixed with PY_STOLEN in signature. For return values, similarly #define PY_BORROWED. Cheers, Mark. From amauryfa at gmail.com Fri May 6 10:18:32 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Fri, 6 May 2011 10:18:32 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <4DC3A6CB.5020809@dcs.gla.ac.uk> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <19907.21576.751581.958722@montanaro.dyndns.org> <4DC3A6CB.5020809@dcs.gla.ac.uk> Message-ID: Le vendredi 6 mai 2011, Mark Shannon a ?crit?: > What about #defining PY_STOLEN in some header? > > Then any stolen parameter can be prefixed with PY_STOLEN in signature. > > For return values, similarly #define PY_BORROWED. Header files are harder to parse, and I don't see how it would apply to macros. What about additional tags in the .rst files? -- Amaury -- Amaury Forgeot d'Arc From solipsis at pitrou.net Fri May 6 12:27:03 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 6 May 2011 12:27:03 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> Message-ID: <20110506122703.17c4d889@pitrou.net> On Fri, 06 May 2011 13:28:11 +1200 Greg Ewing wrote: > Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: > > > This is not always true, for example when the item is already present > > in the dict. > > It's not important to know what the function does to the object, > > Only the action on the reference is relevant. > > Yes, that's the whole point. When using a functon, > what you need to know is whether it borrows or steals > a reference. Doesn't "borrow" mean the same as "steal" in that context? If an API borrows a reference, I expect it to take it from me. Regards Antoine. From marks at dcs.gla.ac.uk Fri May 6 12:45:38 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Fri, 06 May 2011 11:45:38 +0100 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <20110506122703.17c4d889@pitrou.net> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> Message-ID: <4DC3D152.601@dcs.gla.ac.uk> Antoine Pitrou wrote: > On Fri, 06 May 2011 13:28:11 +1200 > Greg Ewing wrote: > >> Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: >> >>> This is not always true, for example when the item is already present >>> in the dict. >>> It's not important to know what the function does to the object, >>> Only the action on the reference is relevant. >> Yes, that's the whole point. When using a functon, >> what you need to know is whether it borrows or steals >> a reference. > > Doesn't "borrow" mean the same as "steal" in that context? > If an API borrows a reference, I expect it to take it from me. "Stealing" takes the ownership. Borrowing does not. This explains it better: http://docs.python.org/py3k/c-api/intro.html#reference-count-details Cheers, Mark. From jimjjewett at gmail.com Fri May 6 15:49:19 2011 From: jimjjewett at gmail.com (Jim Jewett) Date: Fri, 6 May 2011 09:49:19 -0400 Subject: [Python-Dev] [Python-checkins] cpython: Userlist.copy() wasn't returning a UserList. In-Reply-To: References: Message-ID: Do you also want to assert that u is not v, or would that sort of "copy" be acceptable by some subclasses? On 5/5/11, raymond.hettinger wrote: > http://hg.python.org/cpython/rev/f20373fcdde5 > changeset: 69865:f20373fcdde5 > user: Raymond Hettinger > date: Thu May 05 14:34:35 2011 -0700 > summary: > Userlist.copy() wasn't returning a UserList. > > files: > Lib/collections/__init__.py | 2 +- > Lib/test/test_userlist.py | 6 ++++++ > 2 files changed, 7 insertions(+), 1 deletions(-) > > > diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py > --- a/Lib/collections/__init__.py > +++ b/Lib/collections/__init__.py > @@ -887,7 +887,7 @@ > def pop(self, i=-1): return self.data.pop(i) > def remove(self, item): self.data.remove(item) > def clear(self): self.data.clear() > - def copy(self): return self.data.copy() > + def copy(self): return self.__class__(self) > def count(self, item): return self.data.count(item) > def index(self, item, *args): return self.data.index(item, *args) > def reverse(self): self.data.reverse() > diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py > --- a/Lib/test/test_userlist.py > +++ b/Lib/test/test_userlist.py > @@ -52,6 +52,12 @@ > return str(key) + '!!!' > self.assertEqual(next(iter(T((1,2)))), "0!!!") > > + def test_userlist_copy(self): > + u = self.type2test([6, 8, 1, 9, 1]) > + v = u.copy() > + self.assertEqual(u, v) > + self.assertEqual(type(u), type(v)) > + > def test_main(): > support.run_unittest(UserListTest) > > > -- > Repository URL: http://hg.python.org/cpython > From ndbecker2 at gmail.com Fri May 6 16:04:09 2011 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 06 May 2011 10:04:09 -0400 Subject: [Python-Dev] Linus on garbage collection Message-ID: http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html From solipsis at pitrou.net Fri May 6 16:12:33 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 6 May 2011 16:12:33 +0200 Subject: [Python-Dev] Linus on garbage collection References: Message-ID: <20110506161233.1ed647ec@pitrou.net> On Fri, 06 May 2011 10:04:09 -0400 Neal Becker wrote: > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html Since we're sharing links, here's Matt Mackall's take: http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html cheers Antoine. From marks at dcs.gla.ac.uk Fri May 6 16:46:08 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Fri, 06 May 2011 15:46:08 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: Message-ID: <4DC409B0.60909@dcs.gla.ac.uk> Neal Becker wrote: > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html > Being famous does not necessarily make you right. OS kernels are pretty atypical software, even if Linus is right about Linux, it doesn't apply to Python. I have empirical evidence, not opinion, that PyPy and my own HotPy are a *lot* faster (x5 or better) on Unladen Swallow's gcbench benchmark (which stresses the memory management subsystem). (Note that gcbench does not introduce any cycles, so its being easy on CPython) In fact, for gcbench CPython spends over twice as long in the cycle-collector as HotPy takes in total! I don't have such detailed results for PyPy. For other benchmarks, the HotPy GC times are often smaller than the inter-run variations in runtime, for example: HotPy GC stats for pystones (on a slow machine with a small cache): Total memory allocated: 20 Mbytes. 20 minor collections, 0 major collections Max heap size 2.4 Mbytes. Total time spent in GC: 3.5 milliseconds. ( <1% of execution time) My GC is quick, but its not the fastest. Evidence trumps opinion IMHO ;) Cheers, Mark. > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/marks%40dcs.gla.ac.uk From solipsis at pitrou.net Fri May 6 17:33:51 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 6 May 2011 17:33:51 +0200 Subject: [Python-Dev] Linus on garbage collection References: <4DC409B0.60909@dcs.gla.ac.uk> Message-ID: <20110506173351.4aef8145@pitrou.net> On Fri, 06 May 2011 15:46:08 +0100 Mark Shannon wrote: > > Neal Becker wrote: > > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html > > > Being famous does not necessarily make you right. > > OS kernels are pretty atypical software, > even if Linus is right about Linux, it doesn't apply to Python. > > I have empirical evidence, not opinion, that PyPy and my own HotPy > are a *lot* faster (x5 or better) on Unladen Swallow's gcbench benchmark > (which stresses the memory management subsystem). > > (Note that gcbench does not introduce any cycles, so its being easy on > CPython) > > In fact, for gcbench CPython spends over twice as long in the > cycle-collector as HotPy takes in total! The thing is, it would be easy to change our collection heuristics so that the cycle collector gets called less often (actually, you can already do so using gc.set_threshold, IIRC). Something which is much more delicate for a "full" GC, where it would grow memory consumption a lot. Regards Antoine. From status at bugs.python.org Fri May 6 18:07:23 2011 From: status at bugs.python.org (Python tracker) Date: Fri, 6 May 2011 18:07:23 +0200 (CEST) Subject: [Python-Dev] Summary of Python tracker Issues Message-ID: <20110506160723.04A101CFD5@psf.upfronthosting.co.za> ACTIVITY SUMMARY (2011-04-29 - 2011-05-06) Python tracker at http://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue. Do NOT respond to this message. Issues counts and deltas: open 2783 (+23) closed 21017 (+41) total 23800 (+64) Open issues with patches: 1201 Issues opened (47) ================== #11955: 3.3 : test_argparse.py fails 'make test' http://bugs.python.org/issue11955 opened by Jason.Vas.Dias #11956: 3.3 : test_import.py causes 'make test' to fail http://bugs.python.org/issue11956 opened by Jason.Vas.Dias #11957: re.sub confusion between count and flags args http://bugs.python.org/issue11957 opened by mindauga #11959: smtpd cannot be used without affecting global state http://bugs.python.org/issue11959 opened by vinay.sajip #11962: Buildbot reliability http://bugs.python.org/issue11962 opened by skrah #11963: Use real assert* for test_trigger_memory_error (test_parser) http://bugs.python.org/issue11963 opened by eric.araujo #11964: Undocumented change to indent param of json.dump in 3.2 http://bugs.python.org/issue11964 opened by eric.araujo #11965: Simplify context manager in os.popen http://bugs.python.org/issue11965 opened by eric.araujo #11968: wsgiref's wsgi application sample code does not work http://bugs.python.org/issue11968 opened by shimizukawa #11969: Can't launch Process on built-in static method http://bugs.python.org/issue11969 opened by cool-RR #11972: input does not strip a trailing newline correctly on Windows http://bugs.python.org/issue11972 opened by Michal.Molhanec #11973: kevent does not accept KQ_NOTE_EXIT (and other (f)flags) http://bugs.python.org/issue11973 opened by DragonSA #11974: Class definition gotcha.. should this be documented somewhere? http://bugs.python.org/issue11974 opened by sleepycal #11975: Fix referencing of built-in types (list, int, ...) http://bugs.python.org/issue11975 opened by jonash #11978: Report correct coverage.py data for tests that invoke subproce http://bugs.python.org/issue11978 opened by ncoghlan #11979: Minor improvements to the Sockets readme: typos, wording and s http://bugs.python.org/issue11979 opened by xmorel #11980: zipfile.ZipFile.write should accept fp as argument http://bugs.python.org/issue11980 opened by proppy #11981: dupe self.fp.tell() in zipfile.ZipFile.writestr http://bugs.python.org/issue11981 opened by proppy #11983: Inconsistent hash and comparison for code objects http://bugs.python.org/issue11983 opened by eltoder #11984: Wrong "See also" in symbol and token module docs http://bugs.python.org/issue11984 opened by davipo #11989: deprecate shutil.copy2 http://bugs.python.org/issue11989 opened by datamuc #11990: redirected output - stdout writes newline as \n in windows http://bugs.python.org/issue11990 opened by Jimbofbx #11992: sys.settrace doesn't disable tracing if a local trace function http://bugs.python.org/issue11992 opened by nedbat #11993: Use sub-second resolution to determine if a file is newer http://bugs.python.org/issue11993 opened by jsjgruber #11994: [2.7/gcc-4.4.3] Segfault under valgrind in string.split() http://bugs.python.org/issue11994 opened by skrah #11995: test_pydoc loads all Python modules http://bugs.python.org/issue11995 opened by haypo #11996: libpython.py: nicer py-bt output http://bugs.python.org/issue11996 opened by haypo #11998: test_signal cannot test blocked signals if _tkinter is loaded; http://bugs.python.org/issue11998 opened by haypo #11999: sporadic failure in test_mailbox on FreeBSD http://bugs.python.org/issue11999 opened by haypo #12001: Extend json.dumps to handle N-triples strings http://bugs.python.org/issue12001 opened by Glenn.Ammons #12002: ftplib.FTP.abort fails with TypeError on Python 3.x http://bugs.python.org/issue12002 opened by nneonneo #12003: documentation: alternate version of xrange seems to fail. http://bugs.python.org/issue12003 opened by tenuki #12004: PyZipFile.writepy gives internal error on syntax errors http://bugs.python.org/issue12004 opened by Ben.Morgan #12005: modulo result of Decimal differs from float/int http://bugs.python.org/issue12005 opened by Kotan #12006: strptime should implement %V or %u directive from libc http://bugs.python.org/issue12006 opened by Erik.Cederstrand #12007: Console commands won't work http://bugs.python.org/issue12007 opened by jake_mcaga #12008: HtmlParser non-strict goes wrong with unquoted attributes http://bugs.python.org/issue12008 opened by svilend #12009: netrc module crashes if netrc file has comment lines http://bugs.python.org/issue12009 opened by rmstoi #12010: Compile fails when sizeof(wchar_t) == 1 http://bugs.python.org/issue12010 opened by dcoles #12011: The signal module should raise OSError for OS-related exceptio http://bugs.python.org/issue12011 opened by pitrou #12012: _ssl module doesn't compile with OpenSSL 1.0.0d: SSLv2_method http://bugs.python.org/issue12012 opened by haypo #12013: file /usr/local/lib/python3.1/lib-dynload/_socket.so: symbol i http://bugs.python.org/issue12013 opened by alex_lai #12014: str.format parses replacement field incorrectly http://bugs.python.org/issue12014 opened by Ben.Wolfson #12015: possible characters in temporary file name is too few http://bugs.python.org/issue12015 opened by planet36 #12016: Wrong behavior for '\xff\n'.decode('gb2312', 'ignore') http://bugs.python.org/issue12016 opened by cdqzzy #12017: Decoding a highly-nested object with json (_speedups enabled) http://bugs.python.org/issue12017 opened by ivank #12018: No tests for ntpath.samefile, ntpath.sameopenfile http://bugs.python.org/issue12018 opened by ronaldoussoren Most recent 15 issues with no replies (15) ========================================== #12018: No tests for ntpath.samefile, ntpath.sameopenfile http://bugs.python.org/issue12018 #12016: Wrong behavior for '\xff\n'.decode('gb2312', 'ignore') http://bugs.python.org/issue12016 #12013: file /usr/local/lib/python3.1/lib-dynload/_socket.so: symbol i http://bugs.python.org/issue12013 #12009: netrc module crashes if netrc file has comment lines http://bugs.python.org/issue12009 #12003: documentation: alternate version of xrange seems to fail. http://bugs.python.org/issue12003 #12002: ftplib.FTP.abort fails with TypeError on Python 3.x http://bugs.python.org/issue12002 #12001: Extend json.dumps to handle N-triples strings http://bugs.python.org/issue12001 #11992: sys.settrace doesn't disable tracing if a local trace function http://bugs.python.org/issue11992 #11989: deprecate shutil.copy2 http://bugs.python.org/issue11989 #11984: Wrong "See also" in symbol and token module docs http://bugs.python.org/issue11984 #11983: Inconsistent hash and comparison for code objects http://bugs.python.org/issue11983 #11979: Minor improvements to the Sockets readme: typos, wording and s http://bugs.python.org/issue11979 #11973: kevent does not accept KQ_NOTE_EXIT (and other (f)flags) http://bugs.python.org/issue11973 #11969: Can't launch Process on built-in static method http://bugs.python.org/issue11969 #11968: wsgiref's wsgi application sample code does not work http://bugs.python.org/issue11968 Most recent 15 issues waiting for review (15) ============================================= #12015: possible characters in temporary file name is too few http://bugs.python.org/issue12015 #12012: _ssl module doesn't compile with OpenSSL 1.0.0d: SSLv2_method http://bugs.python.org/issue12012 #12008: HtmlParser non-strict goes wrong with unquoted attributes http://bugs.python.org/issue12008 #12004: PyZipFile.writepy gives internal error on syntax errors http://bugs.python.org/issue12004 #11999: sporadic failure in test_mailbox on FreeBSD http://bugs.python.org/issue11999 #11998: test_signal cannot test blocked signals if _tkinter is loaded; http://bugs.python.org/issue11998 #11996: libpython.py: nicer py-bt output http://bugs.python.org/issue11996 #11989: deprecate shutil.copy2 http://bugs.python.org/issue11989 #11981: dupe self.fp.tell() in zipfile.ZipFile.writestr http://bugs.python.org/issue11981 #11980: zipfile.ZipFile.write should accept fp as argument http://bugs.python.org/issue11980 #11973: kevent does not accept KQ_NOTE_EXIT (and other (f)flags) http://bugs.python.org/issue11973 #11963: Use real assert* for test_trigger_memory_error (test_parser) http://bugs.python.org/issue11963 #11956: 3.3 : test_import.py causes 'make test' to fail http://bugs.python.org/issue11956 #11949: Make float('nan') unorderable http://bugs.python.org/issue11949 #11948: Tutorial/Modules - small fix to better clarify the modules sea http://bugs.python.org/issue11948 Top 10 most discussed issues (10) ================================= #11277: Crash with mmap and sparse files on Mac OS X http://bugs.python.org/issue11277 19 msgs #8407: expose signalfd(2) and pthread_sigmask in the signal module http://bugs.python.org/issue8407 18 msgs #11935: MMDF/MBOX mailbox need utime http://bugs.python.org/issue11935 17 msgs #11999: sporadic failure in test_mailbox on FreeBSD http://bugs.python.org/issue11999 11 msgs #6721: Locks in python standard library should be sanitized on fork http://bugs.python.org/issue6721 10 msgs #9971: Optimize BufferedReader.readinto http://bugs.python.org/issue9971 9 msgs #3526: Customized malloc implementation on SunOS and AIX http://bugs.python.org/issue3526 8 msgs #11962: Buildbot reliability http://bugs.python.org/issue11962 8 msgs #11949: Make float('nan') unorderable http://bugs.python.org/issue11949 7 msgs #11954: 3.3 - 'make test' fails http://bugs.python.org/issue11954 7 msgs Issues closed (37) ================== #1856: shutdown (exit) can hang or segfault with daemon threads runni http://bugs.python.org/issue1856 closed by pitrou #7517: freeze.py not ported to python3 http://bugs.python.org/issue7517 closed by eric.araujo #8158: Docstring of optparse.OptionParser incomplete http://bugs.python.org/issue8158 closed by r.david.murray #9756: Crash with custom __getattribute__ http://bugs.python.org/issue9756 closed by haypo #10684: Folders get deleted when trying to change case with shutil.mov http://bugs.python.org/issue10684 closed by ronaldoussoren #10775: assertRaises as a context manager should accept a 'msg' keywor http://bugs.python.org/issue10775 closed by ezio.melotti #10922: Unexpected exception when calling function_proxy.__class__.__c http://bugs.python.org/issue10922 closed by haypo #11034: Build problem on Windows with MSVC++ Express 2008 http://bugs.python.org/issue11034 closed by loewis #11206: test_readline unconditionally calls clear_history() http://bugs.python.org/issue11206 closed by ned.deily #11247: Error sending packets to multicast IPV4 address http://bugs.python.org/issue11247 closed by neologix #11335: Memory leak after key function failure in sort http://bugs.python.org/issue11335 closed by stutzbach #11834: wrong module installation dir on Windows http://bugs.python.org/issue11834 closed by brian.curtin #11849: glibc allocator doesn't release all free()ed memory http://bugs.python.org/issue11849 closed by pitrou #11873: test_regexp() of test_compileall fails occassionally http://bugs.python.org/issue11873 closed by r.david.murray #11883: Call connect() before sending an email with smtplib http://bugs.python.org/issue11883 closed by r.david.murray #11887: unittest fails on comparing str with bytes if python has the - http://bugs.python.org/issue11887 closed by michael.foord #11898: Sending binary data with a POST request in httplib can cause U http://bugs.python.org/issue11898 closed by orsenthil #11912: PaX triggers a segfault in dlopen http://bugs.python.org/issue11912 closed by neologix #11930: Remove time.accept2dyear http://bugs.python.org/issue11930 closed by belopolsky #11950: logger use dict for loggers instead of WeakValueDictionary http://bugs.python.org/issue11950 closed by vinay.sajip #11958: test.test_ftplib.TestIPv6Environment failure http://bugs.python.org/issue11958 closed by python-dev #11960: Python crashes when running numpy test http://bugs.python.org/issue11960 closed by amaury.forgeotdarc #11961: Document STARTUPINFO and creationflags options for Windows http://bugs.python.org/issue11961 closed by brian.curtin #11966: Typo in PyModule_AddIntMacro's documentation http://bugs.python.org/issue11966 closed by python-dev #11967: Left shift and Right shift for floats http://bugs.python.org/issue11967 closed by loewis #11970: distutils command 'upload' crashes when --show-response is sel http://bugs.python.org/issue11970 closed by offby1 #11971: Wrong parameter -O0 instead of -OO in manpage http://bugs.python.org/issue11971 closed by r.david.murray #11976: Provide proper documentation for list data type http://bugs.python.org/issue11976 closed by georg.brandl #11977: Document int.conjugate, .denominator, ... http://bugs.python.org/issue11977 closed by python-dev #11982: json.loads() returns str instead of unicode for empty strings http://bugs.python.org/issue11982 closed by ezio.melotti #11985: Document that platform.python_implementation supports PyPy http://bugs.python.org/issue11985 closed by ezio.melotti #11986: Min/max not symmetric in presence of NaN http://bugs.python.org/issue11986 closed by rhettinger #11987: queue.Queue.put should acquire mutex for unfinished_tasks http://bugs.python.org/issue11987 closed by rhettinger #11988: special method lookup docs don't address some important detail http://bugs.python.org/issue11988 closed by r.david.murray #11991: test_distutils fails because of bad filename match http://bugs.python.org/issue11991 closed by eric.araujo #11997: One typo in Doc/c-api/init.rst http://bugs.python.org/issue11997 closed by ezio.melotti #12000: SSL certificate verification failed if no dNSName entry in sub http://bugs.python.org/issue12000 closed by pitrou From skip at pobox.com Fri May 6 18:18:51 2011 From: skip at pobox.com (skip at pobox.com) Date: Fri, 6 May 2011 11:18:51 -0500 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <20110506161233.1ed647ec@pitrou.net> References: <20110506161233.1ed647ec@pitrou.net> Message-ID: <19908.8043.8921.50222@montanaro.dyndns.org> Antoine> Since we're sharing links, here's Matt Mackall's take: Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >From that note: 1: You can't have meaningful destructors, because when destruction happens is undefined. And going-out-of-scope destructors are extremely useful. Python is already a rather broken in this regard, so feel free to ignore this point. Given the presence of cyclic data I don't see how reference counting or garbage collection win. Ignoring the fact that in a pure reference counted system you won't even consider cycles for reclmation, would both RC and GC have to punt because they can't tell which object's destructor to call first? Skip From fuzzyman at voidspace.org.uk Fri May 6 18:31:44 2011 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 06 May 2011 17:31:44 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <19908.8043.8921.50222@montanaro.dyndns.org> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> Message-ID: <4DC42270.1000301@voidspace.org.uk> On 06/05/2011 17:18, skip at pobox.com wrote: > Antoine> Since we're sharing links, here's Matt Mackall's take: > Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html > > > From that note: > > 1: You can't have meaningful destructors, because when destruction > happens is undefined. And going-out-of-scope destructors are extremely > useful. Python is already a rather broken in this regard, so feel free > to ignore this point. > > Given the presence of cyclic data I don't see how reference counting or > garbage collection win. Ignoring the fact that in a pure reference counted > system you won't even consider cycles for reclmation, would both RC and GC > have to punt because they can't tell which object's destructor to call > first? pypy and .NET choose to arbitrarily break cycles rather than leave objects unfinalised and memory unreclaimed. Not sure what Java does. All the best, Michael Foord > Skip > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html From greg at krypto.org Fri May 6 18:32:51 2011 From: greg at krypto.org (Gregory P. Smith) Date: Fri, 6 May 2011 09:32:51 -0700 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <19908.8043.8921.50222@montanaro.dyndns.org> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> Message-ID: On Fri, May 6, 2011 at 9:18 AM, wrote: > > ? ?Antoine> Since we're sharing links, here's Matt Mackall's take: > ? ?Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html > > >From that note: > > ? ?1: You can't have meaningful destructors, because when destruction > ? ?happens is undefined. And going-out-of-scope destructors are extremely > ? ?useful. Python is already a rather broken in this regard, so feel free > ? ?to ignore this point. Python being "broken" in this regard is pretty much exactly why __enter__, __exit__ and with as context managers were added to the language. That gives the ability to have the equivalent of well defined nested scopes that destroy something (exit) deterministically much as it is easy to do in C++ with some {}s and a ~destructor(). It is not broken, just different. -gps From marks at dcs.gla.ac.uk Fri May 6 18:33:03 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Fri, 06 May 2011 17:33:03 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <19908.8043.8921.50222@montanaro.dyndns.org> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> Message-ID: <4DC422BF.4010006@dcs.gla.ac.uk> skip at pobox.com wrote: > Antoine> Since we're sharing links, here's Matt Mackall's take: > Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html > >>From that note: > > 1: You can't have meaningful destructors, because when destruction > happens is undefined. And going-out-of-scope destructors are extremely > useful. Python is already a rather broken in this regard, so feel free > to ignore this point. > > Given the presence of cyclic data I don't see how reference counting or > garbage collection win. Ignoring the fact that in a pure reference counted > system you won't even consider cycles for reclmation, would both RC and GC > have to punt because they can't tell which object's destructor to call > first? It doesn't matter which is called first. In fact, the VM could call all the destructors at the same time if the machine has enough cores and there's no GIL. All objects are kept alive by the GC until after the destructors are called. Those that are still dead will have their memory reclaimed. > > Skip > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/marks%40dcs.gla.ac.uk From stefan_ml at behnel.de Fri May 6 18:51:37 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 06 May 2011 18:51:37 +0200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC422BF.4010006@dcs.gla.ac.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> Message-ID: Mark Shannon, 06.05.2011 18:33: > skip at pobox.com wrote: >> Antoine> Since we're sharing links, here's Matt Mackall's take: >> Antoine> >> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >> >>> From that note: >> >> 1: You can't have meaningful destructors, because when destruction >> happens is undefined. And going-out-of-scope destructors are extremely >> useful. Python is already a rather broken in this regard, so feel free >> to ignore this point. >> >> Given the presence of cyclic data I don't see how reference counting or >> garbage collection win. Ignoring the fact that in a pure reference counted >> system you won't even consider cycles for reclmation, would both RC and GC >> have to punt because they can't tell which object's destructor to call >> first? > > It doesn't matter which is called first. May I quote you on that one the next time my software crashes? It may not make a difference for the runtime, but the difference for user software may be "dead" or "alive". Stefan From fuzzyman at voidspace.org.uk Fri May 6 19:04:53 2011 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 06 May 2011 18:04:53 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> Message-ID: <4DC42A35.6060303@voidspace.org.uk> On 06/05/2011 17:32, Gregory P. Smith wrote: > On Fri, May 6, 2011 at 9:18 AM, wrote: >> Antoine> Since we're sharing links, here's Matt Mackall's take: >> Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >> >> > From that note: >> >> 1: You can't have meaningful destructors, because when destruction >> happens is undefined. And going-out-of-scope destructors are extremely >> useful. Python is already a rather broken in this regard, so feel free >> to ignore this point. > Python being "broken" in this regard is pretty much exactly why > __enter__, __exit__ and with as context managers were added to the > language. > How does that help with cycles? Sure it makes cleaning up some resources easier, but not at all this case. Explicit destruction is of course always an alternative to the runtime doing it for you, but it doesn't help with (for example) reclaiming memory. For long running processes memory leaks due to unreclaimable cycles can be a problem with CPython. > That gives the ability to have the equivalent of well defined nested > scopes that destroy something (exit) deterministically much as it is > easy to do in C++ with some {}s and a ~destructor(). > > It is not broken, just different. +1 QOTW ;-) Michael > -gps > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html From fuzzyman at voidspace.org.uk Fri May 6 19:06:35 2011 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 06 May 2011 18:06:35 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> Message-ID: <4DC42A9B.6020000@voidspace.org.uk> On 06/05/2011 17:51, Stefan Behnel wrote: > Mark Shannon, 06.05.2011 18:33: >> skip at pobox.com wrote: >>> Antoine> Since we're sharing links, here's Matt Mackall's take: >>> Antoine> >>> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >>> >>>> From that note: >>> >>> 1: You can't have meaningful destructors, because when destruction >>> happens is undefined. And going-out-of-scope destructors are extremely >>> useful. Python is already a rather broken in this regard, so feel free >>> to ignore this point. >>> >>> Given the presence of cyclic data I don't see how reference counting or >>> garbage collection win. Ignoring the fact that in a pure reference >>> counted >>> system you won't even consider cycles for reclmation, would both RC >>> and GC >>> have to punt because they can't tell which object's destructor to call >>> first? >> >> It doesn't matter which is called first. > > May I quote you on that one the next time my software crashes? > Arbitrarily breaking cycles *could* cause a problem if a destructor attempts to access an already collected object. Not breaking cycles *definitely* leaks memory and definitely doesn't call finalizers. Michael > It may not make a difference for the runtime, but the difference for > user software may be "dead" or "alive". > > Stefan > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html From glyph at twistedmatrix.com Fri May 6 19:07:44 2011 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Fri, 6 May 2011 13:07:44 -0400 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC42270.1000301@voidspace.org.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC42270.1000301@voidspace.org.uk> Message-ID: <8F83194F-5A5C-496E-920A-A2488F9949E4@twistedmatrix.com> On May 6, 2011, at 12:31 PM, Michael Foord wrote: > pypy and .NET choose to arbitrarily break cycles rather than leave objects unfinalised and memory unreclaimed. Not sure what Java does. I think that's a mischaracterization of their respective collectors; "arbitrarily break cycles" implies that user code would see broken or incomplete objects, at least during finalization, which I'm fairly sure is not true on either .NET or PyPy. Java definitely has a collector that can handles cycles too. (None of these are reference counting.) -glyph -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen at xemacs.org Fri May 6 19:15:33 2011 From: stephen at xemacs.org (Stephen J. Turnbull) Date: Sat, 07 May 2011 02:15:33 +0900 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC409B0.60909@dcs.gla.ac.uk> References: <4DC409B0.60909@dcs.gla.ac.uk> Message-ID: <87y62jeone.fsf@uwakimon.sk.tsukuba.ac.jp> Mark Shannon writes: > > > Neal Becker wrote: > > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html > > > Being famous does not necessarily make you right. No, but being a genius sure helps you beat the odds. > OS kernels are pretty atypical software, > even if Linus is right about Linux, it doesn't apply to Python. Well, actually he was writing about GCC.... > I have empirical evidence, not opinion, that PyPy and my own HotPy > are a *lot* faster (x5 or better) on Unladen Swallow's gcbench benchmark > (which stresses the memory management subsystem). You're missing Linus's point, I think. Linus did *not* claim that it's impossible to write a fast *GC*. He claimed that it's hard to write a fast *program* that uses GC for memory management. A benchmark that stresses *only* the memory management system is unlikely to impress him. From fuzzyman at voidspace.org.uk Fri May 6 19:12:51 2011 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 06 May 2011 18:12:51 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <8F83194F-5A5C-496E-920A-A2488F9949E4@twistedmatrix.com> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC42270.1000301@voidspace.org.uk> <8F83194F-5A5C-496E-920A-A2488F9949E4@twistedmatrix.com> Message-ID: <4DC42C13.8070806@voidspace.org.uk> On 06/05/2011 18:07, Glyph Lefkowitz wrote: > On May 6, 2011, at 12:31 PM, Michael Foord wrote: > >> pypy and .NET choose to arbitrarily break cycles rather than leave >> objects unfinalised and memory unreclaimed. Not sure what Java does. > > I think that's a mischaracterization of their respective collectors; > "arbitrarily break cycles" implies that user code would see broken or > incomplete objects, at least during finalization, which I'm fairly > sure is not true on either .NET or PyPy. http://morepypy.blogspot.com/2008/02/python-finalizers-semantics-part-1.html "Therefore we decided to break such a cycle at an arbitrary place, which doesn't sound too insane." All the best, Michael Foord > > Java definitely has a collector that can handles cycles too. (None of > these are reference counting.) > > -glyph -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From marks at dcs.gla.ac.uk Fri May 6 19:46:37 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Fri, 06 May 2011 18:46:37 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC4321F.3070206@voidspace.org.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC42F4B.1050509@dcs.gla.ac.uk> <4DC4321F.3070206@voidspace.org.uk> Message-ID: <4DC433FD.6090803@dcs.gla.ac.uk> Michael Foord wrote: > On 06/05/2011 18:26, Mark Shannon wrote: >> Michael Foord wrote: >>> On 06/05/2011 17:51, Stefan Behnel wrote: >>>> Mark Shannon, 06.05.2011 18:33: >>>>> skip at pobox.com wrote: >>>>>> Antoine> Since we're sharing links, here's Matt Mackall's take: >>>>>> Antoine> >>>>>> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >>>>>> >>>>>>> From that note: >>>>>> 1: You can't have meaningful destructors, because when destruction >>>>>> happens is undefined. And going-out-of-scope destructors are >>>>>> extremely >>>>>> useful. Python is already a rather broken in this regard, so feel >>>>>> free >>>>>> to ignore this point. >>>>>> >>>>>> Given the presence of cyclic data I don't see how reference >>>>>> counting or >>>>>> garbage collection win. Ignoring the fact that in a pure reference >>>>>> counted >>>>>> system you won't even consider cycles for reclmation, would both >>>>>> RC and GC >>>>>> have to punt because they can't tell which object's destructor to >>>>>> call >>>>>> first? >>>>> It doesn't matter which is called first. >>>> May I quote you on that one the next time my software crashes? >>>> >>> Arbitrarily breaking cycles *could* cause a problem if a destructor >>> attempts to access an already collected object. Not breaking cycles >>> *definitely* leaks memory and definitely doesn't call finalizers. >> You don't need to break the cycles to call the finalizers. Just call >> them, then collect the whole cycle (assuming it is still unreachable). >> >> The GC will *never* reclaim a reachable object. Objects awaiting >> finalization are reachable, by definition. >> > Well it was sloppily worded, so replace it with: > > if a finalizer attempts to access an already finalized object. A finalized object will still be a valid object. Python code cannot make an object unsafe. Obviously C code can make it unsafe, but that's true of C code anywhere. For example, a file object will close itself during finalization, but its still a valid object, just a closed file rather than an open one. > > Michael >>> Michael >>> >>>> It may not make a difference for the runtime, but the difference for >>>> user software may be "dead" or "alive". >>>> >>>> Stefan >>>> >>>> _______________________________________________ >>>> Python-Dev mailing list >>>> Python-Dev at python.org >>>> http://mail.python.org/mailman/listinfo/python-dev >>>> Unsubscribe: >>>> http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk >>> > > From merwok at netwok.org Fri May 6 19:42:11 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Fri, 06 May 2011 19:42:11 +0200 Subject: [Python-Dev] cpython (3.2): Avoid codec spelling issues by just using the utf-8 default. In-Reply-To: References: "\"" " <926F0913-8142-430A-8400-6E6F0CD5B8F1@gmail.com> Message-ID: Le 06/05/2011 00:52, Terry Reedy a ?crit : > On 5/5/2011 4:55 PM, Raymond Hettinger wrote: >> Either way, the code is simpler by just using the default. > I thought about this and decided that the purpose of having defaults > is > so one does not have to always spell it out. So use it. Readers can > always look it up and learn. Agreed. I thought about something similar after Victor?s commit that changed open(mode='rU') to use just 'r': Why not remove the mode argument entirely when it is the default value? Regards From merwok at netwok.org Fri May 6 19:51:31 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Fri, 06 May 2011 19:51:31 +0200 Subject: [Python-Dev] Problems with regrtest and with logging Message-ID: Hi, Sorry for quick email-battery dying. regrtest helpfully reports when a test leaves the environment unclean (sys.path, os.environ, logging._handlerList), but I think the implementation is buggy: it compares object identity and then value. Why is comparing identity useful? I?d just use ==. It makes writing cleanup code easier (just use addCleanup(setattr, obj, 'attr', copy(obj.attr))). Second: in packaging, we have two modules that create a logging handler. I?m not sure how if we should change the code or fix the tests to restore the _handlerList, or how. Thanks for advice. Regards From skip at pobox.com Fri May 6 19:58:34 2011 From: skip at pobox.com (skip at pobox.com) Date: Fri, 6 May 2011 12:58:34 -0500 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC42C13.8070806@voidspace.org.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC42270.1000301@voidspace.org.uk> <8F83194F-5A5C-496E-920A-A2488F9949E4@twistedmatrix.com> <4DC42C13.8070806@voidspace.org.uk> Message-ID: <19908.14026.312182.540486@montanaro.dyndns.org> Michael> "Therefore we decided to break such a cycle at an arbitrary Michael> place, which doesn't sound too insane." I trust "arbitrary" != "random"? Skip From stefan_ml at behnel.de Fri May 6 20:06:12 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 06 May 2011 20:06:12 +0200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC42A9B.6020000@voidspace.org.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> Message-ID: Michael Foord, 06.05.2011 19:06: > On 06/05/2011 17:51, Stefan Behnel wrote: >> Mark Shannon, 06.05.2011 18:33: >>> skip at pobox.com wrote: >>>> Antoine> Since we're sharing links, here's Matt Mackall's take: >>>> Antoine> >>>> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >>>> >>>>> From that note: >>>> >>>> 1: You can't have meaningful destructors, because when destruction >>>> happens is undefined. And going-out-of-scope destructors are extremely >>>> useful. Python is already a rather broken in this regard, so feel free >>>> to ignore this point. >>>> >>>> Given the presence of cyclic data I don't see how reference counting or >>>> garbage collection win. Ignoring the fact that in a pure reference counted >>>> system you won't even consider cycles for reclmation, would both RC and GC >>>> have to punt because they can't tell which object's destructor to call >>>> first? >>> >>> It doesn't matter which is called first. >> >> May I quote you on that one the next time my software crashes? > > Arbitrarily breaking cycles *could* cause a problem if a destructor > attempts to access an already collected object. This is more real than the "could" suggests. Remember that CPython includes a lot of C code, and is commonly used to interface with C libraries. While you will simply get an exception when cycles are broken in Python code, cycles that involve C code can suffer quite badly from this problem. There was a bug in the lxml.etree XML library a while ago that could let it crash hard when its Element objects participated in a reference cycle. It's based on libxml2, so there's an underlying C tree that potentially involves disconnected subtrees, and a Python space representation using Element proxies, with at least one Element for each disconnected subtree. Basically, Elements reference their Document (not the other way round) even if they are disconnected from the main C document tree. The Document needs to do some final cleanup in the end, whereas the Elements require the Document to be alive to do their own subtree cleanup, if only to know what exactly to clean up, as the subtrees share some C state through the document. Now, if any of the Elements ends up in a reference cycle for some reason, the GC will throw its dices and may decide to call the Document destructor first. Then the Element destructors are bound to crash, trying to access dead memory of the Document. This was easy to fix in CPython's refcounting environment. A double INCREF on the Document for each Element does the trick, as it effectively removes the Document from the collectable cycle and lets the Element destructors decide when to let the Document refcount go down to 0. A fix in a pure GC system is substantially harder to make efficient. Stefan From g.brandl at gmx.net Fri May 6 20:14:28 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Fri, 06 May 2011 20:14:28 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <19907.21576.751581.958722@montanaro.dyndns.org> <4DC3A6CB.5020809@dcs.gla.ac.uk> Message-ID: On 06.05.2011 10:18, Amaury Forgeot d'Arc wrote: > Le vendredi 6 mai 2011, Mark Shannon a ?crit : >> What about #defining PY_STOLEN in some header? >> >> Then any stolen parameter can be prefixed with PY_STOLEN in signature. >> >> For return values, similarly #define PY_BORROWED. > > Header files are harder to parse, and I don't see how it would apply to macros. > What about additional tags in the .rst files? Possible, of course, and even easier to implement. Georg From g.brandl at gmx.net Fri May 6 20:16:20 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Fri, 06 May 2011 20:16:20 +0200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <20110506122703.17c4d889@pitrou.net> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> Message-ID: On 06.05.2011 12:27, Antoine Pitrou wrote: > On Fri, 06 May 2011 13:28:11 +1200 > Greg Ewing wrote: > >> Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: >> >> > This is not always true, for example when the item is already present >> > in the dict. >> > It's not important to know what the function does to the object, >> > Only the action on the reference is relevant. >> >> Yes, that's the whole point. When using a functon, >> what you need to know is whether it borrows or steals >> a reference. > > Doesn't "borrow" mean the same as "steal" in that context? > If an API borrows a reference, I expect it to take it from me. Basically, "borrow" is applied to return values (or, more generally, "out" parameters), and means that *you* borrowed the reference. "steal", OTOH, is applied to (and the exception for) "in" parameters. Georg From marks at dcs.gla.ac.uk Fri May 6 20:45:41 2011 From: marks at dcs.gla.ac.uk (Mark Shannon) Date: Fri, 06 May 2011 19:45:41 +0100 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> Message-ID: <4DC441D5.2070102@dcs.gla.ac.uk> Stefan Behnel wrote: > Michael Foord, 06.05.2011 19:06: >> On 06/05/2011 17:51, Stefan Behnel wrote: >>> Mark Shannon, 06.05.2011 18:33: >>>> skip at pobox.com wrote: >>>>> Antoine> Since we're sharing links, here's Matt Mackall's take: >>>>> Antoine> >>>>> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >>>>> >>>>>> From that note: >>>>> 1: You can't have meaningful destructors, because when destruction >>>>> happens is undefined. And going-out-of-scope destructors are extremely >>>>> useful. Python is already a rather broken in this regard, so feel free >>>>> to ignore this point. >>>>> >>>>> Given the presence of cyclic data I don't see how reference counting or >>>>> garbage collection win. Ignoring the fact that in a pure reference counted >>>>> system you won't even consider cycles for reclmation, would both RC and GC >>>>> have to punt because they can't tell which object's destructor to call >>>>> first? >>>> It doesn't matter which is called first. >>> May I quote you on that one the next time my software crashes? >> Arbitrarily breaking cycles *could* cause a problem if a destructor >> attempts to access an already collected object. > > This is more real than the "could" suggests. Remember that CPython includes > a lot of C code, and is commonly used to interface with C libraries. While > you will simply get an exception when cycles are broken in Python code, > cycles that involve C code can suffer quite badly from this problem. > > There was a bug in the lxml.etree XML library a while ago that could let it > crash hard when its Element objects participated in a reference cycle. It's > based on libxml2, so there's an underlying C tree that potentially involves > disconnected subtrees, and a Python space representation using Element > proxies, with at least one Element for each disconnected subtree. > > Basically, Elements reference their Document (not the other way round) even > if they are disconnected from the main C document tree. The Document needs > to do some final cleanup in the end, whereas the Elements require the > Document to be alive to do their own subtree cleanup, if only to know what > exactly to clean up, as the subtrees share some C state through the > document. Now, if any of the Elements ends up in a reference cycle for some > reason, the GC will throw its dices and may decide to call the Document > destructor first. Then the Element destructors are bound to crash, trying > to access dead memory of the Document. With a tracing collector it is *impossible* to access dead memory, ever. If it can be reached the GC will *not* collect it. This should be a fundamental invariant of *all* GCs. If an object is finalizable or reachable from any finalizable objects then it is reachable and its memory should not be reclaimed until it is truly unreachable. Finalization and reclamation are separate phases. > > This was easy to fix in CPython's refcounting environment. A double INCREF > on the Document for each Element does the trick, as it effectively removes > the Document from the collectable cycle and lets the Element destructors > decide when to let the Document refcount go down to 0. A fix in a pure GC > system is substantially harder to make efficient. With a tracing GC: While the Elements are finalized, the Document is still alive. While the Document is finalized, the Elements are still alive. Then, and only then, is the whole lot reclaimed. Mark. From vinay_sajip at yahoo.co.uk Fri May 6 20:57:24 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Fri, 6 May 2011 18:57:24 +0000 (UTC) Subject: [Python-Dev] Problems with regrtest and with logging References: Message-ID: ?ric Araujo netwok.org> writes: > Second: in packaging, we have two modules that create a logging > handler. I?m not sure how if we should change the code or fix the tests > to restore the _handlerList, or how. If you are saying this happens in your unit tests for packaging, then you can either restore the _handlerList using the approach in test_logging, or else you can just close the handlers when you've done with them. If you point me at the relevant code (is it on bitbucket or on hg.python.org?) I can perhaps take a look and advise. Regards, Vinay Sajip From stefan_ml at behnel.de Fri May 6 21:10:30 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 06 May 2011 21:10:30 +0200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC441D5.2070102@dcs.gla.ac.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC441D5.2070102@dcs.gla.ac.uk> Message-ID: Mark Shannon, 06.05.2011 20:45: > Stefan Behnel wrote: >> Michael Foord, 06.05.2011 19:06: >>> On 06/05/2011 17:51, Stefan Behnel wrote: >>>> Mark Shannon, 06.05.2011 18:33: >>>>> skip at pobox.com wrote: >>>>>> Antoine> Since we're sharing links, here's Matt Mackall's take: >>>>>> Antoine> >>>>>> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html >>>>>> >>>>>>> From that note: >>>>>> 1: You can't have meaningful destructors, because when destruction >>>>>> happens is undefined. And going-out-of-scope destructors are extremely >>>>>> useful. Python is already a rather broken in this regard, so feel free >>>>>> to ignore this point. >>>>>> >>>>>> Given the presence of cyclic data I don't see how reference counting or >>>>>> garbage collection win. Ignoring the fact that in a pure reference >>>>>> counted >>>>>> system you won't even consider cycles for reclmation, would both RC >>>>>> and GC >>>>>> have to punt because they can't tell which object's destructor to call >>>>>> first? >>>>> It doesn't matter which is called first. >>>> May I quote you on that one the next time my software crashes? >>> Arbitrarily breaking cycles *could* cause a problem if a destructor >>> attempts to access an already collected object. >> >> This is more real than the "could" suggests. Remember that CPython >> includes a lot of C code, and is commonly used to interface with C >> libraries. While you will simply get an exception when cycles are broken >> in Python code, cycles that involve C code can suffer quite badly from >> this problem. >> >> There was a bug in the lxml.etree XML library a while ago that could let >> it crash hard when its Element objects participated in a reference cycle. >> It's based on libxml2, so there's an underlying C tree that potentially >> involves disconnected subtrees, and a Python space representation using >> Element proxies, with at least one Element for each disconnected subtree. >> >> Basically, Elements reference their Document (not the other way round) >> even if they are disconnected from the main C document tree. The Document >> needs to do some final cleanup in the end, whereas the Elements require >> the Document to be alive to do their own subtree cleanup, if only to know >> what exactly to clean up, as the subtrees share some C state through the >> document. Now, if any of the Elements ends up in a reference cycle for >> some reason, the GC will throw its dices and may decide to call the >> Document destructor first. Then the Element destructors are bound to >> crash, trying to access dead memory of the Document. > > With a tracing collector it is *impossible* to access dead memory, ever. > If it can be reached the GC will *not* collect it. > This should be a fundamental invariant of *all* GCs. > > If an object is finalizable or reachable from any finalizable objects > then it is reachable and its memory should not be reclaimed until it is > truly unreachable. > > Finalization and reclamation are separate phases. Sure. However, I'm talking about Python types and C memory here. Even if the Python objects are still alive, they may already have freed the underlying C memory during their *finalisation*. When an Element goes out of scope, it must free its C subtree if it is disconnected, even if the Document stays alive. So that's what Elements do in their destructor, and they need the Document's C memory for that, which the Document frees during its own finalisation. I do agree that CPython's destructor call algorithms could have been smarter in this case. After all, the described crash case indicates that the Document destructor was called before all of the Element destructors had been called, although all Elements reference their Document, but the Document does not refer to any of the Elements, so it's basically a dead end. That would have provided a detectable hint to call the Document destructor last, after the ones of all objects that reference it. Apparently, this hint did not lead to an appropriate action, possibly because it's an unimplemented special case and there are enough cases where multiple objects with destructors are actually part of the 'real' cycle. Stefan From drsalists at gmail.com Fri May 6 21:59:30 2011 From: drsalists at gmail.com (Dan Stromberg) Date: Fri, 6 May 2011 12:59:30 -0700 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: Message-ID: On Fri, May 6, 2011 at 7:04 AM, Neal Becker wrote: > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html > Of course, a generational GC improves locality of reference. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdmurray at bitdance.com Fri May 6 22:07:30 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Fri, 06 May 2011 16:07:30 -0400 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: <20110506200734.049872500DF@webabinitio.net> On Fri, 06 May 2011 19:51:31 +0200, =?UTF-8?Q?=C3=89ric_Araujo?= wrote: > regrtest helpfully reports when a test leaves the environment unclean > (sys.path, os.environ, logging._handlerList), but I think the > implementation is buggy: it compares object identity and then value. > Why is comparing identity useful? I???d just use ==. It makes writing > cleanup code easier (just use addCleanup(setattr, obj, 'attr', > copy(obj.attr))). Well, the implementation is intentional. Nick (I think) added the identity check, and he had a reason at the time. I don't remember what it was, though. -- R. David Murray http://www.bitdance.com From greg.ewing at canterbury.ac.nz Sat May 7 01:25:09 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 07 May 2011 11:25:09 +1200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: Message-ID: <4DC48355.2050509@canterbury.ac.nz> Neal Becker wrote: > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html There, Linus says > For example, if you have an _explicit_ refcounting system, then it is > quite natural to have operations like ... > > note_t *node = *np; > if (node->count > 1) > newnode = copy_alloc(node); It's interesting to note that, even though you *can* get reference count information in CPython, it's not all that useful for doing things like that, because it's hard to be sure how many incidental references have been created on the way to the code concerned. So tricks like this at the Python level aren't really feasible in any robust way. -- Greg From greg.ewing at canterbury.ac.nz Sat May 7 01:43:16 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 07 May 2011 11:43:16 +1200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <19908.8043.8921.50222@montanaro.dyndns.org> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> Message-ID: <4DC48794.5070808@canterbury.ac.nz> Antoine> http://www.selenic.com/pipermail/mercurial-devel/2011-May/031055.html > >>From that note: > > 1: You can't have meaningful destructors, because when destruction > happens is undefined. And going-out-of-scope destructors are extremely > useful. Python is already a rather broken in this regard, so feel free > to ignore this point. It's only broken if you regard RAII as the One True Way to implement scoped resource management. Python has other approaches to that, such as the with-statement. Also, you *can* have destructors that work for objects in cycles, as long as you don't insist on the destructor having access to the object that's being destroyed. Weakref callbacks provide a way of implementing this in CPython. -- Greg From greg.ewing at canterbury.ac.nz Sat May 7 01:53:39 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 07 May 2011 11:53:39 +1200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC433FD.6090803@dcs.gla.ac.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC42F4B.1050509@dcs.gla.ac.uk> <4DC4321F.3070206@voidspace.org.uk> <4DC433FD.6090803@dcs.gla.ac.uk> Message-ID: <4DC48A03.2020800@canterbury.ac.nz> Mark Shannon wrote: > For example, a file object will close itself during finalization, > but its still a valid object, just a closed file rather than an open one. It might be valid in the sense that you won't get a segfault. But the point is that the destructors of some objects may be relying on other objects still being in a certain state, e.g. a file still being open. One would have to adopt a highly defensive coding style in destructors, verging on paranoia, to be sure that one's destructor code was completely immune to this kind of problem. All of this worry goes away if the destructor is not a method of the object being destroyed, but something external that runs *after* the object has disappeared. -- Greg From ncoghlan at gmail.com Sat May 7 02:12:33 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sat, 7 May 2011 10:12:33 +1000 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: Message-ID: <6163FB60-2F6C-4143-8D9D-EE241DD09081@gmail.com> Even if he's right (and he probably is) manual memory management is still a premature optimization for most applications. C and C++ data structures are a PITA because you have to be so careful to avoid leaks and double-frees, so people end up using dumb algorithms. Worrying about losing cycles waiting for main memory is stupid if your high level algorithm is O(N^2). Cheers, Nick. -- Nick Coghlan, Brisbane, Australia On 07/05/2011, at 12:04 AM, Neal Becker wrote: > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com From greg.ewing at canterbury.ac.nz Sat May 7 02:22:22 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 07 May 2011 12:22:22 +1200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC441D5.2070102@dcs.gla.ac.uk> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC441D5.2070102@dcs.gla.ac.uk> Message-ID: <4DC490BE.4080002@canterbury.ac.nz> Mark Shannon wrote: > With a tracing GC: > While the Elements are finalized, the Document is still alive. > While the Document is finalized, the Elements are still alive. > Then, and only then, is the whole lot reclaimed. One problem is that, at the C level in CPython, you can't separate finalisation and reclamation. When an object's refcount drops to zero, its tp_dealloc method is called, which both finalises the object and reclaims its memory. Another problem is that just because an object's memory hasn't been reclaimed yet doesn't mean it's safe to do anything with that object. This is doubly true at the C level, where the consequences can include segfaults. Seems to me the basic issue here is that the C code wasn't designed with tracing GC in mind. There is a reference cycle, but it is assumed that the user is in manual control of deallocation and will deallocate the Nodes before the Document. -- Greg From greg.ewing at canterbury.ac.nz Sat May 7 02:26:10 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 07 May 2011 12:26:10 +1200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC441D5.2070102@dcs.gla.ac.uk> Message-ID: <4DC491A2.2060309@canterbury.ac.nz> Stefan Behnel wrote: > After all, the described crash case indicates that > the Document destructor was called before all of the Element destructors > had been called, although all Elements reference their Document, but the > Document does not refer to any of the Elements, In that case, why was the GC system regarding this as a cycle at all? There must be more going on. -- Greg From glyph at twistedmatrix.com Sat May 7 03:39:10 2011 From: glyph at twistedmatrix.com (Glyph Lefkowitz) Date: Fri, 6 May 2011 21:39:10 -0400 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: Message-ID: Apologies in advance for contributing to an obviously and increasingly off-topic thread, but this kind of FUD about GC is a pet peeve of mine. On May 6, 2011, at 10:04 AM, Neal Becker wrote: > http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html Counterpoint: . Sorry Linus, sometimes correctness matters more than performance. But, even the performance argument is kind of bogus. See, for example, this paper on real-time garbage collection: . That's just one example of an easy-to-find solution to a problem that Linus holds up as unsolved or unsolvable. There are solutions to pretty much all of the problems that Linus brings up. One of these solutions is even famously implemented by CPython! The CPython "string +=" idiom optimization fixes at least one case of the "you tend to always copy the node" antipattern Linus describes, and lots of languages (especially Scheme and derivatives, IIRC) have very nice optimizations around this area. One could argue that any functional language without large pools of mutable state (i.e. Erlang) is a massive optimization for this case. Another example: the "dirty cache" problem Linus talks about can be addressed by having a GC that cooperates with the VMM: . And the "re-using stuff as fast as possible" thing is exactly the kind of problem that generational GCs address. When you run out of space in cache, you reap your first generation before you start copying stuff. One of the key insights of generational GC is that you'll usually reclaim enough (in this case, cache-local) memory that you can keep going for a little while. You don't have to read a super fancy modern paper on this, Wikipedia explains nicely: . Of course if you don't tune your GC at all for your machine-specific cache size, you won't see this performance benefit play out. I don't know if there's a programming language and runtime with a real-time, VM-cooperating garbage collector that actually exists today which has all the bells and whistles required to implement an OS kernel, so I wouldn't give the Linux kernel folks too much of a hard time for still using C; but there's nothing wrong with the idea in the abstract. The performance differences between automatic and manual GC are dubious at best, and with a really good GC and a language that supports it, GC tends to win big. When it loses, it loses in ways which can be fixed in one area of the code (the GC) rather than millions of tiny fixes across your whole codebase, as is the case with strategies used by manual collection algorithms. The assertion that "modern hardware" is not designed for big data-structure pointer-chasing is also a bit silly. On the contrary, modern hardware has evolved staggeringly massive caches, specifically because large programs (whether they're GC'd or not) tend to do lots of this kind of thing, because there's a certain level of complexity beyond which one can no longer avoid it. It's old hardware, with tiny caches (that were, by virtue of their tininess, closer to the main instruction-processing silicon), that was optimized for the "carefully stack-allocating everything in the world to conserve cache" approach. You can see this pretty clearly by running your favorite Python benchmark of choice on machines which are similar except for cache size. The newer machine, with the bigger cache, will run Python considerably faster, but doesn't help the average trivial C benchmark that much - or, for that matter, Linux benchmarks. -glyph -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.brandl at gmx.net Sat May 7 08:55:57 2011 From: g.brandl at gmx.net (Georg Brandl) Date: Sat, 07 May 2011 08:55:57 +0200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC48355.2050509@canterbury.ac.nz> References: <4DC48355.2050509@canterbury.ac.nz> Message-ID: On 07.05.2011 01:25, Greg Ewing wrote: > Neal Becker wrote: >> http://gcc.gnu.org/ml/gcc/2002-08/msg00552.html > > There, Linus says > >> For example, if you have an _explicit_ refcounting system, then it is >> quite natural to have operations like ... >> >> note_t *node = *np; >> if (node->count > 1) >> newnode = copy_alloc(node); > > It's interesting to note that, even though you *can* get reference > count information in CPython, it's not all that useful for doing > things like that, because it's hard to be sure how many incidental > references have been created on the way to the code concerned. > So tricks like this at the Python level aren't really feasible in > any robust way. But they are at the C level, see for example the optimization for string += something if "string"'s reference count is exactly one. Georg From stefan_ml at behnel.de Sat May 7 09:20:38 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 07 May 2011 09:20:38 +0200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: <4DC491A2.2060309@canterbury.ac.nz> References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC441D5.2070102@dcs.gla.ac.uk> <4DC491A2.2060309@canterbury.ac.nz> Message-ID: Greg Ewing, 07.05.2011 02:26: > Stefan Behnel wrote: >> After all, the described crash case indicates that the Document >> destructor was called before all of the Element destructors had been >> called, although all Elements reference their Document, but the Document >> does not refer to any of the Elements, > > In that case, why was the GC system regarding this as a cycle > at all? There must be more going on. It's a dead-end that is referenced by a cycle, that's all. Stefan From greg.ewing at canterbury.ac.nz Sat May 7 10:20:23 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 07 May 2011 20:20:23 +1200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: <20110506161233.1ed647ec@pitrou.net> <19908.8043.8921.50222@montanaro.dyndns.org> <4DC422BF.4010006@dcs.gla.ac.uk> <4DC42A9B.6020000@voidspace.org.uk> <4DC441D5.2070102@dcs.gla.ac.uk> <4DC491A2.2060309@canterbury.ac.nz> Message-ID: <4DC500C7.1070608@canterbury.ac.nz> Stefan Behnel wrote: > It's a dead-end that is referenced by a cycle, that's all. But shouldn't it be breaking the cycle by clearing one of the objects that's actually part of the cycle, rather than part of the dead-end? I can't see how the Document could get picked for clearing unless it was actually in the cycle. Either that or I'm imagining the cyclic GC algorithm to be smarter than it actually is. -- Greg From solipsis at pitrou.net Sat May 7 10:34:57 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 7 May 2011 10:34:57 +0200 Subject: [Python-Dev] Linus on garbage collection References: Message-ID: <20110507103457.1e586a76@pitrou.net> On Fri, 6 May 2011 21:39:10 -0400 Glyph Lefkowitz wrote: > > The assertion that "modern hardware" is not designed for big data-structure pointer-chasing is also a bit silly. On the contrary, modern hardware has evolved staggeringly massive caches, specifically because large programs (whether they're GC'd or not) tend to do lots of this kind of thing, because there's a certain level of complexity beyond which one can no longer avoid it. "Staggeringly massive"? The average 4MB L3 cache is very small compared to the heap of non-trivial Python (or Java) workloads. And Linus is right: modern hardware is not optimized for random pointer-chasing, simply because optimizing for it is very hard. Regards Antoine. From doug.hellmann at gmail.com Sat May 7 13:54:59 2011 From: doug.hellmann at gmail.com (Doug Hellmann) Date: Sat, 7 May 2011 07:54:59 -0400 Subject: [Python-Dev] Python Insider translations Message-ID: <23CF5EAF-FA24-48D3-89B5-E6C07F920FD1@gmail.com> I wanted to take a few minutes to let you all know that the recent call for help with translating Python Insider was met with a wave of enthusiastic contributors. We now have teams prepared to translate all posts to Simplified and Traditional Chinese, German, Japanese, Portuguese, Romanian, and Spanish. Setting up each blog takes a bit of effort, so we are launching them in batches as they are ready. When all of the existing teams are launched, I will be looking for translators for additional languages. The next time you have Python related information that you would like to share with the community, I hope you will consider working with us and publishing it through Python Insider, so it can reach the widest possible audience. Either Brian Curtin or I can help you get set up, so contact one of us directly when you are ready. Thanks, Doug From merwok at netwok.org Sat May 7 18:28:21 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Sat, 07 May 2011 18:28:21 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: <2ed4b4e7b4fc17cba2162535d2a220d8@netwok.org> Le 06/05/2011 20:57, Vinay Sajip a ?crit : > ?ric Araujo netwok.org> writes: >> Second: in packaging, we have two modules that create a logging >> handler. I?m not sure how if we should change the code or fix the >> tests >> to restore the _handlerList, or how. > > If you are saying this happens in your unit tests for packaging, then > you can > either restore the _handlerList using the approach in test_logging, > or else you > can just close the handlers when you've done with them. We create one handler in a command-line script, not in the lib, which is the Right Way AFAIU, but there is also one module that creates one handler (in order to set its level depending on a verbose attribute) deep in the library code, not in the command-line script, which I think is bad. Our tests that instantiate that object (dist.Distribution) end up modifying logging._handlerList, but I feel that the code is wrong, not the tests. The code is on https://bitbucket.org/tarek/cpython, in Lib/packaging. Thanks! From merwok at netwok.org Sat May 7 18:28:37 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Sat, 07 May 2011 18:28:37 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: <20110506200734.049872500DF@webabinitio.net> References: <20110506200734.049872500DF@webabinitio.net> Message-ID: <17c0c1bacc61292edec4600e3feb40f9@netwok.org> Hi, Le 06/05/2011 22:07, R. David Murray a ?crit : > On Fri, 06 May 2011 19:51:31 +0200, =?UTF-8?Q?=C3=89ric_Araujo?= > wrote: >> regrtest helpfully reports when a test leaves the environment >> unclean >> (sys.path, os.environ, logging._handlerList), but I think the >> implementation is buggy: it compares object identity and then value. >> Why is comparing identity useful? I?d just use ==. It makes >> writing >> cleanup code easier (just use addCleanup(setattr, obj, 'attr', >> copy(obj.attr))). > > Well, the implementation is intentional. Nick (I think) added the > identity check, and he had a reason at the time. I don't remember > what > it was, though. Drat. Nick, if it was indeed you, can you enlighten me? /off to replace all those addCleanup/setattr combos :( Regards From catch-all at masklinn.net Sat May 7 20:31:45 2011 From: catch-all at masklinn.net (Xavier Morel) Date: Sat, 7 May 2011 20:31:45 +0200 Subject: [Python-Dev] Linus on garbage collection In-Reply-To: References: Message-ID: On 2011-05-07, at 03:39 , Glyph Lefkowitz wrote: > > I don't know if there's a programming language and runtime with a real-time, VM-cooperating garbage collector that actually exists today which has all the bells and whistles required to implement an OS kernel, so I wouldn't give the Linux kernel folks too much of a hard time for still using C; but there's nothing wrong with the idea in the abstract. Not sure it had all those bells and whistles, and there were other issues, but I believe Lisp Machines implemented garbage collection at the hardware (or at least microcode) level, and the OS itself provided a pretty direct interface to it (it was part of the core services). From solipsis at pitrou.net Sat May 7 23:52:05 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Sat, 7 May 2011 23:52:05 +0200 Subject: [Python-Dev] cpython (2.7): Some tests were incorrectly marked as C specific. References: Message-ID: <20110507235205.162d414c@pitrou.net> On Sat, 07 May 2011 23:16:51 +0200 raymond.hettinger wrote: > > +class TestErrorHandling_Python(unittest.TestCase): > + module = py_heapq This class contains no tests. Regards Antoine. From vinay_sajip at yahoo.co.uk Sun May 8 16:22:18 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 8 May 2011 14:22:18 +0000 (UTC) Subject: [Python-Dev] Problems with regrtest and with logging References: <2ed4b4e7b4fc17cba2162535d2a220d8@netwok.org> Message-ID: ?ric Araujo netwok.org> writes: > The code is on https://bitbucket.org/tarek/cpython, in Lib/packaging. The cases you refer to seem to be _set_logger in packaging/run.py (which appears not to be used at all - there appear to be no other references to it in the code), Dispatcher.__init__ in packaging/run.py and Distribution.parse_command_line in packaging/dist.py. I can't see why the first case is there. In the second and third cases, can you be sure that only one of these code paths will be executed, at most once? If not, multiple StreamHandler instances would be added to the logger, resulting in duplicated messages. If the code paths will be executed at most once, then the code seems to be acceptable. You may wish to add a guard using "if not logger.hasHandlers():" so that even if the code is executed multiple times, a handler isn't added multiple times. In the case of the test support code, I'm not really sure that LoggingCatcher is needed. There is already a TestHandler class in test.support which captures records in a buffer, and allows flexible matching for assertions, as described in http://plumberjack.blogspot.com/2010/09/unit-testing-and-logging.html The _handlerList in logging contains weak references to handlers, and when the referent is finalised, it's removed from the list. If you want to control this more finely, you could do something like (untested): class MyTestCase(unittest.TestCase): def setUp(self): self.handler = TestHandler(Matcher()) logging.getLogger().addHandler(self.handler) def tearDown(self): logging.getLogger().removeHandler(self.handler) self.handler.close() refs = weakref.getweakrefs(self.handler) for ref in refs: logging._removeHandlerRef(ref) def test_something(self): logging.warning('Test') self.assertTrue(self.handler.matches(message='Test')) Regards, Vinay Sajip From victor.stinner at haypocalc.com Mon May 9 12:32:48 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Mon, 09 May 2011 12:32:48 +0200 Subject: [Python-Dev] Commit changelog: issue number and merges Message-ID: <1304937168.22910.21.camel@marge> Hi, Commit changelogs are important to understand why the code was changed. I regulary use hg blame to search which commit introduced a particular line of code, and I am always happy if I can find an issue number because it usually contains the whole story. And since the migration to Mercurial, we have also a great tool adding a comment to an issue if the changelog contains an issue number (e.g. changelog starting with "Issue #118888: ..."). So if someone watchs an issue (is in the nosy list), (s)he will be noticed that a related commit was pushed. It is not exactly something new: we already do that with Subversion except that today it is more automatic. I noticed that some recent commits don't contain the issue number: please try to always prefix your changelog with the issue number. It is not "mandatory", but it helps me when I dig the Python history. -- For merge commits: many developers just write "merge" or "merge 3.1". I have to go to the parent commit (and something to the grandparent, 3.1->3.2->3.3) to learn more about the commit. Would it be possible to repeat the changelog of the original commit in the merge commits? svnmerge toold prepared a nice changelog containing the changelog of all pendings commits, even when a commit was "blocked". For a merge commit, I copy/paste the changelog of the original commit and I add a "(Merge 3.1) " prefix. I prefer to add explictly a prefix because it is not easy to notice that it is a merge commit in a python-checkins email or in the history of hg.python.org. We need maybe new tools to help the process. -- Usecases needing better changelogs: - "All changes" section of a buildbot build - hg blame (or just hg log) Victor From rdmurray at bitdance.com Mon May 9 14:40:03 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 09 May 2011 08:40:03 -0400 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <1304937168.22910.21.camel@marge> References: <1304937168.22910.21.camel@marge> Message-ID: <20110509124003.EB9D5250044@webabinitio.net> On Mon, 09 May 2011 12:32:48 +0200, Victor Stinner wrote: > For merge commits: many developers just write "merge" or "merge 3.1". I > have to go to the parent commit (and something to the grandparent, > 3.1->3.2->3.3) to learn more about the commit. > > Would it be possible to repeat the changelog of the original commit in > the merge commits? svnmerge toold prepared a nice changelog containing > the changelog of all pendings commits, even when a commit was "blocked". > > For a merge commit, I copy/paste the changelog of the original commit > and I add a "(Merge 3.1) " prefix. I prefer to add explictly a prefix > because it is not easy to notice that it is a merge commit in a > python-checkins email or in the history of hg.python.org. +1. What I do is, in the edit window for the commit message, I pull in .hg/last-message.txt, and just type 'Merge' in front of my previous first line. I don't add the merge-from number, because I figure if you know which branch you are looking at you know which branch the merge came from, given that there is a strict progression. -- R. David Murray http://www.bitdance.com From jimjjewett at gmail.com Mon May 9 14:53:52 2011 From: jimjjewett at gmail.com (Jim Jewett) Date: Mon, 9 May 2011 08:53:52 -0400 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #11277: Remove useless test from test_zlib. In-Reply-To: References: Message-ID: Can you clarify (preferably in the commit message as well) exactly *why* these largefile tests are useless? For example, is there another test that covers this already? -jJ On 5/7/11, nadeem.vawda wrote: > http://hg.python.org/cpython/rev/201dcfc56e86 > changeset: 69886:201dcfc56e86 > branch: 2.7 > parent: 69881:a0147a1f1776 > user: Nadeem Vawda > date: Sat May 07 11:28:03 2011 +0200 > summary: > Issue #11277: Remove useless test from test_zlib. > > files: > Lib/test/test_zlib.py | 42 ------------------------------- > 1 files changed, 0 insertions(+), 42 deletions(-) > > > diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py > --- a/Lib/test/test_zlib.py > +++ b/Lib/test/test_zlib.py > @@ -72,47 +72,6 @@ > zlib.crc32('spam', (2**31))) > > > -# Issue #11277 - check that inputs of 2 GB (or 1 GB on 32 bits system) are > -# handled correctly. Be aware of issues #1202. We cannot test a buffer of 4 > GB > -# or more (#8650, #8651 and #10276), because the zlib stores the buffer > size > -# into an int. > -class ChecksumBigBufferTestCase(unittest.TestCase): > - if sys.maxsize > _4G: > - # (64 bits system) crc32() and adler32() stores the buffer size > into an > - # int, the maximum filesize is INT_MAX (0x7FFFFFFF) > - filesize = 0x7FFFFFFF > - else: > - # (32 bits system) On a 32 bits OS, a process cannot usually > address > - # more than 2 GB, so test only 1 GB > - filesize = _1G > - > - @unittest.skipUnless(mmap, "mmap() is not available.") > - def test_big_buffer(self): > - if sys.platform[:3] == 'win' or sys.platform == 'darwin': > - requires('largefile', > - 'test requires %s bytes and a long time to run' % > - str(self.filesize)) > - try: > - with open(TESTFN, "wb+") as f: > - f.seek(self.filesize-4) > - f.write("asdf") > - f.flush() > - m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) > - try: > - if sys.maxsize > _4G: > - self.assertEqual(zlib.crc32(m), 0x709418e7) > - self.assertEqual(zlib.adler32(m), -2072837729) > - else: > - self.assertEqual(zlib.crc32(m), 722071057) > - self.assertEqual(zlib.adler32(m), -1002962529) > - finally: > - m.close() > - except (IOError, OverflowError): > - raise unittest.SkipTest("filesystem doesn't have largefile > support") > - finally: > - unlink(TESTFN) > - > - > class ExceptionTestCase(unittest.TestCase): > # make sure we generate some expected errors > def test_badlevel(self): > @@ -595,7 +554,6 @@ > def test_main(): > run_unittest( > ChecksumTestCase, > - ChecksumBigBufferTestCase, > ExceptionTestCase, > CompressTestCase, > CompressObjectTestCase > > -- > Repository URL: http://hg.python.org/cpython > From eliben at gmail.com Mon May 9 14:56:57 2011 From: eliben at gmail.com (Eli Bendersky) Date: Mon, 9 May 2011 15:56:57 +0300 Subject: [Python-Dev] more timely detection of unbound locals Message-ID: Hi all, It's a known Python gotcha (*) that the following code: x = 5 def foo(): print(x) x = 1 print(x) foo() Will throw: UnboundLocalError: local variable 'x' referenced before assignment On the usage of 'x' in the *first* print. Recently, while reading the zillionth question on StackOverflow on some variation of this case, I started thinking whether this behavior is desired or just an implementation artifact. IIUC, the reason it behaves this way is that the symbol table logic goes over the code before the code generation runs, sees the assignment 'x = 1` and marks 'x' as local in foo. Then, the code generator generates LOAD_FAST for all loads of 'x' in 'foo', even though 'x' is actually bound locally after the first print. When the bytecode is run, since it's LOAD_FAST and no store was made into the local 'x', ceval.c then throws the exception. On first sight, it's possible to signal that 'x' truly becomes local only after it's bound in the scope (and before that LOAD_NAME can be generated for it instead of LOAD_FAST). To do this, some modifications to the symbol table creation and usage are required, because we can no longer say "x is local in this block", but rather should attach scope information to each instance of "x". This has some overhead, but it's only at the compilation stage so it shouldn't have a real effect on the runtime of Python code. This is also less convenient and "clean" than the current approach - this is why I'm wondering whether the behavior is an artifact of the implementation. Would it not be worth to make Python's behavior more expected in this case, at the cost of some implementation complexity? What are the cons to making such a change? At least judging by the amount of people getting confused by it, maybe it's in line with the zen of Python to behave more explicitly here. Thanks in advance, Eli (*) Variation of this FAQ: http://docs.python.org/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value -------------- next part -------------- An HTML attachment was scrubbed... URL: From jimjjewett at gmail.com Mon May 9 15:00:17 2011 From: jimjjewett at gmail.com (Jim Jewett) Date: Mon, 9 May 2011 09:00:17 -0400 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: Message-ID: Are you asserting that all foreign modules (or at least all handled by this) are in C, as opposed to C++ or even Java or Fortran? (And the C won't change?) Is this ASCII restriction (as opposed to even UTF8) really needed? Or are you just saying that we need to create an ASCII name for passing to C? -jJ On 5/7/11, victor.stinner wrote: > http://hg.python.org/cpython/rev/eb003c3d1770 > changeset: 69889:eb003c3d1770 > user: Victor Stinner > date: Sat May 07 12:46:05 2011 +0200 > summary: > _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII > > The name must be encodable to ASCII because dynamic module must have a > function > called "PyInit_NAME", they are written in C, and the C language doesn't > accept > non-ASCII identifiers. > > files: > Python/importdl.c | 40 +++++++++++++++++++++------------- > 1 files changed, 25 insertions(+), 15 deletions(-) > > > diff --git a/Python/importdl.c b/Python/importdl.c > --- a/Python/importdl.c > +++ b/Python/importdl.c > @@ -20,31 +20,36 @@ > const char *pathname, FILE *fp); > #endif > > -/* name should be ASCII only because the C language doesn't accept > non-ASCII > - identifiers, and dynamic modules are written in C. */ > - > PyObject * > _PyImport_LoadDynamicModule(PyObject *name, PyObject *path, FILE *fp) > { > - PyObject *m; > + PyObject *m = NULL; > #ifndef MS_WINDOWS > PyObject *pathbytes; > #endif > + PyObject *nameascii; > char *namestr, *lastdot, *shortname, *packagecontext, *oldcontext; > dl_funcptr p0; > PyObject* (*p)(void); > struct PyModuleDef *def; > > - namestr = _PyUnicode_AsString(name); > - if (namestr == NULL) > - return NULL; > - > m = _PyImport_FindExtensionObject(name, path); > if (m != NULL) { > Py_INCREF(m); > return m; > } > > + /* name must be encodable to ASCII because dynamic module must have a > + function called "PyInit_NAME", they are written in C, and the C > language > + doesn't accept non-ASCII identifiers. */ > + nameascii = PyUnicode_AsEncodedString(name, "ascii", NULL); > + if (nameascii == NULL) > + return NULL; > + > + namestr = PyBytes_AS_STRING(nameascii); > + if (namestr == NULL) > + goto error; > + > lastdot = strrchr(namestr, '.'); > if (lastdot == NULL) { > packagecontext = NULL; > @@ -60,34 +65,33 @@ > #else > pathbytes = PyUnicode_EncodeFSDefault(path); > if (pathbytes == NULL) > - return NULL; > + goto error; > p0 = _PyImport_GetDynLoadFunc(shortname, > PyBytes_AS_STRING(pathbytes), fp); > Py_DECREF(pathbytes); > #endif > p = (PyObject*(*)(void))p0; > if (PyErr_Occurred()) > - return NULL; > + goto error; > if (p == NULL) { > PyErr_Format(PyExc_ImportError, > "dynamic module does not define init function" > " (PyInit_%s)", > shortname); > - return NULL; > + goto error; > } > oldcontext = _Py_PackageContext; > _Py_PackageContext = packagecontext; > m = (*p)(); > _Py_PackageContext = oldcontext; > if (m == NULL) > - return NULL; > + goto error; > > if (PyErr_Occurred()) { > - Py_DECREF(m); > PyErr_Format(PyExc_SystemError, > "initialization of %s raised unreported exception", > shortname); > - return NULL; > + goto error; > } > > /* Remember pointer to module init function. */ > @@ -101,12 +105,18 @@ > Py_INCREF(path); > > if (_PyImport_FixupExtensionObject(m, name, path) < 0) > - return NULL; > + goto error; > if (Py_VerboseFlag) > PySys_FormatStderr( > "import %U # dynamically loaded from %R\n", > name, path); > + Py_DECREF(nameascii); > return m; > + > +error: > + Py_DECREF(nameascii); > + Py_XDECREF(m); > + return NULL; > } > > #endif /* HAVE_DYNAMIC_LOADING */ > > -- > Repository URL: http://hg.python.org/cpython > From orsenthil at gmail.com Mon May 9 15:08:48 2011 From: orsenthil at gmail.com (Senthil Kumaran) Date: Mon, 9 May 2011 21:08:48 +0800 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <20110509124003.EB9D5250044@webabinitio.net> References: <1304937168.22910.21.camel@marge> <20110509124003.EB9D5250044@webabinitio.net> Message-ID: <20110509130848.GA2402@kevin> On Mon, May 09, 2011 at 08:40:03AM -0400, R. David Murray wrote: > +1. What I do is, in the edit window for the commit message, I pull > in .hg/last-message.txt, and just type 'Merge' in front of my previous Thanks for this tip. I shall start following this one too. -- Senthil From ijmorlan at uwaterloo.ca Mon May 9 15:26:38 2011 From: ijmorlan at uwaterloo.ca (Isaac Morland) Date: Mon, 9 May 2011 09:26:38 -0400 (EDT) Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: On Mon, 9 May 2011, Eli Bendersky wrote: > It's a known Python gotcha (*) that the following code: > > x = 5 > def foo(): > print(x) > x = 1 > print(x) > foo() > > Will throw: > > UnboundLocalError: local variable 'x' referenced before assignment > > On the usage of 'x' in the *first* print. Recently, while reading the > zillionth question on StackOverflow on some variation of this case, I > started thinking whether this behavior is desired or just an implementation > artifact. > > IIUC, the reason it behaves this way is that the symbol table logic goes > over the code before the code generation runs, sees the assignment 'x = 1` > and marks 'x' as local in foo. Then, the code generator generates LOAD_FAST > for all loads of 'x' in 'foo', even though 'x' is actually bound locally > after the first print. When the bytecode is run, since it's LOAD_FAST and no > store was made into the local 'x', ceval.c then throws the exception. > > On first sight, it's possible to signal that 'x' truly becomes local only > after it's bound in the scope (and before that LOAD_NAME can be generated > for it instead of LOAD_FAST). To do this, some modifications to the symbol > table creation and usage are required, because we can no longer say "x is > local in this block", but rather should attach scope information to each > instance of "x". This has some overhead, but it's only at the compilation > stage so it shouldn't have a real effect on the runtime of Python code. This > is also less convenient and "clean" than the current approach - this is why > I'm wondering whether the behavior is an artifact of the implementation. x = 5 def foo (): print (x) if bar (): x = 1 print (x) Isaac Morland CSCF Web Guru DC 2554C, x36650 WWW Software Specialist From stefan_ml at behnel.de Mon May 9 15:27:09 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 09 May 2011 15:27:09 +0200 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: Eli Bendersky, 09.05.2011 14:56: > It's a known Python gotcha (*) that the following code: > > x = 5 > def foo(): > print(x) > x = 1 > print(x) > foo() > > Will throw: > > UnboundLocalError: local variable 'x' referenced before assignment > > On the usage of 'x' in the *first* print. Recently, while reading the > zillionth question on StackOverflow on some variation of this case, I > started thinking whether this behavior is desired or just an implementation > artifact. Well, basically any compiler these days can detect that a variable is being used before assignment, or at least that this is possibly the case, depending on prior branching. ISTM that your suggestion is to let x refer to the outer x up to the assignment and to the inner x from that point on. IMHO, that's much worse than the current behaviour and potentially impractical due to conditional assignments. However, it's also a semantic change to reject code with unbound locals at compile time, as the specific code in question may actually be unreachable at runtime. This makes me think that it would be best to discuss this on the python-ideas list first. If nothing else, I'd like to see a discussion on this behaviour being an implementation detail of CPython or a feature of the Python language. Stefan From ericsnowcurrently at gmail.com Mon May 9 15:41:43 2011 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Mon, 9 May 2011 07:41:43 -0600 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: On May 9, 2011 6:59 AM, "Eli Bendersky" wrote: > > Hi all, > > It's a known Python gotcha (*) that the following code: > > x = 5 > def foo(): > print(x) > x = 1 > print(x) > foo() > > Will throw: > > UnboundLocalError: local variable 'x' referenced before assignment > > On the usage of 'x' in the *first* print. Recently, while reading the zillionth question on StackOverflow on some variation of this case, I started thinking whether this behavior is desired or just an implementation artifact. > > IIUC, the reason it behaves this way is that the symbol table logic goes over the code before the code generation runs, sees the assignment 'x = 1` and marks 'x' as local in foo. Then, the code generator generates LOAD_FAST for all loads of 'x' in 'foo', even though 'x' is actually bound locally after the first print. When the bytecode is run, since it's LOAD_FAST and no store was made into the local 'x', ceval.c then throws the exception. > > On first sight, it's possible to signal that 'x' truly becomes local only after it's bound in the scope (and before that LOAD_NAME can be generated for it instead of LOAD_FAST). To do this, some modifications to the symbol table creation and usage are required, because we can no longer say "x is local in this block", but rather should attach scope information to each instance of "x". This has some overhead, but it's only at the compilation stage so it shouldn't have a real effect on the runtime of Python code. This is also less convenient and "clean" than the current approach - this is why I'm wondering whether the behavior is an artifact of the implementation. > > Would it not be worth to make Python's behavior more expected in this case, at the cost of some implementation complexity? What are the cons to making such a change? At least judging by the amount of people getting confused by it, maybe it's in line with the zen of Python to behave more explicitly here. This is about mixing scopes for the the same name in the same block, right? Perhaps a more specific error would be enough, unless there is a good use case for having that mixed scope for the name. -eric > Thanks in advance, > Eli > > (*) Variation of this FAQ: http://docs.python.org/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value > > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/ericsnowcurrently%40gmail.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nadeem.vawda at gmail.com Mon May 9 16:08:55 2011 From: nadeem.vawda at gmail.com (Nadeem Vawda) Date: Mon, 9 May 2011 16:08:55 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): Issue #11277: Remove useless test from test_zlib. In-Reply-To: References: Message-ID: On Mon, May 9, 2011 at 2:53 PM, Jim Jewett wrote: > Can you clarify (preferably in the commit message as well) exactly > *why* these largefile tests are useless? For example, is there > another test that covers this already? Ah, sorry about that. It was discussed on the tracker issue, but I guess I can't expect people to read through 90+ messages to figure it out :P The short version is that it was supposed to test 4GB+ inputs, but in 2.7, the functions being tested don't accept inputs that large. The details: The test was originally intended to catch the case where crc32() or adler32() would get a buffer of >=4GB, and then silently truncate the buffer size and produce an incorrect result (issue10276). It had been written for 3.x, and then backported to 2.7. However, in 2.7, zlibmodule.c doesn't define PY_SSIZE_T_CLEAN, so passing in a buffer of >=2GB raises an OverflowError (see issue8651). This means that it is impossible to trigger the bug in question on 2.7, making the test pointless. Of course, the code that was deleted tests with an input sized 2GB-1 or 1GB, rather than 4GB (the size used in 3.x). When the test was backported, the size of the input was reduced, to avoid triggering an OverflowException. At the time, no-one realized that this also would not trigger the bug being tested for; it only came to light when the test started crashing for unrelated reasons (issue11277). Cheers, Nadeem From benjamin at python.org Mon May 9 16:08:53 2011 From: benjamin at python.org (Benjamin Peterson) Date: Mon, 9 May 2011 09:08:53 -0500 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <1304937168.22910.21.camel@marge> References: <1304937168.22910.21.camel@marge> Message-ID: 2011/5/9 Victor Stinner : > Hi, > > Commit changelogs are important to understand why the code was changed. > I regulary use hg blame to search which commit introduced a particular > line of code, and I am always happy if I can find an issue number > because it usually contains the whole story. > > And since the migration to Mercurial, we have also a great tool adding a > comment to an issue if the changelog contains an issue number (e.g. > changelog starting with "Issue #118888: ..."). So if someone watchs an > issue (is in the nosy list), (s)he will be noticed that a related commit > was pushed. It is not exactly something new: we already do that with > Subversion except that today it is more automatic. > > I noticed that some recent commits don't contain the issue number: > please try to always prefix your changelog with the issue number. It is > not "mandatory", but it helps me when I dig the Python history. > > -- > > For merge commits: many developers just write "merge" or "merge 3.1". I > have to go to the parent commit (and something to the grandparent, > 3.1->3.2->3.3) to learn more about the commit. I thought the whole point of merging was that you brought a changeset from one branch to another. This why I just write "merge" because otherwise you're technically duplicating information that is pulled onto the branch by merging. It seems like something that should be solved by tools like a display visual graph indicating what is merged. (like Bazaar) -- Regards, Benjamin From victor.stinner at haypocalc.com Mon May 9 16:11:15 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Mon, 09 May 2011 16:11:15 +0200 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: Message-ID: <1304950275.22910.32.camel@marge> Le lundi 09 mai 2011 ? 09:00 -0400, Jim Jewett a ?crit : > Are you asserting that all foreign modules (or at least all handled by > this) are in C, as opposed to C++ or even Java or Fortran? (And the C > won't change?) C and C++ identifiers are restricted to ASCII. I don't know for Fortran or Java. Is it possible to write a CPython extension module in Java or Fortran? (My change doesn't concern Jython: it's an implementation detail of dynamic modules in CPython.) > Is this ASCII restriction (as opposed to even UTF8) really needed? I prefer to explicitly limit module names of dynamic modules to ASCII. If we decide to extend the support to something else than ASCII, we will need a working module to test it, and maybe also a test. > Or are you just saying that we need to create an ASCII name for passing to C? You pass a Unicode module name to import (import h? or __import__('h?')), and Python encodes the name to ASCII if it is a dynamic module. It is still possible to use non-ASCII module names, but only for modules written in Python. Victor From victor.stinner at haypocalc.com Mon May 9 16:14:03 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Mon, 09 May 2011 16:14:03 +0200 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: References: <1304937168.22910.21.camel@marge> Message-ID: <1304950443.22910.34.camel@marge> Le lundi 09 mai 2011 ? 09:08 -0500, Benjamin Peterson a ?crit : > It seems like something that should be solved by tools like a display > visual graph indicating what is merged. (like Bazaar) Yeah, we could fix buildbot, hg.python.org website, improve hg log, and all other tools using Mercurial. But until that, I would prefer to duplicate the information. Victor From ncoghlan at gmail.com Mon May 9 16:36:04 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 00:36:04 +1000 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <20110506122703.17c4d889@pitrou.net> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> Message-ID: On Fri, May 6, 2011 at 8:27 PM, Antoine Pitrou wrote: > On Fri, 06 May 2011 13:28:11 +1200 > Greg Ewing wrote: > >> Amaury Forgeot d'Arc wrote [concerning the Doc/data/refcounts.dat file]: >> >> > This is not always true, for example when the item is already present >> > in the dict. >> > It's not important to know what the function does to the object, >> > Only the action on the reference is relevant. >> >> Yes, that's the whole point. When using a functon, >> what you need to know is whether it borrows or steals >> a reference. > > Doesn't "borrow" mean the same as "steal" in that context? > If an API borrows a reference, I expect it to take it from me. Input parameter, borrowed or new reference: caller retains ownership and must still decref item Input parameter, stolen reference: caller transfers ownership and must NOT decref item (or must incref before call to guarantee lifecycle if planning to continue using the object after the call) Output parameter or return value, borrowed reference: caller does NOT receive ownership and does not need to decref item, but needs to be careful of lifecycle (and promote to a full reference with incref if the borrowed reference may outlive the original) Output parameter or return value, stolen or new reference: caller receives ownership and must decref item One interesting aspect is that from the caller's point of view, a *new* reference to the relevant behaves like a borrowed reference for input parameters, but like a stolen reference for output parameters and return values. It is typically the converse cases (stolen reference to an input parameter, borrowed reference to an output parameter or return value) that requires special attention on the caller's part. Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From steve at pearwood.info Mon May 9 16:45:09 2011 From: steve at pearwood.info (Steven D'Aprano) Date: Tue, 10 May 2011 00:45:09 +1000 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: <4DC7FDF5.9060003@pearwood.info> Eli Bendersky wrote: > Hi all, > > It's a known Python gotcha (*) that the following code: > > x = 5 > def foo(): > print(x) > x = 1 > print(x) > foo() > > Will throw: > > UnboundLocalError: local variable 'x' referenced before assignment I think part of the problem is that UnboundLocalError is a jargon name, while it's predecessor NameError (used up to Python 1.5) is far more intuitively obvious. > On the usage of 'x' in the *first* print. Recently, while reading the > zillionth question on StackOverflow on some variation of this case, I > started thinking whether this behavior is desired or just an implementation > artifact. [...] > Would it not be worth to make Python's behavior more expected in this case, > at the cost of some implementation complexity? What are the cons to making > such a change? At least judging by the amount of people getting confused by > it, maybe it's in line with the zen of Python to behave more explicitly > here. I think you are making an unwarranted assumption about what is "more expected". I presume you are thinking that the expected behaviour is that foo() should: print global x (5) assign 1 to local x print local x (1) If we implemented this change, there would be no more questions about UnboundLocalError, but instead there would be lots of questions like "why is it that globals revert to their old value after I change them in a function?". -- Steven From ncoghlan at gmail.com Mon May 9 17:00:38 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 01:00:38 +1000 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: On Sat, May 7, 2011 at 3:51 AM, ?ric Araujo wrote: > regrtest helpfully reports when a test leaves the environment unclean > (sys.path, os.environ, logging._handlerList), but I think the implementation > is buggy: it compares object identity and then value. ?Why is comparing > identity useful? ?I?d just use ==. ?It makes writing cleanup code easier > (just use addCleanup(setattr, obj, 'attr', copy(obj.attr))). Because changing the identity of any of those global state attributes that regrtest monitors is itself suggestive of a bug. When it comes to containers, identity matters at least as much as value does (and sometimes more so - e.g. sys.modules). Replacing those global containers with new ones isn't guaranteed to work, as they may be cached in various places rather than always retrieved fresh from the relevant module namespace. Modifying them in place, on the other hand, does the right thing even in the presence of cached references. A comment to that effect may be a useful addition to regrtest, as I expect others may have similar questions about those identity checks in the future. (It may even be a useful addition to the documentation, but I have no idea where it could be sensibly included). Also, don't be surprised if wholesale cleanup like that isn't completely reliable - it's far, far better if the test case understands the changes it is making (even indirectly) and explicitly reverses them. Save-and-restore should be a last resort technique (although context managers that are designed for more general use, such as warnings.catch_warnings(), use save-and-restore by necessity, since they have no control over the body of the relevant with statements). Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From eliben at gmail.com Mon May 9 17:01:06 2011 From: eliben at gmail.com (Eli Bendersky) Date: Mon, 9 May 2011 18:01:06 +0300 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: <4DC7FDF5.9060003@pearwood.info> References: <4DC7FDF5.9060003@pearwood.info> Message-ID: > I think you are making an unwarranted assumption about what is "more > expected". I presume you are thinking that the expected behaviour is that > foo() should: > > print global x (5) > assign 1 to local x > print local x (1) > > If we implemented this change, there would be no more questions about > UnboundLocalError, but instead there would be lots of questions like "why is > it that globals revert to their old value after I change them in a > function?". > True, but this is less confusing and follows the rules in a more straightforward way. x = 1 without a 'global x' assigns a local x, this make sense and is similar to what happens in C where an inner declaration temporarily shadows a global one. Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From ncoghlan at gmail.com Mon May 9 17:04:21 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 01:04:21 +1000 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: Message-ID: On Mon, May 9, 2011 at 11:00 PM, Jim Jewett wrote: > Are you asserting that all foreign modules (or at least all handled by > this) are in C, as opposed to C++ or even Java or Fortran? ?(And the C > won't change?) The extension module that interfaces them to CPython will be written in C, or something that can export a C-compatible library interface (after reading in the Python C API headers). Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From eliben at gmail.com Mon May 9 17:06:18 2011 From: eliben at gmail.com (Eli Bendersky) Date: Mon, 9 May 2011 18:06:18 +0300 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: > x = 5 > def foo (): > print (x) > if bar (): > x = 1 > print (x) > I wish you'd annotate this code sample, what do you intend it to demonstrate? It probably shows the original complaint even more strongly. As for being a problem with the suggested solution, I suppose you're right, although it doesn't make it much different. Still, before a *possible* assignment to 'x', it should be loaded as LOAD_NAME since it was surely not bound as local, yet. Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From ncoghlan at gmail.com Mon May 9 17:17:35 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 01:17:35 +1000 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: <4DC7FDF5.9060003@pearwood.info> Message-ID: On Tue, May 10, 2011 at 1:01 AM, Eli Bendersky wrote: > >> I think you are making an unwarranted assumption about what is "more >> expected". I presume you are thinking that the expected behaviour is that >> foo() should: >> >> print global x (5) >> assign 1 to local x >> print local x (1) >> >> If we implemented this change, there would be no more questions about >> UnboundLocalError, but instead there would be lots of questions like "why is >> it that globals revert to their old value after I change them in a >> function?". > > True, but this is less confusing and follows the rules in a more > straightforward way. x = 1 without a 'global x' assigns a local x, this make > sense and is similar to what happens in C where an inner declaration > temporarily shadows a global one. However, since flow control constructs in Python don't create new scopes (unlike C/C++), you run into a fundamental problem with cases like the one Isaac posted, or even nastier ones like the following: def f(): if bar(): fill = 1 else: fiil = 2 print(fill) # Q: What does this do when bool(bar()) is False? Since we want to make the decision categorically at compile-time, the simplest, least-confusing option is to say "assignment makes a variable name local, referencing it before the first assignment is now an error". I don't know of anyone that particularly *likes* UnboundLocalError, but it's better than letting errors like the one above pass silently. (It obviously doesn't trap *all* typo-related errors, but it at least lets you reason sanely about name bindings) On the reasoning-sanely front, closures likely present a more compelling argument: def f(): def g(): print(x) # We want this to refer to the closure in f(), thanks x = 1 return g UnboundLocalError is really about aligning the rules for the current scope with those for references from nested scopes (i.e. x is a local variable of f, whether it is referenced from f's local scope, or any nested scope within f) Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From ncoghlan at gmail.com Mon May 9 17:22:36 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 01:22:36 +1000 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: On Tue, May 10, 2011 at 1:06 AM, Eli Bendersky wrote: > It probably shows the original complaint even more strongly. As for being a > problem with the suggested solution, I suppose you're right, although it > doesn't make it much different. Still, before a *possible* assignment to > 'x', it should be loaded as LOAD_NAME since it was surely not bound as > local, yet. Yeah, I've decided I'm happier with the closure based arguments than the conditional statement related ones. "Assignments create local variables" is a relatively simple rule to reason about, and is equally valid for the current scope and for any nested scopes. The symtable analysis for nested scopes is ordering independent (and can't be changed for backwards compatibility reasons if nothing else), and UnboundLocalError is a natural outgrowth of applying those semantics to the current scope as well. Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From rdmurray at bitdance.com Mon May 9 17:44:15 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 09 May 2011 11:44:15 -0400 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: References: <1304937168.22910.21.camel@marge> Message-ID: <20110509154416.35BBF250037@webabinitio.net> On Mon, 09 May 2011 09:08:53 -0500, Benjamin Peterson wrote: > I thought the whole point of merging was that you brought a changeset > from one branch to another. This why I just write "merge" because > otherwise you're technically duplicating information that is pulled > onto the branch by merging. No it isn't. The commit message isn't pulled into the new branch. > It seems like something that should be solved by tools like a display > visual graph indicating what is merged. (like Bazaar) You'd need some extension to hg log that would show the original commit message for the first changeset in the merge line in order to "fix" this. I doubt that is going to happen. Note that saying just 'merge' makes perfect sense when you are pulling in a whole group of changesets in order to synchronize two branches. But if you are applying a single changeset to multiple branches, as we often do in our workflow, then I think duplicating the commit message is (1) easy to do and (2) very helpful when looking at hg log output. -- R. David Murray http://www.bitdance.com From ijmorlan at uwaterloo.ca Mon May 9 17:44:21 2011 From: ijmorlan at uwaterloo.ca (Isaac Morland) Date: Mon, 9 May 2011 11:44:21 -0400 (EDT) Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: On Mon, 9 May 2011, Eli Bendersky wrote: >> x = 5 >> def foo (): >> print (x) >> if bar (): >> x = 1 >> print (x) >> > > I wish you'd annotate this code sample, what do you intend it to > demonstrate? > > It probably shows the original complaint even more strongly. As for being a > problem with the suggested solution, I suppose you're right, although it > doesn't make it much different. Still, before a *possible* assignment to > 'x', it should be loaded as LOAD_NAME since it was surely not bound as > local, yet. Extrapolating from your suggestion, you're saying before a *possible* assignment it will be treated as global, and after a *possible* assignment it will be treated as local? But surely: print (x) if False: x = 1 print (x) should always print the same thing twice (in the absence of actions taken by other threads)! Replace "False" by something that is usually (but not always) True, and "print (x)" by something that actually does something, and you had best put on your helmet because it's going to be a fun ride. But I won't be on it. The idea that the same name within the same scope always refers to the same value is an idea from functional programming and not part of Python; but surely the same name within the same scope should at least always refer to the same variable! If something is to be done here, it occurs to me that the same parser that decides that the initial reference to x should use the local x could conceivably issue an error right away - "local variable can never be assigned before use" rather than waiting until runtime. But even if I haven't confused myself about the possibility of this raising a false positive (and it certainly could in the presence of dead code), it wouldn't catch cases of conditional premature use of a local variable. I think in those cases people would still ask the same questions they do with the existing implementation. Isaac Morland CSCF Web Guru DC 2554C, x36650 WWW Software Specialist From merwok at netwok.org Mon May 9 17:55:42 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Mon, 09 May 2011 17:55:42 +0200 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: References: <1304937168.22910.21.camel@marge> Message-ID: <7fa082450fb750d082e71d5070a62171@netwok.org> Hi, Le 09/05/2011 16:08, Benjamin Peterson a ?crit : > 2011/5/9 Victor Stinner : >> For merge commits: many developers just write "merge" or "merge >> 3.1". I >> have to go to the parent commit (and something to the grandparent, >> 3.1->3.2->3.3) to learn more about the commit. I follow conventions I?ve seen elsewhere (maybe Mercurial itself): I use ?Branch merge? when I merge anonymous branches on the same named branch, and ?Merge x.y? for forward-porting across named branches. I also tend to do more than one commit before merging. It would not be very easy with my current toolchain to get the commit message(s) to insert into the new message, and I think it?s not necessary. > I thought the whole point of merging was that you brought a changeset > from one branch to another. This why I just write "merge" because > otherwise you're technically duplicating information that is pulled > onto the branch by merging. +1. No interest in manually duplicating available information. Le 09/05/2011 17:44, R. David Murray a ?crit : > No it isn't. The commit message isn't pulled into the new branch. Sorry, your terminology does not make sense. If you mean that the commit message is not reused in the new commit after the merge, it?s true. However, the commit message with the relevant information is available as part of the changesets that have been pulled and merged. Regards From merwok at netwok.org Mon May 9 18:36:43 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Mon, 09 May 2011 18:36:43 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: "\"" " <2ed4b4e7b4fc17cba2162535d2a220d8@netwok.org> Message-ID: Hi, Thanks for the help. I didn?t know about handler.close. (By which I mean that I used logging without re-reading its documentation, which is a testimony to its usability :) > The cases you refer to seem to be _set_logger in packaging/run.py > (which appears > not to be used at all - there appear to be no other references to it > in the > code), Yep, probably dead code. I think that an handler should be defined only once, in the ?if __name__ == '__main__'? block. Am I right? Just like you don?t call sys.exit from library code (hello optparse!), you don?t set logging handlers in library code, only in the outmost layer of the script. > Dispatcher.__init__ in packaging/run.py and This is the new-fangled command line parser, which can run global (Python-wide) commands (search, uninstall, etc.) as well as traditional project-wide commands (build, check, sdist, etc.) > Distribution.parse_command_line in packaging/dist.py. This is the older command line parser, that can handle only project-wide commands. I?m not sure the work is finished to integrate both parsers; my smoke test used to be --help-commands, which can be hard to run these days. The problem is that Dispatcher or Distribution get the quiet or verbose options from the command-line deep in the library code, and want to use it to configure the log level on the handler, which I?ve just said should be set up at a much higher level. To solve this, I?m going to add a *logginghandler* argument to Dispatcher/Distribution; that way, the creation of the handler will happen only once and at a high level, but the command-line parsing code will be able to set the log handler from the command-line arguments. :) > In the second and third cases, can you be sure that only one of these > code paths > will be executed, at most once? Gut feeling is yes, but we?ve learned not to trust our instinct with distutils. > In the case of the test support code, I'm not really sure that > LoggingCatcher is > needed. There is already a TestHandler class in test.support which > captures > records in a buffer, and allows flexible matching for assertions, as > described in distutils used its own log module; this mixin was used to intercept messages sent with this system. When we migrated to stdlib logging, I added a todo comment to update the code to use something less kludgy :) The post you linked to is already in my bookmarks. Note that this support module also helps with Python 2.4+, so I may have to copy-paste TestHandler. So, I will fix the LoggingCatcher mixin to use the much cleaner addHandler/removeHandler combo (I?ll avoid calling logging._removeHandlerRef if I don?t have to) and try my idea about the handler instantiation in the code. Thanks a lot! Cheers From steve at pearwood.info Mon May 9 18:39:14 2011 From: steve at pearwood.info (Steven D'Aprano) Date: Tue, 10 May 2011 02:39:14 +1000 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: <4DC7FDF5.9060003@pearwood.info> Message-ID: <4DC818B2.5060508@pearwood.info> Eli Bendersky wrote: >> I think you are making an unwarranted assumption about what is "more >> expected". I presume you are thinking that the expected behaviour is that >> foo() should: >> >> print global x (5) >> assign 1 to local x >> print local x (1) >> >> If we implemented this change, there would be no more questions about >> UnboundLocalError, but instead there would be lots of questions like "why is >> it that globals revert to their old value after I change them in a >> function?". >> > > True, but this is less confusing and follows the rules in a more > straightforward way. x = 1 without a 'global x' assigns a local x, this make > sense and is similar to what happens in C where an inner declaration > temporarily shadows a global one. I disagree that it is less confusing. Instead of a nice, straightforward error that you can google, the function will silently do the wrong thing, giving no clue that weirdness is happening. def spam(): if x < 0: # refers to global x x = 1 # now local if x > 0: # could be either global or local x = x - 1 # local on the LHS of the equal # sometimes global on the RHS else: x += 1 # local x, but what value does it have? Just thinking about debugging the mess that this could make gives me a headache. -- Steven From merwok at netwok.org Mon May 9 18:42:06 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Mon, 09 May 2011 18:42:06 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: <190b407c9c414b46c8658307a88e5dfa@netwok.org> Hi, > When it comes to > containers, identity matters at least as much as value does (and > sometimes more so - e.g. sys.modules). Replacing those global > containers with new ones isn't guaranteed to work, as they may be > cached in various places rather than always retrieved fresh from the > relevant module namespace. Modifying them in place, on the other > hand, > does the right thing even in the presence of cached references. That makes sense, thanks for the explanation! > A comment to that effect may be a useful addition to regrtest, as I > expect others may have similar questions about those identity checks > in the future. (It may even be a useful addition to the > documentation, > but I have no idea where it could be sensibly included). Somewhere in unittest doc, say in the section about tearDown. Or maybe it?s time for a Python testing best practices howto? > Also, don't be surprised if wholesale cleanup like that isn't > completely reliable - it's far, far better if the test case > understands the changes it is making (even indirectly) and explicitly > reverses them. Yep, I was probably bringing out the big guns too early. self.addCleanup(sys.path.remove, path) is better and even shorter than my previous code! Cheers From tjreedy at udel.edu Mon May 9 18:59:29 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 09 May 2011 12:59:29 -0400 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: On 5/9/2011 9:27 AM, Stefan Behnel wrote: > Eli Bendersky, 09.05.2011 14:56: >> It's a known Python gotcha (*) that the following code: >> >> x = 5 >> def foo(): >> print(x) >> x = 1 >> print(x) >> foo() >> >> Will throw: >> >> UnboundLocalError: local variable 'x' referenced before assignment >> >> On the usage of 'x' in the *first* print. Recently, while reading the >> zillionth question on StackOverflow on some variation of this case, I >> started thinking whether this behavior is desired or just an >> implementation >> artifact. > > Well, basically any compiler these days can detect that a variable is > being used before assignment, or at least that this is possibly the > case, depending on prior branching. > > ISTM that your suggestion is to let x refer to the outer x up to the > assignment and to the inner x from that point on. IMHO, that's much > worse than the current behaviour and potentially impractical due to > conditional assignments. > > However, it's also a semantic change to reject code with unbound locals > at compile time, as the specific code in question may actually be > unreachable at runtime. This makes me think that it would be best to > discuss this on the python-ideas list first. > > If nothing else, I'd like to see a discussion on this behaviour being an > implementation detail of CPython or a feature of the Python language. > > Stefan > -- Terry Jan Reedy From tjreedy at udel.edu Mon May 9 19:24:20 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 09 May 2011 13:24:20 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity Message-ID: A commit (push) partition time and behavior into before and after (with a short change period in between during which behavior is undefined). Some commit messages have the form 'x does y'. Does 'does' mean before or after? Sometimes that is clear. 'x crashes' means before. 'x return correct value' means after. But some messages of this type are unclear to me as written. Consider 'x raises exception'? The temporal reference is obvious to the committer but not necessary to everyone else. It could mean 'x used to segfault and now raises a catchable exception'. There was a fix like this (with a clear message) just today. It could also mean 'x used to raise but now return an answer. There have been many fixes like this. Two minimal fixes are 'x raised exception' or 'make x raise exception'. -- Terry Jan Reedy From vinay_sajip at yahoo.co.uk Mon May 9 19:40:03 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 9 May 2011 17:40:03 +0000 (UTC) Subject: [Python-Dev] Problems with regrtest and with logging Message-ID: ?ric Araujo netwok.org> writes: > Yep, probably dead code. I think that an handler should be defined > only once, in the ?if __name__ == '__main__'? block. Am I right? Just > like you don?t call sys.exit from library code (hello optparse!), you > don?t set logging handlers in library code, only in the outmost layer of > the script. That's right, though it's OK to provide a documented convenience API for adding handlers. > The problem is that Dispatcher or Distribution get the quiet or verbose > options from the command-line deep in the library code, and want to use > it to configure the log level on the handler, which I?ve just said > should be set up at a much higher level. To solve this, I?m going to > add a *logginghandler* argument to Dispatcher/Distribution; that way, > the creation of the handler will happen only once and at a high level, > but the command-line parsing code will be able to set the log handler > from the command-line arguments. :) You don't necessarily need to set the level on the handler - why can you not just set it on the logger? The effect would often be the same: the logger's level is checked first, and then the handler's level. Generally you set levels on handlers when you want specific behaviour, such as all ERROR and above to a particular file, all CRITICAL to an email handler etc. For command-line scripts outputting to the console and nowhere else, usually you could just add a StreamHandler (with no level set on it), and set the level on the logger. Where the functionality may be used in an API, you should perhaps check logger.hasHandlers() and avoid adding handlers if there are already some added by a using library or application. Regards, Vinay Sajip From rdmurray at bitdance.com Mon May 9 19:54:45 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 09 May 2011 13:54:45 -0400 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <7fa082450fb750d082e71d5070a62171@netwok.org> References: <1304937168.22910.21.camel@marge> <7fa082450fb750d082e71d5070a62171@netwok.org> Message-ID: <20110509175447.4DC56250039@webabinitio.net> On Mon, 09 May 2011 17:55:42 +0200, =?UTF-8?Q?=C3=89ric_Araujo?= wrote: > Le 09/05/2011 16:08, Benjamin Peterson a ??crit : > > 2011/5/9 Victor Stinner : > >> For merge commits: many developers just write "merge" or "merge > >> 3.1". I > >> have to go to the parent commit (and something to the grandparent, > >> 3.1->3.2->3.3) to learn more about the commit. > > I follow conventions I???ve seen elsewhere (maybe Mercurial itself): I > use ???Branch merge??? when I merge anonymous branches on the same named > branch, and ???Merge x.y??? for forward-porting across named branches. > > I also tend to do more than one commit before merging. It would not be > very easy with my current toolchain to get the commit message(s) to > insert into the new message, and I think it???s not necessary. > > > I thought the whole point of merging was that you brought a changeset > > from one branch to another. This why I just write "merge" because > > otherwise you're technically duplicating information that is pulled > > onto the branch by merging. > > +1. No interest in manually duplicating available information. > > Le 09/05/2011 17:44, R. David Murray a ??crit : > > No it isn't. The commit message isn't pulled into the new branch. > > Sorry, your terminology does not make sense. If you mean that the > commit message is not reused in the new commit after the merge, it???s > true. However, the commit message with the relevant information is > available as part of the changesets that have been pulled and merged. The changesets are in the repository and there are pointers to them from the merge changeset, sure, but the data isn't in the checkout (that's how I understood "pulled in to the new branch"). If I do 'hg log' and search for a revno (that I got from hg annotate), the commit message describing the change is not attached to that revno, nor as far as I know is there a tool that makes it easy to get from that revno to the explanatory commit message. That's what Victor and I are talking about. Is there a tool that fixes this problem? (svnmerge did a nice job of that from the automate-the-message-generation end of things). -- R. David Murray http://www.bitdance.com From ned at nedbatchelder.com Mon May 9 20:36:44 2011 From: ned at nedbatchelder.com (Ned Batchelder) Date: Mon, 09 May 2011 14:36:44 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: References: Message-ID: <4DC8343C.2050005@nedbatchelder.com> On 5/9/2011 1:24 PM, Terry Reedy wrote: > A commit (push) partition time and behavior into before and after > (with a short change period in between during which behavior is > undefined). > > Some commit messages have the form 'x does y'. Does 'does' mean before > or after? Sometimes that is clear. 'x crashes' means before. 'x return > correct value' means after. But some messages of this type are unclear > to me as written. > > Consider 'x raises exception'? The temporal reference is obvious to > the committer but not necessary to everyone else. It could mean 'x > used to segfault and now raises a catchable exception'. There was a > fix like this (with a clear message) just today. It could also mean 'x > used to raise but now return an answer. There have been many fixes > like this. > > Two minimal fixes are 'x raised exception' or 'make x raise exception'. > I've always favored "X now properly raises an exception." --Ned. From guido at python.org Mon May 9 21:17:45 2011 From: guido at python.org (Guido van Rossum) Date: Mon, 9 May 2011 12:17:45 -0700 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: <4DC8343C.2050005@nedbatchelder.com> References: <4DC8343C.2050005@nedbatchelder.com> Message-ID: On Mon, May 9, 2011 at 11:36 AM, Ned Batchelder wrote: > On 5/9/2011 1:24 PM, Terry Reedy wrote: >> >> A commit (push) partition time and behavior into before and after (with a >> short change period in between during which behavior is undefined). >> >> Some commit messages have the form 'x does y'. Does 'does' mean before or >> after? Sometimes that is clear. 'x crashes' means before. 'x return correct >> value' means after. But some messages of this type are unclear to me as >> written. >> >> Consider 'x raises exception'? The temporal reference is obvious to the >> committer but not necessary to everyone else. It could mean 'x used to >> segfault and now raises a catchable exception'. There was a fix like this >> (with a clear message) just today. It could also mean 'x used to raise but >> now return an answer. There have been many fixes like this. >> >> Two minimal fixes are 'x raised exception' or 'make x raise exception'. >> > I've always favored "X now properly raises an exception." While my own preference is "make X properly raise an exception" I'm happy with any of the alternatives proposed here, and grateful to Terry for calling this out. Checkin comments of the form "X does Y" are ambiguous and confusing. (Same for feature requests in the tracker.) I'm curious where the habit to use the present tense comes from; I wonder if it originates in some agile development practice? -- --Guido van Rossum (python.org/~guido) From eric at trueblade.com Mon May 9 21:36:21 2011 From: eric at trueblade.com (Eric Smith) Date: Mon, 09 May 2011 15:36:21 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: References: <4DC8343C.2050005@nedbatchelder.com> Message-ID: <4DC84235.4060600@trueblade.com> On 05/09/2011 03:17 PM, Guido van Rossum wrote: > On Mon, May 9, 2011 at 11:36 AM, Ned Batchelder wrote: >> On 5/9/2011 1:24 PM, Terry Reedy wrote: >>> >>> A commit (push) partition time and behavior into before and after (with a >>> short change period in between during which behavior is undefined). >>> >>> Some commit messages have the form 'x does y'. Does 'does' mean before or >>> after? Sometimes that is clear. 'x crashes' means before. 'x return correct >>> value' means after. But some messages of this type are unclear to me as >>> written. >>> >>> Consider 'x raises exception'? The temporal reference is obvious to the >>> committer but not necessary to everyone else. It could mean 'x used to >>> segfault and now raises a catchable exception'. There was a fix like this >>> (with a clear message) just today. It could also mean 'x used to raise but >>> now return an answer. There have been many fixes like this. >>> >>> Two minimal fixes are 'x raised exception' or 'make x raise exception'. >>> >> I've always favored "X now properly raises an exception." > > While my own preference is "make X properly raise an exception" I'm > happy with any of the alternatives proposed here, and grateful to > Terry for calling this out. Checkin comments of the form "X does Y" > are ambiguous and confusing. (Same for feature requests in the > tracker.) > > I'm curious where the habit to use the present tense comes from; I > wonder if it originates in some agile development practice? > Thanks indeed for bringing this up, Terry. It's been on my to-do list for a while. I think it comes from just copying the title of a bug report. The bug is "X does Y", and that's what's used in the fix. Eric. From guido at python.org Mon May 9 22:05:30 2011 From: guido at python.org (Guido van Rossum) Date: Mon, 9 May 2011 13:05:30 -0700 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: <4DC84235.4060600@trueblade.com> References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> Message-ID: On Mon, May 9, 2011 at 12:36 PM, Eric Smith wrote: > On 05/09/2011 03:17 PM, Guido van Rossum wrote: >> On Mon, May 9, 2011 at 11:36 AM, Ned Batchelder wrote: >>> On 5/9/2011 1:24 PM, Terry Reedy wrote: >>>> >>>> A commit (push) partition time and behavior into before and after (with a >>>> short change period in between during which behavior is undefined). >>>> >>>> Some commit messages have the form 'x does y'. Does 'does' mean before or >>>> after? Sometimes that is clear. 'x crashes' means before. 'x return correct >>>> value' means after. But some messages of this type are unclear to me as >>>> written. >>>> >>>> Consider 'x raises exception'? The temporal reference is obvious to the >>>> committer but not necessary to everyone else. It could mean 'x used to >>>> segfault and now raises a catchable exception'. There was a fix like this >>>> (with a clear message) just today. It could also mean 'x used to raise but >>>> now return an answer. There have been many fixes like this. >>>> >>>> Two minimal fixes are 'x raised exception' or 'make x raise exception'. >>>> >>> I've always favored "X now properly raises an exception." >> >> While my own preference is "make X properly raise an exception" I'm >> happy with any of the alternatives proposed here, and grateful to >> Terry for calling this out. Checkin comments of the form "X does Y" >> are ambiguous and confusing. (Same for feature requests in the >> tracker.) >> >> I'm curious where the habit to use the present tense comes from; I >> wonder if it originates in some agile development practice? >> > > Thanks indeed for bringing this up, Terry. It's been on my to-do list > for a while. I think it comes from just copying the title of a bug > report. The bug is "X does Y", and that's what's used in the fix. But in bug reports it is also ambiguous, since I've often seen it used meaning "X should do Y" which is very confusing when it doesn't do Y yet at the time the bug is created. :-( -- --Guido van Rossum (python.org/~guido) From tjreedy at udel.edu Tue May 10 00:59:41 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 09 May 2011 18:59:41 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> Message-ID: On 5/9/2011 4:05 PM, Guido van Rossum wrote: > On Mon, May 9, 2011 at 12:36 PM, Eric Smith wrote: >> On 05/09/2011 03:17 PM, Guido van Rossum wrote: >>> While my own preference is "make X properly raise an exception" I'm >>> happy with any of the alternatives proposed here, and grateful to >>> Terry for calling this out. I am willing to admit that I do not know all corners of Python ;-) I read the commit messages to learn more; in particular what sort of errors exist and how are they fixed. >>> Checkin comments of the form "X does Y" >>> are ambiguous and confusing. (Same for feature requests in the >>> tracker.) I have always assumed that an issue entitled 'x does y' is a bug report about doing y now, before a fix. >> Thanks indeed for bringing this up, Terry. It's been on my to-do list >> for a while. I think it comes from just copying the title of a bug >> report. The bug is "X does Y", and that's what's used in the fix. I have also seen this type of message for non-tracker-issue commits. > But in bug reports it is also ambiguous, since I've often seen it used > meaning "X should do Y" which is very confusing when it doesn't do Y > yet at the time the bug is created. :-( If I notice a title that bad, I will try to change it. -- Terry Jan Reedy From tjreedy at udel.edu Tue May 10 01:03:24 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 09 May 2011 19:03:24 -0400 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <20110509175447.4DC56250039@webabinitio.net> References: <1304937168.22910.21.camel@marge> <7fa082450fb750d082e71d5070a62171@netwok.org> <20110509175447.4DC56250039@webabinitio.net> Message-ID: On 5/9/2011 1:54 PM, R. David Murray wrote: > If I do 'hg log' and search for a revno (that I got from hg annotate), > the commit message describing the change is not attached to that revno, > nor as far as I know is there a tool that makes it easy to get from that > revno to the explanatory commit message. That's what Victor and I are > talking about. Is there a tool that fixes this problem? (svnmerge did a > nice job of that from the automate-the-message-generation end of things). TortoiseSvn, and I presume TortoiseHg also, has a 'recent messages' box that makes is trivial to reuse a message. I used it with svn and will make sure to use it, if it exists, when I get started with hg. -- Terry Jan Reedy From benjamin at python.org Tue May 10 01:23:45 2011 From: benjamin at python.org (Benjamin Peterson) Date: Mon, 9 May 2011 18:23:45 -0500 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <20110509154416.35BBF250037@webabinitio.net> References: <1304937168.22910.21.camel@marge> <20110509154416.35BBF250037@webabinitio.net> Message-ID: 2011/5/9 R. David Murray : > On Mon, 09 May 2011 09:08:53 -0500, Benjamin Peterson wrote: >> I thought the whole point of merging was that you brought a changeset >> from one branch to another. This why I just write "merge" because >> otherwise you're technically duplicating information that is pulled >> onto the branch by merging. > > No it isn't. ?The commit message isn't pulled into the new branch. > >> It seems like something that should be solved by tools like a display >> visual graph indicating what is merged. (like Bazaar) > > You'd need some extension to hg log that would show the original commit > message for the first changeset in the merge line in order to "fix" > this. ?I doubt that is going to happen. *cough* http://mercurial.selenic.com/wiki/GraphlogExtension > > Note that saying just 'merge' makes perfect sense when you are pulling > in a whole group of changesets in order to synchronize two branches. > But if you are applying a single changeset to multiple branches, > as we often do in our workflow, then I think duplicating the commit > message is (1) easy to do and (2) very helpful when looking at > hg log output. What's the difference between pulling multiple changesets in and one then? -- Regards, Benjamin From nyamatongwe at gmail.com Tue May 10 01:52:49 2011 From: nyamatongwe at gmail.com (Neil Hodgson) Date: Tue, 10 May 2011 09:52:49 +1000 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: <1304950275.22910.32.camel@marge> References: <1304950275.22910.32.camel@marge> Message-ID: Victor Stinner: > C and C++ identifiers are restricted to ASCII. I don't know for Fortran > or Java. Some C and C++ implementations currently allow non-ASCII identifiers and the forthcoming C1X and C++0x language standards include non-ASCII identifiers. The allowed characters are specified in Annexes of the respective standards. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf - Annex D http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3225.pdf - Annex E Neil From solipsis at pitrou.net Tue May 10 02:06:03 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Tue, 10 May 2011 02:06:03 +0200 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII References: <1304950275.22910.32.camel@marge> Message-ID: <20110510020603.25774eb9@pitrou.net> On Mon, 09 May 2011 16:11:15 +0200 Victor Stinner wrote: > Le lundi 09 mai 2011 ? 09:00 -0400, Jim Jewett a ?crit : > > Are you asserting that all foreign modules (or at least all handled by > > this) are in C, as opposed to C++ or even Java or Fortran? (And the C > > won't change?) > > C and C++ identifiers are restricted to ASCII. I don't know for Fortran > or Java. Why is it important, though? What matters is not what C/C++ can produce, but what a shared library can export. So the question is: are shared libraries limited to ASCII symbols? Regards Antoine. From greg.ewing at canterbury.ac.nz Tue May 10 02:13:47 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 10 May 2011 12:13:47 +1200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> Message-ID: <4DC8833B.9080503@canterbury.ac.nz> Nick Coghlan wrote: > One interesting aspect is that from the caller's point of view, a > *new* reference to the relevant behaves like a borrowed reference for > input parameters, but like a stolen reference for output parameters > and return values. I think it's less confusing to use the term "new" only for output/return values, and "stolen" only for input values. Inputs are either "borrowed" or "stolen" (by the callee). Outputs are either "new" (to the caller) or "borrowed" (by the caller). (Or maybe the terms for outputs should be "given" and "lent"?-) -- Greg From victor.stinner at haypocalc.com Tue May 10 02:57:14 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Tue, 10 May 2011 02:57:14 +0200 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: <1304950275.22910.32.camel@marge> Message-ID: <1304989034.29582.7.camel@marge> Le mardi 10 mai 2011 ? 09:52 +1000, Neil Hodgson a ?crit : > Some C and C++ implementations currently allow non-ASCII > identifiers and the forthcoming C1X and C++0x language standards > include non-ASCII identifiers. The allowed characters are specified in > Annexes of the respective standards. > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf - Annex D > http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3225.pdf - Annex E I read these documents but they don't explain which encoding is used in libraries and programs. Does it mean that Windows and Linux may use different encodings? At least, the surrogate range (U+DC00-U+DFFF) is excluded, which is a good news (UTF-8 decoder of Python 3 rejects surrogate characters). I discovered -fextended-identifiers option of gcc: using this option, you can use \uHHHH and \UHHHHHHHH in identifiers, but not \xHH. On Linux, identifiers are encoded to UTF-8. Example: -------------- #define _ISOC99_SOURCE #include int f\u00E9() { wprintf(L"U+00E9 = \xE9\n"); } int g\U000000E8() { wprintf(L"U+00E8 = \xE8\n"); } int main() { f\u00E9(); g\U000000E8(); return 0; } -------------- It's not very practical, I would prefer to write directly Unicode characters (as I can do in Python 3!). I'm not sure that chineses will prefer to call \u4f60\u597d() instead of hello(). Ok, I now agree, it is possible to use non-ASCII characters in C. But what about the encoding of symbols in a dynamic library: is it always UTF-8? Victor From nyamatongwe at gmail.com Tue May 10 03:08:32 2011 From: nyamatongwe at gmail.com (Neil Hodgson) Date: Tue, 10 May 2011 11:08:32 +1000 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: <1304989034.29582.7.camel@marge> References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> Message-ID: Victor Stinner: > I read these documents but they don't explain which encoding is used in > libraries and programs. Does it mean that Windows and Linux may use > different encodings? Yes, Windows will use UTF-16 as it does for almost everything. From a user's point of view, these should both just be seen as Unicode. Neil From greg.ewing at canterbury.ac.nz Tue May 10 03:28:04 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 10 May 2011 13:28:04 +1200 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <20110510005835.GA29281@rectangular.com> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> <4DC8833B.9080503@canterbury.ac.nz> <20110510005835.GA29281@rectangular.com> Message-ID: <4DC894A4.2000709@canterbury.ac.nz> Marvin Humphrey wrote: > incremented: The caller has to account for an additional refcount. > decremented: The caller has to account for a lost refcount. I'm not sure that really clarifies anything. These terms sound like they're talking about the reference count of the object, but if they correspond to borrowed/stolen, they don't necessarily correlate with what actually happens to the reference count. -- Greg From marvin at rectangular.com Tue May 10 02:58:35 2011 From: marvin at rectangular.com (Marvin Humphrey) Date: Mon, 9 May 2011 17:58:35 -0700 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <4DC8833B.9080503@canterbury.ac.nz> References: <1304499523.15694.11.camel@marge> <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> <4DC8833B.9080503@canterbury.ac.nz> Message-ID: <20110510005835.GA29281@rectangular.com> On Tue, May 10, 2011 at 12:13:47PM +1200, Greg Ewing wrote: > Nick Coghlan wrote: > >> One interesting aspect is that from the caller's point of view, a >> *new* reference to the relevant behaves like a borrowed reference for >> input parameters, but like a stolen reference for output parameters >> and return values. > > I think it's less confusing to use the term "new" only for > output/return values, and "stolen" only for input values. > > Inputs are either "borrowed" or "stolen" (by the callee). > > Outputs are either "new" (to the caller) or "borrowed" > (by the caller). > > (Or maybe the terms for outputs should be "given" and "lent"?-) To solve this problem in a similar system (the Clownfish object system used by Apache Lucy) we used the keywords "incremented" and "decremented". Applied to some Python C API function documentation: incremented PyObject* PyTuple_New(Py_ssize_t len) int PyTuple_SetItem(PyObject *p, Py_ssize_t pos, decremented PyObject *o) With "incremented" and "decremented", the perspective is always that of the caller. incremented: The caller has to account for an additional refcount. decremented: The caller has to account for a lost refcount. Marvin Humphrey From rdmurray at bitdance.com Tue May 10 03:32:46 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Mon, 09 May 2011 21:32:46 -0400 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: References: <1304937168.22910.21.camel@marge> <20110509154416.35BBF250037@webabinitio.net> Message-ID: <20110510013247.655DA250037@webabinitio.net> On Mon, 09 May 2011 18:23:45 -0500, Benjamin Peterson wrote: > 2011/5/9 R. David Murray : > > On Mon, 09 May 2011 09:08:53 -0500, Benjamin Peterson g> wrote: > >> I thought the whole point of merging was that you brought a changeset > >> from one branch to another. This why I just write "merge" because > >> otherwise you're technically duplicating information that is pulled > >> onto the branch by merging. > > > > No it isn't. =C2=A0The commit message isn't pulled into the new branch. > > > >> It seems like something that should be solved by tools like a display > >> visual graph indicating what is merged. (like Bazaar) > > > > You'd need some extension to hg log that would show the original commit > > message for the first changeset in the merge line in order to "fix" > > this. =C2=A0I doubt that is going to happen. > > *cough* http://mercurial.selenic.com/wiki/GraphlogExtension I'm sorry, but I've looked at the output of that and the mental overhead has so far proven too high for it to be of any use to me. I apologize for not having made the full mental transition to "distributed VCS"/DAG (apparently), but it sounds like I'm not the only one.... > > Note that saying just 'merge' makes perfect sense when you are pulling > > in a whole group of changesets in order to synchronize two branches. > > But if you are applying a single changeset to multiple branches, > > as we often do in our workflow, then I think duplicating the commit > > message is (1) easy to do and (2) very helpful when looking at > > hg log output. > > What's the difference between pulling multiple changesets in and one then? I'm talking about merging trunk to a feature branch, for example. I'd not expect any message other than 'merge' for that. I'd be satisfied if the commit messages listed the issue numbers involved in the merge, especially if someone (like ??ric) is merging more than one change at a time. But as I think about this, frankly I'd rather see atomic commits, even on merges. That was something I disliked about svnmerge, the fact that often an svnmerge commit involved many changesets from the other branch. That was especially painful in exactly the same situation: trying to backtrack a change starting from 'svn blame'. I limited my own use of multiple-changeset-svnmerge to doc changes and changesets that were actually related, despite the overhead involved in doing it that way. All that said, I'm not trying to impose my will on the workflow, I'll certainly live with the consensus (though unless there is an outcry against it I'll continue putting the full commit message in my own merges). -- R. David Murray http://www.bitdance.com From marvin at rectangular.com Tue May 10 03:53:10 2011 From: marvin at rectangular.com (Marvin Humphrey) Date: Mon, 9 May 2011 18:53:10 -0700 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <4DC894A4.2000709@canterbury.ac.nz> References: <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> <4DC8833B.9080503@canterbury.ac.nz> <20110510005835.GA29281@rectangular.com> <4DC894A4.2000709@canterbury.ac.nz> Message-ID: <20110510015310.GA29407@rectangular.com> On Tue, May 10, 2011 at 01:28:04PM +1200, Greg Ewing wrote: > Marvin Humphrey wrote: > >> incremented: The caller has to account for an additional refcount. >> decremented: The caller has to account for a lost refcount. > > I'm not sure that really clarifies anything. These terms > sound like they're talking about the reference count of the > object, but if they correspond to borrowed/stolen, they > don't necessarily correlate with what actually happens to > the reference count. Hmm, they don't correspond to borrowed/stolen. stolen from the caller -> decremented stolen from the callee -> incremented borrowed -> [no modifier] We don't have a modifier keyword which is analogous to "borrowed". The user is expected to understand object lifespan issues for borrowed references without explicit guidance. With regards to "what actually happens to the reference count", I would argue that "incremented" and "decremented" are accurate descriptions. * When a function returns an "incremented" object, that function has added a refcount to it. * When a function accepts a "decremented" object as an argument, it will consume a refcount from it -- either right away, or at some point in the future. In my view, it is not desirable to label arguments or return values as "borrowed"; it is only necessary to advise the user when they must take action to account for a refcount, gained or lost. Cheers, Marvin Humphrey From stephen at xemacs.org Tue May 10 04:51:19 2011 From: stephen at xemacs.org (Stephen J. Turnbull) Date: Tue, 10 May 2011 11:51:19 +0900 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <20110510013247.655DA250037@webabinitio.net> References: <1304937168.22910.21.camel@marge> <20110509154416.35BBF250037@webabinitio.net> <20110510013247.655DA250037@webabinitio.net> Message-ID: <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> R. David Murray writes: > On Mon, 09 May 2011 18:23:45 -0500, Benjamin Peterson wrote: > > *cough* http://mercurial.selenic.com/wiki/GraphlogExtension > > I'm sorry, but I've looked at the output of that and the mental overhead > has so far proven too high for it to be of any use to me. How about the hgk extension, and "hg view"? http://mercurial.selenic.com/wiki/HgkExtension > But as I think about this, frankly I'd rather see atomic commits, even > on merges. That was something I disliked about svnmerge, the fact that > often an svnmerge commit involved many changesets from the other branch. > That was especially painful in exactly the same situation: trying to > backtrack a change starting from 'svn blame'. I don't understand the issue. In my experience, hg annotate will point to the commit on the branch, not to the merge, unless there was a conflict, in which case the merge is the "right" place (although not necessarily the most useful place) to point. From murman at gmail.com Tue May 10 05:18:10 2011 From: murman at gmail.com (Michael Urman) Date: Mon, 9 May 2011 22:18:10 -0500 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> Message-ID: On Mon, May 9, 2011 at 20:08, Neil Hodgson wrote: > ? Yes, Windows will use UTF-16 as it does for almost everything. From > a user's point of view, these should both just be seen as Unicode. I'm not convinced this is correct for this case. GetProcAddress takes an "ANSI" string, meaning while it could theoretically use UTF-8, in practice I doubt it uses anything outside of ASCII safely. So while the name of the library would be encoded in UTF-16, the name of the function loaded from the library would not be. http://msdn.microsoft.com/en-us/library/ms683212(v=vs.85).aspx -- Michael Urman From nyamatongwe at gmail.com Tue May 10 06:09:06 2011 From: nyamatongwe at gmail.com (Neil Hodgson) Date: Tue, 10 May 2011 14:09:06 +1000 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> Message-ID: Michael Urman: > I'm not convinced this is correct for this case. GetProcAddress takes > an "ANSI" string, meaning while it could theoretically use UTF-8, in > practice I doubt it uses anything outside of ASCII safely. So while > the name of the library would be encoded in UTF-16, the name of the > function loaded from the library would not be. Yes you are right: http://scintilla.org/NarrowName.png Neil From murman at gmail.com Tue May 10 06:23:54 2011 From: murman at gmail.com (Michael Urman) Date: Mon, 9 May 2011 23:23:54 -0500 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> Message-ID: On Mon, May 9, 2011 at 23:09, Neil Hodgson wrote: > Michael Urman: > >> I'm not convinced this is correct for this case. GetProcAddress takes >> an "ANSI" string, meaning while it could theoretically use UTF-8, in >> practice I doubt it uses anything outside of ASCII safely. So while >> the name of the library would be encoded in UTF-16, the name of the >> function loaded from the library would not be. > > ? Yes you are right: > http://scintilla.org/NarrowName.png > > ? Neil > That screenshot seems to show UTF-8 is being used. This may just be the literal bytes in the .c file, but could it be something more dependable? http://unicode.org/cgi-bin/GetUnihanData.pl?codepoint=6728 From nyamatongwe at gmail.com Tue May 10 06:35:27 2011 From: nyamatongwe at gmail.com (Neil Hodgson) Date: Tue, 10 May 2011 14:35:27 +1000 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> Message-ID: Michael Urman: > That screenshot seems to show UTF-8 is being used. This may just be > the literal bytes in the .c file, but could it be something more > dependable? The file is in UTF-8 so the compiler may just be copying the bytes. There is a setlocale pragma but that seems to be just for string literals. Neil From eliben at gmail.com Tue May 10 07:36:38 2011 From: eliben at gmail.com (Eli Bendersky) Date: Tue, 10 May 2011 08:36:38 +0300 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: On Mon, May 9, 2011 at 18:44, Isaac Morland wrote: > On Mon, 9 May 2011, Eli Bendersky wrote: > > x = 5 >>> def foo (): >>> print (x) >>> if bar (): >>> x = 1 >>> print (x) >>> >>> >> I wish you'd annotate this code sample, what do you intend it to >> demonstrate? >> >> It probably shows the original complaint even more strongly. As for being >> a >> problem with the suggested solution, I suppose you're right, although it >> doesn't make it much different. Still, before a *possible* assignment to >> 'x', it should be loaded as LOAD_NAME since it was surely not bound as >> local, yet. >> > > Extrapolating from your suggestion, you're saying before a *possible* > assignment it will be treated as global, and after a *possible* assignment > it will be treated as local? > > But surely: > > print (x) > if False: > x = 1 > print (x) > > [snip] Alright, I now understand the problems with the suggestion. Indeed, conditional assignments that are only really resolved at runtime are the big stumbling block here. However, maybe the error message/reporting can still be improved? ISTM the UnboundLocalError exception gets raised only in those weird and confusing cases. After all, why would Python decide an access to some name is to a local? Only if it found an assignment to that local in the scope. But that assignment clearly didn't happen yet, so the error is thrown. So cases like these: x = 2 def foo1(): x += 1 def foo2(): print(x) x = 10 def foo3(): if something_that_didnot_happen: x = 10 print(x) All belong to the category. With an unlimited error message length it could make sense to say "Hey, I see 'x' may be assigned in this scope, so I mark it local. But this access to 'x' happens before assignment - so ERROR". This isn't realistic, of course, so I'm wondering: 1. Does this error message (although unrealistic) capture all possible appearances of UnboundLocalError? 2. If the answer to (1) is yes - could it be usefully shortened to be clearer than the current "local variable referenced before assignment"? This may not be possible, of course, but it doesn't harm trying :-) Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Tue May 10 08:16:24 2011 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 10 May 2011 08:16:24 +0200 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: [forwarded to the python-ideas list] Stefan From victor.stinner at haypocalc.com Tue May 10 10:03:29 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Tue, 10 May 2011 10:03:29 +0200 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> Message-ID: <1305014609.2014.6.camel@marge> Le lundi 09 mai 2011 ? 22:18 -0500, Michael Urman a ?crit : > On Mon, May 9, 2011 at 20:08, Neil Hodgson wrote: > > Yes, Windows will use UTF-16 as it does for almost everything. From > > a user's point of view, these should both just be seen as Unicode. > > I'm not convinced this is correct for this case. GetProcAddress takes > an "ANSI" string, meaning while it could theoretically use UTF-8, in > practice I doubt it uses anything outside of ASCII safely. If GetProcAddress() expects a byte string encoded to the ANSI code page, my patch is correct because the function used the UTF-8 encoding, not the ANSI code page. We can maybe use GetProcAddressW() to pass a Unicode string. I don't know which encoding is used by GetProcAddressW()... I already patched _PyImport_GetDynLoadFunc() for Windows: the path is now a Unicode object instead of a byte string encoded to the filesystem encoding. _PyImport_GetDynLoadWindows() uses GetFullPathNameW() and LoadLibraryExW(). The work to be fully Unicode compliant (for the path field, not for the name) is not completly done... but I have a pending patch, see: http://bugs.python.org/issue11619 But this patch is huge and creates many functions. I am not sure that we need it, I will work on this later. Victor From orsenthil at gmail.com Tue May 10 10:37:42 2011 From: orsenthil at gmail.com (Senthil Kumaran) Date: Tue, 10 May 2011 16:37:42 +0800 Subject: [Python-Dev] [Python-checkins] cpython: Issue #12039: Add end_headers() call to avoid BadStatusLine. In-Reply-To: References: Message-ID: <20110510083742.GA16239@kevin> On Tue, May 10, 2011 at 10:10:15AM +0200, vinay.sajip wrote: > diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py > --- a/Lib/test/test_logging.py > +++ b/Lib/test/test_logging.py > @@ -1489,6 +1489,7 @@ > except: > self.post_data = None > request.send_response(200) > + request.end_headers() > self.handled.set() This is accurate. It should have resulted from the change made in the http.server, because the headers are now cached and then written to the output stream in one-shot when end_headers/flush_headers are called. Thanks, Senthil From aurelien.campeas at logilab.fr Tue May 10 13:51:41 2011 From: aurelien.campeas at logilab.fr (=?ISO-8859-1?Q?Aur=E9lien_Camp=E9as?=) Date: Tue, 10 May 2011 13:51:41 +0200 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> References: <1304937168.22910.21.camel@marge> <20110509154416.35BBF250037@webabinitio.net> <20110510013247.655DA250037@webabinitio.net> <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> Message-ID: <4DC926CD.1040108@logilab.fr> Le 10/05/2011 04:51, Stephen J. Turnbull a ?crit : > R. David Murray writes: > > On Mon, 09 May 2011 18:23:45 -0500, Benjamin Peterson wrote: > > > > *cough* http://mercurial.selenic.com/wiki/GraphlogExtension > > > > I'm sorry, but I've looked at the output of that and the mental overhead > > has so far proven too high for it to be of any use to me. > > How about the hgk extension, and "hg view"? > > http://mercurial.selenic.com/wiki/HgkExtension > or, FWIW, "hgview" (http://www.logilab.org/project/hgview) From ncoghlan at gmail.com Tue May 10 14:29:58 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 22:29:58 +1000 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: <4DC84235.4060600@trueblade.com> References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> Message-ID: On Tue, May 10, 2011 at 5:36 AM, Eric Smith wrote: > Thanks indeed for bringing this up, Terry. It's been on my to-do list > for a while. I think it comes from just copying the title of a bug > report. The bug is "X does Y", and that's what's used in the fix. I believe I've actually seen it in NEWS entries as well (although thankfully not often and I can't recall any specific instances off the top of my head). I'm also a fan of including the word "now" and describing the new behaviour, although I'll sometimes use "no longer" and describe the old behaviour for some bugs where that seems more appropriate. Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From ncoghlan at gmail.com Tue May 10 14:44:29 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 22:44:29 +1000 Subject: [Python-Dev] Borrowed and Stolen References in API In-Reply-To: <20110510015310.GA29407@rectangular.com> References: <4DC11791.2000109@dcs.gla.ac.uk> <4DC1D1C5.9010507@canterbury.ac.nz> <4DC34EAB.9050001@canterbury.ac.nz> <20110506122703.17c4d889@pitrou.net> <4DC8833B.9080503@canterbury.ac.nz> <20110510005835.GA29281@rectangular.com> <4DC894A4.2000709@canterbury.ac.nz> <20110510015310.GA29407@rectangular.com> Message-ID: On Tue, May 10, 2011 at 11:53 AM, Marvin Humphrey wrote: > With regards to "what actually happens to the reference count", I would argue > that "incremented" and "decremented" are accurate descriptions. > > ?* When a function returns an "incremented" object, that function has added > ? ?a refcount to it. Except that's not quite true in cases like PySet_Pop(). In that case, the net effect on the refcount is neutral. The significant point is that the set no longer holds a reference, it has passed that responsibility back to the caller. > In my view, it is not desirable to label arguments or return values as > "borrowed"; it is only necessary to advise the user when they must take action > to account for a refcount, gained or lost. Agreed on this part, though. Callers need to know when: 1. The return value is a new reference that must be decremented (currently indicated in the docs by "Return value: New reference") 2. An input parameter transfers responsibility for the reference to the callee (the only example I noticed in the docs is PyList_SetItem, which uses an explicit note rather than any kind of markup or the refcount data) I believe the current refcount data covers the first case reasonably well, but not the latter (and still has the problem of being separated from the documentation of the functions themselves). Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From rdmurray at bitdance.com Tue May 10 14:50:34 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 10 May 2011 08:50:34 -0400 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> References: <1304937168.22910.21.camel@marge> <20110509154416.35BBF250037@webabinitio.net> <20110510013247.655DA250037@webabinitio.net> <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> Message-ID: <20110510125035.8F20B250041@webabinitio.net> On Tue, 10 May 2011 11:51:19 +0900, "Stephen J. Turnbull" wrote: > R. David Murray writes: > > On Mon, 09 May 2011 18:23:45 -0500, Benjamin Peterson wrote: > > > > *cough* http://mercurial.selenic.com/wiki/GraphlogExtension > > > > I'm sorry, but I've looked at the output of that and the mental overhead > > has so far proven too high for it to be of any use to me. > > How about the hgk extension, and "hg view"? I think the problem is in my brain, not the graphical tools :) With rare exceptions I don't use tools that require a mouse to operate, though, so unless I feel like doing tcl hacking to make good keyboard bindings that particular tool won't help me anyway. > > But as I think about this, frankly I'd rather see atomic commits, even > > on merges. That was something I disliked about svnmerge, the fact that > > often an svnmerge commit involved many changesets from the other branch. > > That was especially painful in exactly the same situation: trying to > > backtrack a change starting from 'svn blame'. > > I don't understand the issue. In my experience, hg annotate will > point to the commit on the branch, not to the merge, unless there was > a conflict, in which case the merge is the "right" place (although not > necessarily the most useful place) to point. That's what I get for reasoning about hg based on my svn experience. Someone on IRC also pointed this out. I haven't done this often enough in HG for the difference to have penetrated my brain. I have a feeling I'm still going to get confused occasionally, but then I'm sure I did with svn too... -- R. David Murray http://www.bitdance.com From ncoghlan at gmail.com Tue May 10 14:59:02 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 10 May 2011 22:59:02 +1000 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> References: <1304937168.22910.21.camel@marge> <20110509154416.35BBF250037@webabinitio.net> <20110510013247.655DA250037@webabinitio.net> <87d3jre09k.fsf@uwakimon.sk.tsukuba.ac.jp> Message-ID: On Tue, May 10, 2011 at 12:51 PM, Stephen J. Turnbull wrote: > R. David Murray writes: > ?> On Mon, 09 May 2011 18:23:45 -0500, Benjamin Peterson wrote: > > ?> > *cough* http://mercurial.selenic.com/wiki/GraphlogExtension > ?> > ?> I'm sorry, but I've looked at the output of that and the mental overhead > ?> has so far proven too high for it to be of any use to me. > > How about the hgk extension, and "hg view"? > > http://mercurial.selenic.com/wiki/HgkExtension I don't think it's really a jump up to the "graphical" level that we're after. It's more a matter of: 1. Display commit message for current commit 2. Notice that this commit has two parents 3. Ignore any parent commit in the same branch as the current commit 4. For a parent commit in another branch, also display that commit message 5. If the commit in step 4 also has multiple parents, repeat from step 3 (but based off that parent commit) So a standard 3.1->3.2->default merge could be displayed along the lines of: Merge from 3.2 3.2: Merge from 3.1 3.1: Issue #123456: mod.func now works correctly when argument is negative It won't help if the last commit on the initial branch was something boring like "Fix whitespace", but it will be adequate for our typical single-commit bug fix workflow. (If nobody does anything before then, I'll see what I can do with the email hook next week) Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From rdmurray at bitdance.com Tue May 10 15:11:44 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 10 May 2011 09:11:44 -0400 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: Message-ID: <20110510131144.C8D75250041@webabinitio.net> On Tue, 10 May 2011 08:36:38 +0300, Eli Bendersky wrote: > With an unlimited error message length it could make sense to say "Hey, I > see 'x' may be assigned in this scope, so I mark it local. But this access > to 'x' happens before assignment - so ERROR". This isn't realistic, of > course, so I'm wondering: > > 1. Does this error message (although unrealistic) capture all possible > appearances of UnboundLocalError? > 2. If the answer to (1) is yes - could it be usefully shortened to be > clearer than the current "local variable referenced before assignment"? > > This may not be possible, of course, but it doesn't harm trying :-) How about: "reference to variable 'y' precedes an assignment that makes it a local variable" IMO this still leaves room for confusion, but is better because it indicates the causation more clearly. (I don't think it is necessary to capture the subtlety of conditional assignment in the error message.) -- R. David Murray http://www.bitdance.com From rdmurray at bitdance.com Tue May 10 15:33:13 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 10 May 2011 09:33:13 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> Message-ID: <20110510133314.66B48250041@webabinitio.net> On Tue, 10 May 2011 22:29:58 +1000, Nick Coghlan wrote: > On Tue, May 10, 2011 at 5:36 AM, Eric Smith wrote: > > Thanks indeed for bringing this up, Terry. It's been on my to-do list > > for a while. I think it comes from just copying the title of a bug > > report. The bug is "X does Y", and that's what's used in the fix. > > I believe I've actually seen it in NEWS entries as well (although > thankfully not often and I can't recall any specific instances off the > top of my head). > > I'm also a fan of including the word "now" and describing the new > behaviour, although I'll sometimes use "no longer" and describe the > old behaviour for some bugs where that seems more appropriate. I generally don't use the same text for commit and NEWS, because I like to stick to one-liners for the first line of the commit, possibly with more detail in the body, while for NEWS items I'm aiming for a one to three line description. But in both cases what I'm thinking about is "what have I *changed*". In the commit message that will probably focus more on code changes, while the NEWS item will focus more on behavior changes, but the results are generally similar. So for example my most recent two comments look like this: commit: 11999: sync based on comparing mtimes, not mtime to system clock NEWS: Issue 11999: fixed sporadic sync failure mailbox.Maildir due to its trying to detect mtime changes by comparing to the system clock instead of to the previous value of the mtime. commit: #11873: Improve test regex so random directory names don't cause test to fail NEWS: Issue #11873: Change regex in test_compileall to fix occasional failures when when the randomly generated temporary path happened to match the regex. You will note the *active* verbs "fixed", "improve", and "change" figure in there prominently :) (Eh. And proofreading this email I see I made a grammar error in that first NEWS example :( -- R. David Murray http://www.bitdance.com From murman at gmail.com Tue May 10 15:34:38 2011 From: murman at gmail.com (Michael Urman) Date: Tue, 10 May 2011 08:34:38 -0500 Subject: [Python-Dev] [Python-checkins] cpython: _PyImport_LoadDynamicModule() encodes the module name explicitly to ASCII In-Reply-To: <1305014609.2014.6.camel@marge> References: <1304950275.22910.32.camel@marge> <1304989034.29582.7.camel@marge> <1305014609.2014.6.camel@marge> Message-ID: On Tue, May 10, 2011 at 03:03, Victor Stinner wrote: > If GetProcAddress() expects a byte string encoded to the ANSI code page, > my patch is correct because the function used the UTF-8 encoding, not > the ANSI code page. We can maybe use GetProcAddressW() to pass a Unicode > string. I don't know which encoding is used by GetProcAddressW()... While I can find references to a GetProcAddressW, most of them seem to agree it doesn't exist. "My kernel32.dll only exports GetProcAddress." This suggests to me it accepts a null-terminated bytestring instead of specifically an ANSI string. What data ends up in the export table is likely similar to the linux filesystem case, only with less likelihood of the environment telling you its encoding. > I already patched _PyImport_GetDynLoadFunc() for Windows: the path is > now a Unicode object instead of a byte string encoded to the filesystem > encoding. _PyImport_GetDynLoadWindows() uses GetFullPathNameW() and > LoadLibraryExW(). The work to be fully Unicode compliant (for the path > field, not for the name) is not completly done... but I have a pending > patch, see: > http://bugs.python.org/issue11619 > > But this patch is huge and creates many functions. I am not sure that we > need it, I will work on this later. I'm comfortable with the idea of requiring UTF-8 encoding for the initmodule entry points of modules named with non-ASCII identifiers, especially if there is nothing which works consistently today. I've only seen pure-ASCII library names in all my C++ work, so I feel it borders on YAGNI (but I like it in theory). As an alternate approach, one article I read suggested to use ordinals instead of names if you wanted to use non-ASCII names. Python could certainly try to load by ordinal on Windows, and fall back to loading by name. I don't have a clue what the rate of false positives would be. -- Michael Urman From phd at phdru.name Tue May 10 15:45:44 2011 From: phd at phdru.name (Oleg Broytman) Date: Tue, 10 May 2011 17:45:44 +0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: <20110510133314.66B48250041@webabinitio.net> References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> <20110510133314.66B48250041@webabinitio.net> Message-ID: <20110510134544.GA9665@iskra.aviel.ru> On Tue, May 10, 2011 at 09:33:13AM -0400, R. David Murray wrote: > commit: > 11999: sync based on comparing mtimes, not mtime to system clock > NEWS: > Issue 11999: fixed sporadic sync failure mailbox.Maildir due to its > trying to detect mtime changes by comparing to the system clock > instead of to the previous value of the mtime. > > commit: > #11873: Improve test regex so random directory names don't cause test to fail > NEWS: > Issue #11873: Change regex in test_compileall to fix occasional > failures when when the randomly generated temporary path happened to > match the regex. > > You will note the *active* verbs "fixed", "improve", and "change" > figure in there prominently :) Why "fixed" is in the past tense, but "improve", and "change" are in present tense? I use past tense to describe what I did on the code, and present simple to describe what the new code does when running. For example: "Fixed a bug in time comparison: compare mtime to mtime, not mtime to system clock" I.e., "fixed" - that what I did, and "compare" is what the code does. (I used an excerpt from above only for the example, not to correct something.) Oleg. -- Oleg Broytman http://phdru.name/ phd at phdru.name Programmers don't die, they just GOSUB without RETURN. From eliben at gmail.com Tue May 10 16:02:07 2011 From: eliben at gmail.com (Eli Bendersky) Date: Tue, 10 May 2011 17:02:07 +0300 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: <20110510131144.C8D75250041@webabinitio.net> References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: On Tue, May 10, 2011 at 16:11, R. David Murray wrote: > On Tue, 10 May 2011 08:36:38 +0300, Eli Bendersky > wrote: > > With an unlimited error message length it could make sense to say "Hey, I > > see 'x' may be assigned in this scope, so I mark it local. But this > access > > to 'x' happens before assignment - so ERROR". This isn't realistic, of > > course, so I'm wondering: > > > > 1. Does this error message (although unrealistic) capture all possible > > appearances of UnboundLocalError? > > 2. If the answer to (1) is yes - could it be usefully shortened to be > > clearer than the current "local variable referenced before assignment"? > > > > This may not be possible, of course, but it doesn't harm trying :-) > > How about: > > "reference to variable 'y' precedes an assignment that makes it a local > variable" > Yes, this is much better and not too long IMHO Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdmurray at bitdance.com Tue May 10 16:46:18 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 10 May 2011 10:46:18 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: <20110510134544.GA9665@iskra.aviel.ru> References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> <20110510133314.66B48250041@webabinitio.net> <20110510134544.GA9665@iskra.aviel.ru> Message-ID: <20110510144618.DEC5B250041@webabinitio.net> On Tue, 10 May 2011 17:45:44 +0400, Oleg Broytman wrote: > On Tue, May 10, 2011 at 09:33:13AM -0400, R. David Murray wrote: > > commit: > > 11999: sync based on comparing mtimes, not mtime to system clock > > NEWS: > > Issue 11999: fixed sporadic sync failure mailbox.Maildir due to its > > trying to detect mtime changes by comparing to the system clock > > instead of to the previous value of the mtime. > > > > commit: > > #11873: Improve test regex so random directory names don't cause test to fail > > NEWS: > > Issue #11873: Change regex in test_compileall to fix occasional > > failures when when the randomly generated temporary path happened to > > match the regex. > > > > You will note the *active* verbs "fixed", "improve", and "change" > > figure in there prominently :) > > Why "fixed" is in the past tense, but "improve", and "change" are in > present tense? > > I use past tense to describe what I did on the code, and present > simple to describe what the new code does when running. For example: > > "Fixed a bug in time comparison: compare mtime to mtime, not mtime to system clock" > > I.e., "fixed" - that what I did, and "compare" is what the code does. > > (I used an excerpt from above only for the example, not to correct > something.) Yes, that's a good point. I'll try to be more consistent about that in the future. Change should have been Changed. -- R. David Murray http://www.bitdance.com From ncoghlan at gmail.com Tue May 10 16:59:08 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Wed, 11 May 2011 00:59:08 +1000 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: <20110510131144.C8D75250041@webabinitio.net> References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: On Tue, May 10, 2011 at 11:11 PM, R. David Murray wrote: > How about: > > "reference to variable 'y' precedes an assignment that makes it a local > variable" For comparison, the error messages I was able to elicit from 2.7 were as follows: # Module level NameError: name 'bob' is not defined # Function level reference to implicit global NameError: global name 'bob' is not defined # Early reference to local UnboundLocalError: local variable 'bob' referenced before assignment # Early reference from closure NameError: free variable 'bob' referenced before assignment in enclosing scope Personally, I would just add "in current scope" to the existing error message for the unbound local case (and potentially collapse the exception hierarchy a bit by setting UnboundLocalError = NameError). Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From rdmurray at bitdance.com Tue May 10 19:31:04 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 10 May 2011 13:31:04 -0400 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: <20110510173107.74C9B250041@webabinitio.net> On Wed, 11 May 2011 00:59:08 +1000, Nick Coghlan wrote: > On Tue, May 10, 2011 at 11:11 PM, R. David Murray w= > rote: > > How about: > > > > "reference to variable 'y' precedes an assignment that makes it a local > > variable" > > For comparison, the error messages I was able to elicit from 2.7 were > as follows: > > # Module level > NameError: name 'bob' is not defined > > # Function level reference to implicit global > NameError: global name 'bob' is not defined > > # Early reference to local > UnboundLocalError: local variable 'bob' referenced before assignment > > # Early reference from closure > NameError: free variable 'bob' referenced before assignment in enclosing sc= > ope > > Personally, I would just add "in current scope" to the existing error > message for the unbound local case (and potentially collapse the > exception hierarchy a bit by setting UnboundLocalError = NameError). I don't think adding that phrase would add any clarity, myself. The mental disconnect comes from the fact that the UnboundLocal error message is emitted for the reference, but it is not immediately obvious *why* the variable is considered local. My rephrasing emphasizes that it is the assignment statement that led to that classification and therefore the error. This disconnect doesn't apply in the global cases. It applies less strongly in the free variable case because there is visibly another scope involved (that is, the triggering assignment isn't in the same scope as the reference producing the error message). -- R. David Murray http://www.bitdance.com From tjreedy at udel.edu Tue May 10 19:56:58 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 10 May 2011 13:56:58 -0400 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: On 5/10/2011 10:59 AM, Nick Coghlan wrote: > On Tue, May 10, 2011 at 11:11 PM, R. David Murray wrote: >> How about: >> >> "reference to variable 'y' precedes an assignment that makes it a local >> variable" > > For comparison, the error messages I was able to elicit from 2.7 were > as follows: > > # Module level > NameError: name 'bob' is not defined > > # Function level reference to implicit global > NameError: global name 'bob' is not defined > > # Early reference to local > UnboundLocalError: local variable 'bob' referenced before assignment I would change this to "local name 'bob' used before the assignment that makes it a local name" Calling names 'variables' is itself a point of confusion. > > # Early reference from closure > NameError: free variable 'bob' referenced before assignment in enclosing scope > > Personally, I would just add "in current scope" to the existing error > message for the unbound local case (and potentially collapse the > exception hierarchy a bit by setting UnboundLocalError = NameError). > > Cheers, > Nick. > -- Terry Jan Reedy From rdmurray at bitdance.com Tue May 10 20:31:17 2011 From: rdmurray at bitdance.com (R. David Murray) Date: Tue, 10 May 2011 14:31:17 -0400 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: <20110510183118.6D2B8250041@webabinitio.net> On Tue, 10 May 2011 13:56:58 -0400, Terry Reedy wrote: > On 5/10/2011 10:59 AM, Nick Coghlan wrote: > > On Tue, May 10, 2011 at 11:11 PM, R. David Murray wrote: > >> How about: > >> > >> "reference to variable 'y' precedes an assignment that makes it a local > >> variable" > > > > For comparison, the error messages I was able to elicit from 2.7 were > > as follows: > > > > # Module level > > NameError: name 'bob' is not defined > > > > # Function level reference to implicit global > > NameError: global name 'bob' is not defined > > > > # Early reference to local > > UnboundLocalError: local variable 'bob' referenced before assignment > > I would change this to > "local name 'bob' used before the assignment that makes it a local name" > > Calling names 'variables' is itself a point of confusion. Yes, your phrasing is much better. -- R. David Murray http://www.bitdance.com From eliben at gmail.com Tue May 10 20:59:04 2011 From: eliben at gmail.com (Eli Bendersky) Date: Tue, 10 May 2011 21:59:04 +0300 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: <20110510183118.6D2B8250041@webabinitio.net> References: <20110510131144.C8D75250041@webabinitio.net> <20110510183118.6D2B8250041@webabinitio.net> Message-ID: > > > # Early reference to local > > > UnboundLocalError: local variable 'bob' referenced before assignment > > > > I would change this to > > "local name 'bob' used before the assignment that makes it a local name" > > > > Calling names 'variables' is itself a point of confusion. > > Yes, your phrasing is much better. > +1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at pearwood.info Wed May 11 00:38:53 2011 From: steve at pearwood.info (Steven D'Aprano) Date: Wed, 11 May 2011 08:38:53 +1000 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: <4DC9BE7D.1070800@pearwood.info> Nick Coghlan wrote: > Personally, I would just add "in current scope" to the existing error > message for the unbound local case (and potentially collapse the > exception hierarchy a bit by setting UnboundLocalError = NameError). -0 That was the case prior to Python 2.0. Reverting is potentially a semantic change that will break any code that distinguishes between (global) NameError and (local) UnboundLocalError. But personally, I don't know why it was thought necessary to distinguish between them in the first place. -- Steven From fdrake at acm.org Wed May 11 01:37:09 2011 From: fdrake at acm.org (Fred Drake) Date: Tue, 10 May 2011 19:37:09 -0400 Subject: [Python-Dev] more timely detection of unbound locals In-Reply-To: <4DC9BE7D.1070800@pearwood.info> References: <20110510131144.C8D75250041@webabinitio.net> <4DC9BE7D.1070800@pearwood.info> Message-ID: On Tue, May 10, 2011 at 6:38 PM, Steven D'Aprano wrote: > I don't know why it was thought necessary to distinguish between them in the > first place. New users almost constantly expressed confusion by NameError when the name was clearly bound at global scope, and a subsequent assignment caused it to be considered a local in their function. -Fred -- Fred L. Drake, Jr.? ? "Give me the luxuries of life and I will willingly do without the necessities." ?? --Frank Lloyd Wright From palla74 at gmail.com Wed May 11 11:51:59 2011 From: palla74 at gmail.com (Palla) Date: Wed, 11 May 2011 11:51:59 +0200 Subject: [Python-Dev] EuroPython: Early Bird will end in 2 days! Message-ID: Hi all, If you plan to attend, you could save quite a bit on registration fees! The end of Early bird is on May 12th, Friday, 23:59:59 CEST. We'd like to ask to you to forward this post to anyone that you feel may be interested. We have an amazing lineup of tutorials, events and talks. We have some excellent keynote speakers and a very complete partner program... but early bird registration ends in 2 days! Right now, you still get discounts on talks and tutorials so if you plan to attend Register Now: http://ep2011.europython.eu/registration/ While you are booking, remember to have a look at the partner program and our offer for a prepaid, data+voice+tethering SIM. We'd like to ask to you to forward this post to anyone that you feel may be interested. All the best, -- ->PALLA From merwok at netwok.org Wed May 11 18:38:53 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Wed, 11 May 2011 18:38:53 +0200 Subject: [Python-Dev] Commit changelog: issue number and merges In-Reply-To: <20110509175447.4DC56250039@webabinitio.net> References: <1304937168.22910.21.camel@marge> <7fa082450fb750d082e71d5070a62171@netwok.org> <20110509175447.4DC56250039@webabinitio.net> Message-ID: <5899b3f80aa1a05b5f6f3364eebde44e@netwok.org> Le 09/05/2011 19:54, R. David Murray a ?crit : >>> No it isn't. The commit message isn't pulled into the new branch. >> Sorry, your terminology does not make sense. If you mean that the >> commit message is not reused in the new commit after the merge, >> it?s >> true. However, the commit message with the relevant information is >> available as part of the changesets that have been pulled and >> merged. > > The changesets are in the repository and there are pointers to them > from the merge changeset, sure, but the data isn't in the checkout > (that's how I understood "pulled in to the new branch"). No commit message is ever in the checkout, so I don?t follow you. > If I do 'hg log' and search for a revno (that I got from hg > annotate), > the commit message describing the change is not attached to that > revno, Ah, I understand your problem now. I would not object to a policy requiring to put helpful information in merge changesets commit messages, like ?Merge fixes for #4444 and #5555? or ?Merge doc fixes? when there are no bug reports. I?m not sure about the ?atomic? merge changesets idea that someone else expressed; I don?t think it would be that useful. > nor as far as I know is there a tool that makes it easy to get from > that > revno to the explanatory commit message. That's what Victor and I > are > talking about. Is there a tool that fixes this problem? I tend to use graphical tools for history viewing. I like the GTK version of TortoiseHg, or failing that the graph displayed by ?hg serve? if you enable the graphlog extension and use a browser with JavaScript. From merwok at netwok.org Wed May 11 18:39:21 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Wed, 11 May 2011 18:39:21 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: Hi, > That's right, though it's OK to provide a documented convenience API > for adding > handlers. I think I?ll aim for simplicity. We?ll document that we use the logger ?packaging? throughout and let people use getLogger and addHandler with that. > You don't necessarily need to set the level on the handler - why can > you not > just set it on the logger? The effect would often be the same: the > logger's > level is checked first, and then the handler's level. I thought that if we set the level on the logger, we would prevent third-party code to get some messages. E.g., we set level to INFO but pip uses some packaging functions and would like to get DEBUG messages. Regards From merwok at netwok.org Wed May 11 18:39:54 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Wed, 11 May 2011 18:39:54 +0200 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: <20110510144618.DEC5B250041@webabinitio.net> References: "\"<4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> " <20110510133314.66B48250041@webabinitio.net>" <20110510134544.GA9665@iskra.aviel.ru> <20110510144618.DEC5B250041@webabinitio.net> Message-ID: Le 10/05/2011 16:46, R. David Murray a ?crit : > On Tue, 10 May 2011 17:45:44 +0400, Oleg Broytman > wrote: >> Why "fixed" is in the past tense, but "improve", and "change" are >> in >> present tense? >> I use past tense to describe what I did on the code, and present >> simple to describe what the new code does when running. For example: Funny, I always use the present tense, to convey what the code does now. From merwok at netwok.org Wed May 11 19:05:48 2011 From: merwok at netwok.org (=?UTF-8?Q?=C3=89ric_Araujo?=) Date: Wed, 11 May 2011 19:05:48 +0200 Subject: [Python-Dev] =?utf-8?q?=5BPython-checkins=5D_cpython_=282=2E7=29?= =?utf-8?q?=3A_=28Merge_3=2E1=29_Issue_=2312012=3A_ssl=2EPROTOCOL=5FSSLv2_?= =?utf-8?q?becomes_optional?= In-Reply-To: References: Message-ID: Le 10/05/2011 01:52, victor.stinner a ?crit : > http://hg.python.org/cpython/rev/3c87a13980be > changeset: 70001:3c87a13980be > branch: 2.7 > parent: 69996:c9f07c69b138 > user: Victor Stinner > date: Tue May 10 01:52:03 2011 +0200 > summary: > (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional ?(Merge 3.1)? is inaccurate for 2.7. Regards From tjreedy at udel.edu Wed May 11 19:45:39 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 11 May 2011 13:45:39 -0400 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: References: "\"<4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> " <20110510133314.66B48250041@webabinitio.net>" <20110510134544.GA9665@iskra.aviel.ru> <20110510144618.DEC5B250041@webabinitio.net> Message-ID: On 5/11/2011 12:39 PM, ?ric Araujo wrote: > Funny, I always use the present tense, to convey what the code does now. Which code ;-). At the moment you write a push message, your private clone does something different from the public repository (and other private clones). At the moment people read a push message, they may not have pulled the change, so that there is a difference between the repository and *their* clone. Besides the ambiguity, there is also inconsistency between writers. Hence my request for a few clarifying keystrokes when needed. -- Terry Jan Reedy From victor.stinner at haypocalc.com Wed May 11 20:08:49 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Wed, 11 May 2011 20:08:49 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional In-Reply-To: References: Message-ID: <1305137329.12577.1.camel@marge> Le mercredi 11 mai 2011 ? 19:05 +0200, ?ric Araujo a ?crit : > Le 10/05/2011 01:52, victor.stinner a ?crit : > > http://hg.python.org/cpython/rev/3c87a13980be > > changeset: 70001:3c87a13980be > > branch: 2.7 > > parent: 69996:c9f07c69b138 > > user: Victor Stinner > > date: Tue May 10 01:52:03 2011 +0200 > > summary: > > (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional > > ?(Merge 3.1)? is inaccurate for 2.7. Ah, why? I did not use "hg merge" command (but hg export|hg import), but it's a "merge" between two branches. Which term would you use? Victor From guido at python.org Wed May 11 20:48:50 2011 From: guido at python.org (Guido van Rossum) Date: Wed, 11 May 2011 11:48:50 -0700 Subject: [Python-Dev] Commit messages: please avoid temporal ambiguity In-Reply-To: References: <4DC8343C.2050005@nedbatchelder.com> <4DC84235.4060600@trueblade.com> <20110510133314.66B48250041@webabinitio.net> <20110510134544.GA9665@iskra.aviel.ru> <20110510144618.DEC5B250041@webabinitio.net> Message-ID: On Wed, May 11, 2011 at 9:39 AM, ?ric Araujo wrote: > Funny, I always use the present tense, to convey what the code does now. Yeah, and that's exactly what I am objecting to. Please describe what changed how, since that is the focus of the patch. -- --Guido van Rossum (python.org/~guido) From vinay_sajip at yahoo.co.uk Wed May 11 21:45:12 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Wed, 11 May 2011 19:45:12 +0000 (UTC) Subject: [Python-Dev] Problems with regrtest and with logging References: Message-ID: ?ric Araujo netwok.org> writes: > I thought that if we set the level on the logger, we would prevent > third-party code to get some messages. E.g., we set level to INFO but > pip uses some packaging functions and would like to get DEBUG messages. Then pip can set the level of the packaging logger as it wishes, perhaps in response to command-line arguments for verbosity. It'd be easier for pip to do that, regardless of which handlers are attached. And pip itself might be being used, say by virtualenv. It's hard in general to say what the top-level code will be, and generally that's the code which should set the handlers. The levels set by a library for its loggers are merely defaults. Applications using the library can choose to override those levels as they wish. Regards, Vinay Sajip From tjreedy at udel.edu Wed May 11 23:12:39 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 11 May 2011 17:12:39 -0400 Subject: [Python-Dev] [Python-checkins] cpython (2.7): (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional In-Reply-To: <1305137329.12577.1.camel@marge> References: <1305137329.12577.1.camel@marge> Message-ID: On 5/11/2011 2:08 PM, Victor Stinner wrote: > Le mercredi 11 mai 2011 ? 19:05 +0200, ?ric Araujo a ?crit : >> Le 10/05/2011 01:52, victor.stinner a ?crit : >>> http://hg.python.org/cpython/rev/3c87a13980be >>> changeset: 70001:3c87a13980be >>> branch: 2.7 >>> parent: 69996:c9f07c69b138 >>> user: Victor Stinner >>> date: Tue May 10 01:52:03 2011 +0200 >>> summary: >>> (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional >> >> ?(Merge 3.1)? is inaccurate for 2.7. > > Ah, why? I did not use "hg merge" command (but hg export|hg import), but > it's a "merge" between two branches. Which term would you use? export/import sounds like transport: "(transport from 3.1)" would be clear enough to me. -- Terry Jan Reedy From pythondev at genstein.net Thu May 12 04:35:16 2011 From: pythondev at genstein.net (Genstein) Date: Thu, 12 May 2011 03:35:16 +0100 Subject: [Python-Dev] py3k buffered I/O - flush() required between read/write? Message-ID: <4DCB4764.5080902@genstein.net> Hi all, Sincere apologies for posting a question without lurking for a while first. I'm not sure whether I'm being dumb (which is very plausible) or whether this is a potential bug. I asked on comp.lang.python but responses were equivocal, so I'm following the README.txt advice and asking here. If I'm out of line, do feel free to slap me down viciously, remove me from the list, or whatever seems most appropriate. Under py3k, is it necessary to flush() a file between buffered read/write calls in order to see consistent results? I have a case under Python 3.2 (r32:88445) where I see different results depending on whether buffering is active, on Gentoo Linux and Windows Vista. Perusing the docs and PEPs I couldn't seem to find an answer; I did find bufferedio.c's comment: "BufferedReader, BufferedWriter and BufferedRandom...share a single buffer...this enables interleaved reads and writes without flushing" which is suggestive but I may be taking it out of context. The following is the smallest code I can conjure which demonstrates the issue I'm seeing: [code] START = 0 MID = 1 LENGTH = 4 def test(buffering): f = open("test.bin", "w+b", buffering = buffering) for i in range(LENGTH): f.write(b'\x00') f.seek(MID) f.read(1) f.write(b'\x00') f.seek(MID) f.write(b'\x01') f.seek(START) f.seek(MID) print(f.read(1)) f.close() print("Buffered result: ") test(-1) print("Unbuffered result:") test(0) [end code] Output on both Gentoo and Vista is: Buffered result: b'\x00' Unbuffered result: b'\x01' I expected the results to be the same, but they aren't. The issue is reproducible with larger files provided that the constants are increased ~proportionally (START 0, MID 500, LENGTH 1000 for example). Transposing the buffered/unbuffered tests and/or using different buffer sizes for the buffered test seem have no effect. Apologies once more if I'm wasting your time. All the best, -eg. PS. By way of entirely belated introduction, I'm a UK software developer with a background mostly in C#, C++ and Lua in both "real software" and commercial games. In my spare time I mostly write code (curiously I don't know many developers who do; I suspect I just know the wrong people.) I perpetrated the Trizbort mapper for interactive fiction which doubtless nobody will have heard of, and with good reason. I'm toying with Python as a genuinely portable alternative to C# for my own projects, and so far loving it. From solipsis at pitrou.net Thu May 12 12:47:27 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 12 May 2011 12:47:27 +0200 Subject: [Python-Dev] py3k buffered I/O - flush() required between read/write? References: <4DCB4764.5080902@genstein.net> Message-ID: <20110512124727.3f4d921e@pitrou.net> Hello, On Thu, 12 May 2011 03:35:16 +0100 Genstein wrote: > > The following is the smallest code I can conjure which demonstrates the > issue I'm seeing: This is a bug indeed. Can you report it on http://bugs.python.org ? Thanks a lot for finding this, Antoine. From pythondev at genstein.net Thu May 12 15:22:22 2011 From: pythondev at genstein.net (Genstein) Date: Thu, 12 May 2011 14:22:22 +0100 Subject: [Python-Dev] py3k buffered I/O - flush() required between read/write? In-Reply-To: <20110512124727.3f4d921e@pitrou.net> References: <4DCB4764.5080902@genstein.net> <20110512124727.3f4d921e@pitrou.net> Message-ID: <4DCBDF0E.4070504@genstein.net> On 12/05/2011 11:47, Antoine Pitrou wrote: > This is a bug indeed. Can you report it on http://bugs.python.org ? > > Thanks a lot for finding this, > > Antoine. > Duly reported as http://bugs.python.org/issue12062. I'm glad it wasn't me being dumb(er than usual). It took a while to pin down to a small reproducible case. Thanks for the fast and definite response, I'll cheerfully revert to lurking now ;) All the best, -eg. From skip at montanaro.dyndns.org Thu May 12 18:33:37 2011 From: skip at montanaro.dyndns.org (Skip Montanaro) Date: Thu, 12 May 2011 11:33:37 -0500 (CDT) Subject: [Python-Dev] Could these restrictions be removed? Message-ID: <20110512163337.3758D12B7749@montanaro.dyndns.org> A friend at work who is new to Python wondered why this didn't work with pickle: class Outer: Class Inner: ... def __init__(self): self.i = Outer.Inner() I explained: > http://docs.python.org/library/pickle.html#what-can-be-pickled-and-unpickled > > > From that: > > # functions defined at the top level of a module > # built-in functions defined at the top level of a module > # classes that are defined at the top level of a module I've never questions this, but I wonder, is this a fundamental restriction or could it be overcome with a modest amount of work? Just curious... Skip From walter at livinglogic.de Thu May 12 18:58:12 2011 From: walter at livinglogic.de (=?UTF-8?B?V2FsdGVyIETDtnJ3YWxk?=) Date: Thu, 12 May 2011 18:58:12 +0200 Subject: [Python-Dev] Could these restrictions be removed? In-Reply-To: <4DCC10A3.9000209@livinglogic.de> References: <20110512163337.3758D12B7749@montanaro.dyndns.org> <4DCC10A3.9000209@livinglogic.de> Message-ID: <4DCC11A4.4050101@livinglogic.de> On 12.05.11 18:53, Walter D?rwald wrote: > On 12.05.11 18:33, skip at pobox.com wrote: > >> A friend at work who is new to Python wondered why this didn't work with >> pickle: >> >> class Outer: >> >> Class Inner: >> >> ... >> >> def __init__(self): >> self.i = Outer.Inner() >> >> I explained: >> >>> http://docs.python.org/library/pickle.html#what-can-be-pickled-and-unpickled >>> >>> >>> From that: >>> >>> # functions defined at the top level of a module >>> # built-in functions defined at the top level of a module >>> # classes that are defined at the top level of a module >> >> I've never questions this, but I wonder, is this a fundamental restriction >> or could it be overcome with a modest amount of work? > > This is related to http://bugs.python.org/issue633930 See also the thread started at: http://mail.python.org/pipermail/python-dev/2005-March/052454.html Servus, Walter From solipsis at pitrou.net Thu May 12 19:05:46 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Thu, 12 May 2011 19:05:46 +0200 Subject: [Python-Dev] Could these restrictions be removed? References: <20110512163337.3758D12B7749@montanaro.dyndns.org> Message-ID: <20110512190546.116a9a91@pitrou.net> On Thu, 12 May 2011 11:33:37 -0500 (CDT) Skip Montanaro wrote: > > A friend at work who is new to Python wondered why this didn't work with > pickle: > > class Outer: > > Class Inner: > > ... > > def __init__(self): > self.i = Outer.Inner() > [...] > > I've never questions this, but I wonder, is this a fundamental restriction > or could it be overcome with a modest amount of work? pickle uses heuristics to try to find out the "official name" of a class or function. It would be a matter of improving these heuristics. There are other cases in which pickle similarly fails: >>> pickle.dumps(random.random) b'\x80\x03crandom\nrandom\nq\x00.' >>> pickle.dumps(random.randint) Traceback (most recent call last): File "", line 1, in _pickle.PicklingError: Can't pickle : attribute lookup builtins.method failed Regards Antoine. From walter at livinglogic.de Thu May 12 18:53:55 2011 From: walter at livinglogic.de (=?UTF-8?B?V2FsdGVyIETDtnJ3YWxk?=) Date: Thu, 12 May 2011 18:53:55 +0200 Subject: [Python-Dev] Could these restrictions be removed? In-Reply-To: <20110512163337.3758D12B7749@montanaro.dyndns.org> References: <20110512163337.3758D12B7749@montanaro.dyndns.org> Message-ID: <4DCC10A3.9000209@livinglogic.de> On 12.05.11 18:33, skip at pobox.com wrote: > A friend at work who is new to Python wondered why this didn't work with > pickle: > > class Outer: > > Class Inner: > > ... > > def __init__(self): > self.i = Outer.Inner() > > I explained: > >> http://docs.python.org/library/pickle.html#what-can-be-pickled-and-unpickled >> >> >> From that: >> >> # functions defined at the top level of a module >> # built-in functions defined at the top level of a module >> # classes that are defined at the top level of a module > > I've never questions this, but I wonder, is this a fundamental restriction > or could it be overcome with a modest amount of work? This is related to http://bugs.python.org/issue633930 Servus, Walter From dickinsm at gmail.com Fri May 13 10:14:12 2011 From: dickinsm at gmail.com (Mark Dickinson) Date: Fri, 13 May 2011 09:14:12 +0100 Subject: [Python-Dev] Python Language Summit at EuroPython: 19th June In-Reply-To: <4DA9ACB5.6030505@python.org> References: <4DA9ACB5.6030505@python.org> Message-ID: Hi Michael, Sorry for the late reply; it's been kinda busy around here. If there are places left, I'll definitely be there at the summit. Congratulations on your impending doom! (And sorry to hear that you might not be there in Florence.) Mark On Sat, Apr 16, 2011 at 3:50 PM, Michael Foord wrote: > Hello all, > > This is an invite to all core-python developers, and developers of > alternative implementations, to attend the Python Language Summit at > EuroPython. The summit will be on June 19th and EuroPython this year will be > held at the beautiful city of Florence in Italy. > > ? ?http://ep2011.europython.eu/ > > If you are not a core-Python developer but would like to attend then please > email me privately and I will let you know if spaces are available. If you > are a core developer, or you have received a direct invitation, then please > respond by private email to let me know if you are able to attend. A maybe > is fine, you can always change your mind later. Attending for only part of > the day is fine. > > We expect the summit to run from 10am - 4pm with appropriate breaks. > > Like previous language summits it is an opportunity to discuss topics like, > Python 3 adoption, PEPs and changes for Python 3.3, the future of Python > 2.7, documentation, package index, web site, etc. > > If you have topics you'd like to discuss at the language summit please let > me know. > > Volunteers for taking notes at the language summit, for posting to > Python-dev and the Python Insiders blog after the event, would be much > appreciated. > > All the best, > > Michael Foord > > N.B. Due to my impending doom (oops, I mean impending fatherhood) I am not > yet 100% certain I will be able to attend. If I can't I will arrange for > someone else to chair. > > -- > http://www.voidspace.org.uk/ > > May you do good and not evil > May you find forgiveness for yourself and forgive others > May you share freely, never taking more than you give. > -- the sqlite blessing http://www.sqlite.org/different.html > > From sandeep.mathew at hp.com Fri May 13 11:25:44 2011 From: sandeep.mathew at hp.com (Mathew, Sandeep (OpenVMS)) Date: Fri, 13 May 2011 09:25:44 +0000 Subject: [Python-Dev] Python Support on OpenVMS Message-ID: Hi Folks, I am Sandeep Mathew from OpenVMS engineering in Hewlett-Packard. I have worked on various components of the OpenVMS operating system including MONITOR, TDF, EXEC, LIBRTL, DCL and SYSMAN. I happened to read this blog post about dropping OpenVMS support for further releases of python here: http://blog.python.org/2011/05/python-33-to-drop-support-for-os2.html. I am willing to spend time and effort to ensure that python remains supported on OpenVMS. Please let me know what needs to be done for continued OpenVMS Support in Python. Looking forward to working with the Python community. Regards Sandeep Mathew -------------- next part -------------- An HTML attachment was scrubbed... URL: From solipsis at pitrou.net Fri May 13 12:08:18 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Fri, 13 May 2011 12:08:18 +0200 Subject: [Python-Dev] Python Support on OpenVMS References: Message-ID: <20110513120818.139dca63@pitrou.net> Welcome Sandeep, > I am willing to spend time and effort to ensure that python remains supported > on OpenVMS. Please let me know what needs to be done for continued > OpenVMS Support in Python. Looking forward to working with the Python > community. The first thing would be to check whether the current development tree (the future Python 3.3) compiles and works fine for OpenVMS. Given that 3.x has had many changes compared to 2.x, this is not guaranteed. Instructions for getting the source tree are here: http://docs.python.org/devguide/setup.html Once the interpreter compiled fine, the second step is to run the test suite: http://docs.python.org/devguide/runtests.html Any compilation errors and test suite failures should be reported to the bug tracker (http://bugs.python.org/), preferably with patches since I doubt any of us would be able to fix the issues themselves. If you have any questions, don't hesitate to ask. Regards Antoine. From merwok at netwok.org Fri May 13 17:14:46 2011 From: merwok at netwok.org (=?UTF-8?B?w4lyaWMgQXJhdWpv?=) Date: Fri, 13 May 2011 17:14:46 +0200 Subject: [Python-Dev] [Python-checkins] cpython (2.7): (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional In-Reply-To: <1305137329.12577.1.camel@marge> References: <1305137329.12577.1.camel@marge> Message-ID: <4DCD4AE6.7030704@netwok.org> Le 11/05/2011 20:08, Victor Stinner a ?crit : >>> (Merge 3.1) Issue #12012: ssl.PROTOCOL_SSLv2 becomes optional >> ?(Merge 3.1)? is inaccurate for 2.7. > Ah, why? I did not use "hg merge" command (but hg export|hg import), but > it's a "merge" between two branches. Which term would you use? I prefer to use merge only to refer to hg merges. The 2.7 and 3.x lines are independent, so I wouldn?t put any marker in the commit message, just use the same as the message used in 3.1. Regards From merwok at netwok.org Fri May 13 17:35:01 2011 From: merwok at netwok.org (=?UTF-8?B?w4lyaWMgQXJhdWpv?=) Date: Fri, 13 May 2011 17:35:01 +0200 Subject: [Python-Dev] [Python-checkins] Python Regression Test Failures doc (1) In-Reply-To: <20110508200046.GA2465@kbk-i386-bb.dyndns.org> References: <20110508200046.GA2465@kbk-i386-bb.dyndns.org> Message-ID: <4DCD4FA5.3040607@netwok.org> Hi, Le 08/05/2011 22:00, Neal Norwitz a ?crit : > rm -rf build/* > rm -rf tools/sphinx > rm -rf tools/pygments > rm -rf tools/jinja2 > rm -rf tools/docutils > Checking out Sphinx... > svn: PROPFIND request failed on '/projects/external/Sphinx-0.6.5/sphinx' > svn: PROPFIND of '/projects/external/Sphinx-0.6.5/sphinx': Could not resolve hostname `svn.python.org': Host not found (http://svn.python.org) > make: *** [checkout] Error 1 I always wonder about these messages. They?re mostly error messages recently; what are python-checkins subscribers supposed to do in reaction? In non-error mode, what are they useful for? Thanks in advance for enlightening me. Regards From merwok at netwok.org Fri May 13 17:44:00 2011 From: merwok at netwok.org (=?UTF-8?B?w4lyaWMgQXJhdWpv?=) Date: Fri, 13 May 2011 17:44:00 +0200 Subject: [Python-Dev] [Python-checkins] cpython (3.1): Fix for issue 10684: Folders get deleted when trying to change case with In-Reply-To: References: Message-ID: <4DCD51C0.9080304@netwok.org> Hi, Le 06/05/2011 11:32, ronald.oussoren a ?crit : > http://hg.python.org/cpython/rev/26da299ca88e > summary: > Fix for issue 10684: Folders get deleted when trying to change case with shutil.move (case insensitive file systems only) > > - except OSError: > + except OSError as exc: > if os.path.isdir(src): > if _destinsrc(src, dst): > raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst)) Is this change a debugging leftover? Regards From status at bugs.python.org Fri May 13 18:07:22 2011 From: status at bugs.python.org (Python tracker) Date: Fri, 13 May 2011 18:07:22 +0200 (CEST) Subject: [Python-Dev] Summary of Python tracker Issues Message-ID: <20110513160722.1F2C31CE85@psf.upfronthosting.co.za> ACTIVITY SUMMARY (2011-05-06 - 2011-05-13) Python tracker at http://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue. Do NOT respond to this message. Issues counts and deltas: open 2784 ( +1) closed 21069 (+52) total 23853 (+53) Open issues with patches: 1198 Issues opened (36) ================== #6011: python doesn't build if prefix contains non-ascii characters http://bugs.python.org/issue6011 reopened by haypo #11786: ConfigParser.[Raw]ConfigParser optionxform() http://bugs.python.org/issue11786 reopened by eric.araujo #11873: test_regexp() of test_compileall fails occassionally http://bugs.python.org/issue11873 reopened by haypo #11977: Document int.conjugate, .denominator, ... http://bugs.python.org/issue11977 reopened by georg.brandl #12019: Dead or buggy code in importlib.test.__main__ http://bugs.python.org/issue12019 opened by eric.araujo #12020: Attribute error with flush on stdout,stderr http://bugs.python.org/issue12020 opened by Jimbofbx #12021: mmap.read requires an argument http://bugs.python.org/issue12021 opened by rich-noir #12022: AttributeError should report the same details when raised by l http://bugs.python.org/issue12022 opened by dholth #12024: 2.6 svn and hg branches are out of sync http://bugs.python.org/issue12024 opened by barry #12026: Support more of MSI api http://bugs.python.org/issue12026 opened by markm #12028: threading._get_ident(): remove it in the doc and make it publi http://bugs.python.org/issue12028 opened by haypo #12029: ABC registration of Exceptions http://bugs.python.org/issue12029 opened by acooke #12034: check_GetFinalPathNameByHandle() suboptimal http://bugs.python.org/issue12034 opened by pitrou #12037: test_email failures under Windows with the eol extension activ http://bugs.python.org/issue12037 opened by pitrou #12038: assertEqual doesn't display newline differences quite well http://bugs.python.org/issue12038 opened by pitrou #12040: Expose a Process.sentinel property (and fix polling loop in Pr http://bugs.python.org/issue12040 opened by pitrou #12042: What's New multiprocessing example error http://bugs.python.org/issue12042 opened by davipo #12043: Update shutil documentation http://bugs.python.org/issue12043 opened by sandro.tosi #12045: external shell command executed twice in ctypes.util._get_sona http://bugs.python.org/issue12045 opened by pitrou #12046: Windows build identification incomplete http://bugs.python.org/issue12046 opened by loewis #12048: Python 3, ZipFile Bug In Chinese http://bugs.python.org/issue12048 opened by yaoyu #12049: expose RAND_bytes() function of OpenSSL http://bugs.python.org/issue12049 opened by haypo #12050: unconsumed_tail of zlib.Decompress is not always cleared on de http://bugs.python.org/issue12050 opened by Takeshi.Yoshino #12053: Add prefetch() for Buffered IO (experiment) http://bugs.python.org/issue12053 opened by jcon #12055: doctest not working on nested functions http://bugs.python.org/issue12055 opened by dabrahams #12057: HZ codec has no test http://bugs.python.org/issue12057 opened by haypo #12059: hashlib does not handle missing hash functions correctly http://bugs.python.org/issue12059 opened by Ian.Wienand #12060: Python doesn't support real time signals http://bugs.python.org/issue12060 opened by haypo #12063: tokenize module appears to treat unterminated single and doubl http://bugs.python.org/issue12063 opened by Devin Jeanpierre #12065: test_ssl failure when svn.python.org fails to resolve http://bugs.python.org/issue12065 opened by r.david.murray #12066: Empty ('') xmlns attribute is not properly handled by xml.dom. http://bugs.python.org/issue12066 opened by atamyrat #12067: Doc: remove errors about mixed-type comparisons. http://bugs.python.org/issue12067 opened by terry.reedy #12068: test_logging failure in test_rollover http://bugs.python.org/issue12068 opened by pitrou #12069: test_signal.test_without_siginterrupt() failure on AMD64 OpenI http://bugs.python.org/issue12069 opened by haypo #12070: Unlimited loop in sysconfig._parse_makefile() http://bugs.python.org/issue12070 opened by haypo #12071: test_concurrent_futures.test_context_manager_shutdown() hangs http://bugs.python.org/issue12071 opened by haypo Most recent 15 issues with no replies (15) ========================================== #12071: test_concurrent_futures.test_context_manager_shutdown() hangs http://bugs.python.org/issue12071 #12069: test_signal.test_without_siginterrupt() failure on AMD64 OpenI http://bugs.python.org/issue12069 #12066: Empty ('') xmlns attribute is not properly handled by xml.dom. http://bugs.python.org/issue12066 #12063: tokenize module appears to treat unterminated single and doubl http://bugs.python.org/issue12063 #12059: hashlib does not handle missing hash functions correctly http://bugs.python.org/issue12059 #12055: doctest not working on nested functions http://bugs.python.org/issue12055 #12053: Add prefetch() for Buffered IO (experiment) http://bugs.python.org/issue12053 #12045: external shell command executed twice in ctypes.util._get_sona http://bugs.python.org/issue12045 #12043: Update shutil documentation http://bugs.python.org/issue12043 #12037: test_email failures under Windows with the eol extension activ http://bugs.python.org/issue12037 #12034: check_GetFinalPathNameByHandle() suboptimal http://bugs.python.org/issue12034 #12029: ABC registration of Exceptions http://bugs.python.org/issue12029 #12024: 2.6 svn and hg branches are out of sync http://bugs.python.org/issue12024 #12019: Dead or buggy code in importlib.test.__main__ http://bugs.python.org/issue12019 #11992: sys.settrace doesn't disable tracing if a local trace function http://bugs.python.org/issue11992 Most recent 15 issues waiting for review (15) ============================================= #12060: Python doesn't support real time signals http://bugs.python.org/issue12060 #12059: hashlib does not handle missing hash functions correctly http://bugs.python.org/issue12059 #12057: HZ codec has no test http://bugs.python.org/issue12057 #12049: expose RAND_bytes() function of OpenSSL http://bugs.python.org/issue12049 #12040: Expose a Process.sentinel property (and fix polling loop in Pr http://bugs.python.org/issue12040 #12026: Support more of MSI api http://bugs.python.org/issue12026 #12018: No tests for ntpath.samefile, ntpath.sameopenfile http://bugs.python.org/issue12018 #12015: possible characters in temporary file name is too few http://bugs.python.org/issue12015 #12014: str.format parses replacement field incorrectly http://bugs.python.org/issue12014 #12008: HtmlParser non-strict goes wrong with unquoted attributes http://bugs.python.org/issue12008 #12004: PyZipFile.writepy gives internal error on syntax errors http://bugs.python.org/issue12004 #12002: ftplib.FTP.abort fails with TypeError on Python 3.x http://bugs.python.org/issue12002 #11999: sporadic failure in test_mailbox http://bugs.python.org/issue11999 #11998: test_signal cannot test blocked signals if _tkinter is loaded; http://bugs.python.org/issue11998 #11996: libpython.py: nicer py-bt output http://bugs.python.org/issue11996 Top 10 most discussed issues (10) ================================= #11948: Tutorial/Modules - small fix to better clarify the modules sea http://bugs.python.org/issue11948 15 msgs #6727: ImportError when package is symlinked on Windows http://bugs.python.org/issue6727 14 msgs #8407: expose signalfd(2) and pthread_sigmask in the signal module http://bugs.python.org/issue8407 14 msgs #11877: Change os.fsync() to support physical backing store syncs http://bugs.python.org/issue11877 14 msgs #12015: possible characters in temporary file name is too few http://bugs.python.org/issue12015 12 msgs #9205: Parent process hanging in multiprocessing if children terminat http://bugs.python.org/issue9205 10 msgs #10666: OS X installer variants have confusing readline differences http://bugs.python.org/issue10666 10 msgs #12057: HZ codec has no test http://bugs.python.org/issue12057 10 msgs #5723: Incomplete json tests http://bugs.python.org/issue5723 9 msgs #12010: Compile fails when sizeof(wchar_t) == 1 http://bugs.python.org/issue12010 9 msgs Issues closed (51) ================== #1195: Problems on Linux with Ctrl-D and Ctrl-C during raw_input http://bugs.python.org/issue1195 closed by haypo #1350: IDLE - CallTips enhancement - show full doc-string in new wind http://bugs.python.org/issue1350 closed by kbk #5154: OSX broken poll testing doesn't work http://bugs.python.org/issue5154 closed by ronaldoussoren #5559: IDLE Output Window 's goto fails when path has spaces http://bugs.python.org/issue5559 closed by kbk #8498: Cannot use backlog = 0 for sockets http://bugs.python.org/issue8498 closed by pitrou #8808: imaplib should support SSL contexts http://bugs.python.org/issue8808 closed by pitrou #9971: Optimize BufferedReader.readinto http://bugs.python.org/issue9971 closed by pitrou #10169: socket.sendto raises incorrect exception when passed incorrect http://bugs.python.org/issue10169 closed by ezio.melotti #10419: distutils command build_scripts fails with UnicodeDecodeError http://bugs.python.org/issue10419 closed by python-dev #11072: Add MLSD command support to ftplib http://bugs.python.org/issue11072 closed by giampaolo.rodola #11164: xml shouldn't use _xmlplus http://bugs.python.org/issue11164 closed by python-dev #11347: libpython3.so: Broken soname and linking http://bugs.python.org/issue11347 closed by python-dev #11607: Apllication crashes when saving file http://bugs.python.org/issue11607 closed by ronaldoussoren #11617: Sporadic failure in test_httpservers http://bugs.python.org/issue11617 closed by haypo #11743: Rewrite PipeConnection and Connection in pure Python http://bugs.python.org/issue11743 closed by pitrou #11799: urllib HTTP authentication behavior with unrecognized auth met http://bugs.python.org/issue11799 closed by orsenthil #11888: Add C99's log2() function to the math library http://bugs.python.org/issue11888 closed by haypo #11896: Save on Close fails in IDLE, from Linux system http://bugs.python.org/issue11896 closed by kbk #11910: test_heapq C tests are not skipped when _heapq is missing http://bugs.python.org/issue11910 closed by ezio.melotti #11916: A few errnos from OSX http://bugs.python.org/issue11916 closed by python-dev #11927: SMTP_SSL doesn't use port 465 by default http://bugs.python.org/issue11927 closed by pitrou #11962: Buildbot reliability http://bugs.python.org/issue11962 closed by skrah #11968: wsgiref's wsgi application sample code does not work http://bugs.python.org/issue11968 closed by orsenthil #11972: input does not strip a trailing newline correctly on Windows http://bugs.python.org/issue11972 closed by terry.reedy #11994: [2.7/gcc-4.4.3] Segfault under valgrind in string.split() http://bugs.python.org/issue11994 closed by haypo #12001: Extend json.dumps to handle N-triples strings http://bugs.python.org/issue12001 closed by terry.reedy #12011: The signal module should raise OSError for OS-related exceptio http://bugs.python.org/issue12011 closed by haypo #12012: _ssl module doesn't compile with OpenSSL 1.0.0d: SSLv2_method http://bugs.python.org/issue12012 closed by haypo #12013: file /usr/local/lib/python3.1/lib-dynload/_socket.so: symbol i http://bugs.python.org/issue12013 closed by eric.araujo #12017: Decoding a highly-nested object with json (_speedups enabled) http://bugs.python.org/issue12017 closed by ezio.melotti #12023: non causal behavior http://bugs.python.org/issue12023 closed by ezio.melotti #12025: strangely missing separator in "resource" table http://bugs.python.org/issue12025 closed by jcea #12027: Optimize import this (patch to make it 10x faster) http://bugs.python.org/issue12027 closed by rhettinger #12030: Roundup Refused Update with No text/plain http://bugs.python.org/issue12030 closed by benjamin.peterson #12031: subprocess module does not accept file twice http://bugs.python.org/issue12031 closed by neologix #12032: Tools/Scripts/crlv.py needs updating for python 3+ http://bugs.python.org/issue12032 closed by python-dev #12033: AttributeError: 'module' object has no attribute 'scipy' http://bugs.python.org/issue12033 closed by alex #12035: problem with installing validator.nu on windows http://bugs.python.org/issue12035 closed by amaury.forgeotdarc #12036: ConfigParser: Document items() added the vars dictionary to th http://bugs.python.org/issue12036 closed by python-dev #12039: test_logging: bad file descriptor on FreeBSD bot http://bugs.python.org/issue12039 closed by vinay.sajip #12041: test_os test_ctypes test_wait3 causes test_wait3 error http://bugs.python.org/issue12041 closed by pitrou #12044: subprocess.Popen.__exit__ doesn't wait for process end http://bugs.python.org/issue12044 closed by brian.curtin #12047: Expand the style guide http://bugs.python.org/issue12047 closed by rhettinger #12051: Segfaults in _json while encoding objects http://bugs.python.org/issue12051 closed by ezio.melotti #12052: round() erroneous for some large arguments http://bugs.python.org/issue12052 closed by mark.dickinson #12054: test_socket: replace custom _get_unused_port() by support.find http://bugs.python.org/issue12054 closed by pitrou #12056: "???" (HORIZONTAL ELLIPSIS) should be an alternative syntax fo http://bugs.python.org/issue12056 closed by benjamin.peterson #12058: Minor edits to comments in faulthandler http://bugs.python.org/issue12058 closed by ezio.melotti #12061: Remove duplicate 'key functions' entry in Glossary http://bugs.python.org/issue12061 closed by georg.brandl #12062: Buffered I/O inconsistent with unbuffered I/O in certain cases http://bugs.python.org/issue12062 closed by pitrou #12064: unexpected behavior with exception variable http://bugs.python.org/issue12064 closed by ezio.melotti From merwok at netwok.org Fri May 13 19:56:28 2011 From: merwok at netwok.org (=?UTF-8?B?w4lyaWMgQXJhdWpv?=) Date: Fri, 13 May 2011 19:56:28 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: <4DCD70CC.7030406@netwok.org> Le 11/05/2011 21:45, Vinay Sajip a ?crit : > ?ric Araujo netwok.org> writes: >> I thought that if we set the level on the logger, we would prevent >> third-party code to get some messages. E.g., we set level to INFO but >> pip uses some packaging functions and would like to get DEBUG messages. > Then pip can set the level of the packaging logger as it wishes, perhaps in > response to command-line arguments for verbosity. It'd be easier for pip to do > that, regardless of which handlers are attached. And pip itself might be being > used, say by virtualenv. It's hard in general to say what the top-level code > will be, and generally that's the code which should set the handlers. Okay. I?ll go ahead and remove handlers (except for the command-line script), and set the level on the logger. If it turns out that the code in packaging incorrectly resets the level set by calling code, we?ll fix it later; now we want to fix the tests to produce the patch that will add packaging to CPython. > The levels set by a library for its loggers are merely defaults. The conflict here is that there?s a class setting the logging level on instantiation, which could reset the level set by calling code. Thanks again for your messages (and blog). From eric at netwok.org Fri May 13 20:02:05 2011 From: eric at netwok.org (=?UTF-8?B?w4lyaWMgQXJhdWpv?=) Date: Fri, 13 May 2011 20:02:05 +0200 Subject: [Python-Dev] Problems with regrtest and with logging In-Reply-To: References: Message-ID: <4DCD721D.1080108@netwok.org> On Sat, May 7, 2011 at 3:51 AM, ?ric Araujo wrote: > regrtest helpfully reports when a test leaves the environment unclean > (sys.path, os.environ, logging._handlerList) A quick follow-up: I talked about regrtest with RDM on IRC, and I will use the context manager that detects changes in the ?if __name__ == '__main__'? blocks of our test files to find the guilty ones. Some warnings are subtle to track down: the test runs a command which instantiates a class which calls a function and here?s the code that sets an environment variable. In the future, I?ll take part in the efforts to reimplement parts of regrtest with new unittest features. Right now it?s quite painful to have to use either unittest to run just one file or regrtest to get the warnings. Cheers From sdaoden at googlemail.com Fri May 13 21:49:01 2011 From: sdaoden at googlemail.com (Steffen Daode Nurpmeso) Date: Fri, 13 May 2011 21:49:01 +0200 Subject: [Python-Dev] Summary of Python tracker Issues In-Reply-To: <20110513160722.1F2C31CE85@psf.upfronthosting.co.za> References: <20110513160722.1F2C31CE85@psf.upfronthosting.co.za> Message-ID: <20110513194901.GA40824@sherwood.local> The summary mails part 1 was declared as US-ASCII, 8bit, but it contained a UTF-8 character: > #12056: "???" (HORIZONTAL ELLIPSIS) should be an alternative syntax fo > http://bugs.python.org/issue12056 closed by benjamin.peterson This is handled without any problem by Python 3000 due to David Murrays patch of issue 11605 for 3.2 and 3.3. (It however broke my obviously insufficient non-postman thing :(, and it's of course not a valid mail, strictly speaking. So i report this just in case your stricken MUAs simply do the right thing and noone recognizes it at all.) May the juice be with you -- Steffen, sdaoden(*)(gmail.com) From ncoghlan at gmail.com Sat May 14 09:00:30 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sat, 14 May 2011 17:00:30 +1000 Subject: [Python-Dev] Python Support on OpenVMS In-Reply-To: <20110513120818.139dca63@pitrou.net> References: <20110513120818.139dca63@pitrou.net> Message-ID: On Fri, May 13, 2011 at 8:08 PM, Antoine Pitrou wrote: > Any compilation errors and test suite failures should be reported to > the bug tracker (http://bugs.python.org/), preferably with patches > since I doubt any of us would be able to fix the issues themselves. For ongoing support, it would also be *really* helpful if HP could provide an OpenVMS buildbot. Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From peck at us.ibm.com Sat May 14 18:03:10 2011 From: peck at us.ibm.com (Jon K Peck) Date: Sat, 14 May 2011 10:03:10 -0600 Subject: [Python-Dev] AUTO: Jon K Peck is out of the office (returning 05/18/2011) Message-ID: I am out of the office until 05/18/2011. I am out of the office traveling Wed - Thursday, May 11-12 and Saturday-Tuesday, May 14-17. I will have limited access to email during this time, so I will be delayed in responding. Note: This is an automated response to your message "Python-Dev Digest, Vol 94, Issue 25" sent on 5/14/11 4:00:03. This is the only notification you will receive while this person is away. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinay_sajip at yahoo.co.uk Sun May 15 10:55:13 2011 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 15 May 2011 08:55:13 +0000 (UTC) Subject: [Python-Dev] more timely detection of unbound locals References: <20110510131144.C8D75250041@webabinitio.net> Message-ID: Terry Reedy udel.edu> writes: > I would change this to > "local name 'bob' used before the assignment that makes it a local name" > > Calling names 'variables' is itself a point of confusion. +1 From senthil at uthcode.com Mon May 16 04:15:03 2011 From: senthil at uthcode.com (Senthil Kumaran) Date: Mon, 16 May 2011 10:15:03 +0800 Subject: [Python-Dev] Python Support on OpenVMS In-Reply-To: References: <20110513120818.139dca63@pitrou.net> Message-ID: <20110516021503.GB2808@kevin> On Sat, May 14, 2011 at 05:00:30PM +1000, Nick Coghlan wrote: > For ongoing support, it would also be *really* helpful if HP could > provide an OpenVMS buildbot. Yes, that would be best first step in the on-going struggle to support OpenVMS platform. The problem in the first place is no one has the hardware to try install python, leaving alone fixing the bugs in that. So, Sandeep, if you can setup a buildbot ( http://python.org/dev/buildbot/) and be the owner of the buildbot, it would be really helpful. -- Senthil From martin at v.loewis.de Mon May 16 09:20:41 2011 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 16 May 2011 09:20:41 +0200 Subject: [Python-Dev] Python Support on OpenVMS In-Reply-To: <20110516021503.GB2808@kevin> References: <20110513120818.139dca63@pitrou.net> <20110516021503.GB2808@kevin> Message-ID: <4DD0D049.9050407@v.loewis.de> Am 16.05.2011 04:15, schrieb Senthil Kumaran: > On Sat, May 14, 2011 at 05:00:30PM +1000, Nick Coghlan wrote: >> For ongoing support, it would also be *really* helpful if HP could >> provide an OpenVMS buildbot. > > Yes, that would be best first step in the on-going struggle to support > OpenVMS platform. I guess the best first step would be to make it compile at all. Then try to make it pass the test suite. This may well take several months to complete. Regards, Martin From ncoghlan at gmail.com Mon May 16 10:04:05 2011 From: ncoghlan at gmail.com (Nick Coghlan) Date: Mon, 16 May 2011 18:04:05 +1000 Subject: [Python-Dev] Python Support on OpenVMS In-Reply-To: <4DD0D049.9050407@v.loewis.de> References: <20110513120818.139dca63@pitrou.net> <20110516021503.GB2808@kevin> <4DD0D049.9050407@v.loewis.de> Message-ID: On Mon, May 16, 2011 at 5:20 PM, "Martin v. L?wis" wrote: > Am 16.05.2011 04:15, schrieb Senthil Kumaran: >> On Sat, May 14, 2011 at 05:00:30PM +1000, Nick Coghlan wrote: >>> For ongoing support, it would also be *really* helpful if HP could >>> provide an OpenVMS buildbot. >> >> Yes, that would be best first step in the on-going struggle to support >> OpenVMS platform. > > I guess the best first step would be to make it compile at all. Then try > to make it pass the test suite. This may well take several months to > complete. And then make sure the buildbot client runs properly. Still, having someone start down that path now (with a green stable buildbot as the target end state) provides a specific goal that any patches can work towards. Cheers, Nick. -- Nick Coghlan?? |?? ncoghlan at gmail.com?? |?? Brisbane, Australia From sandeep.mathew at hp.com Mon May 16 10:08:27 2011 From: sandeep.mathew at hp.com (Mathew, Sandeep (OpenVMS)) Date: Mon, 16 May 2011 08:08:27 +0000 Subject: [Python-Dev] Python Support on OpenVMS In-Reply-To: References: Message-ID: Hi All, Thanks for your responses!. First thing on my radar is to get buildbot working on OpenVMS. I had a quick glance at source, although buildbot is written purely in python it has many platform specific issues. See: https://github.com/buildbot/buildbot/blob/master/master/README.w32 However I am guessing that it may not be very difficult to resolve. I will concentrating on Itanium systems initially and will later port it to Alpha in a similar way. I have requested for an account in HP's OpenVMS cluster meant for open source development. I will kick off my work after the account has been activated! Regards Sandeep Mathew From solipsis at pitrou.net Mon May 16 15:46:47 2011 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 16 May 2011 15:46:47 +0200 Subject: [Python-Dev] Python Support on OpenVMS References: Message-ID: <20110516154647.4a927e2e@pitrou.net> On Mon, 16 May 2011 08:08:27 +0000 "Mathew, Sandeep (OpenVMS)" wrote: > Hi All, > > Thanks for your responses!. First thing on my radar is to get buildbot working on OpenVMS. > I had a quick glance at source, although buildbot is written purely in python it has many > platform specific issues. See: https://github.com/buildbot/buildbot/blob/master/master/README.w32 I think this file is way out of date. We have Windows buildbots running fine, and I don't think they required a modification of the buildbot software. Furthermore, you only need the buildbot slave, not master. See http://wiki.python.org/moin/BuildBot for more info Regards Antoine. From dsuch at gefira.pl Mon May 16 20:31:45 2011 From: dsuch at gefira.pl (Dariusz Suchojad) Date: Mon, 16 May 2011 20:31:45 +0200 Subject: [Python-Dev] Simple XML-RPC server over SSL/TLS In-Reply-To: <27392.1304016849@parc.com> References: <4DB975BB.1040402@netwok.org> <27392.1304016849@parc.com> Message-ID: <4DD16D91.6040805@gefira.pl> Bill Janssen wrote: Hello, >>> But what I would like to know, is if is there any reason why XML-RPC can't >>> optionally work over TLS/SSL using Python's ssl module. I'll create a >>> ticket, and send a patch, but I was wondering if it was a reason why this >>> was not implemented. >> >> I think there's no deeper reason than nobody thought about it. The ssl >> module is new in 2.6 and 3.x, xmlrpc is an older module for an old >> technology *cough*, so feel free to open a bug report. Patch guidelines >> are found at http://docs.python.org/devguide Thanks in advance! > > What he said. I'm not a big fan of XMLRPC in the first place, so I > probably didn't even notice that there wasn't SSL support for it. > > Go for it! I know it's been some time but I've only now spotted the thread and just in case it could be helpful to anyone, Spring Python project has implemented the feature last year for Python 2.x http://static.springsource.org/spring-python/1.2.x/sphinx/html/remoting.html#secure-xml-rpc cheers, -- Dariusz Suchojad From digitalxero at gmail.com Tue May 17 01:15:48 2011 From: digitalxero at gmail.com (Dj Gilcrease) Date: Mon, 16 May 2011 19:15:48 -0400 Subject: [Python-Dev] [OT] Server Side Clone mode Message-ID: I was wondering if there was a place I could get the modifications that have been made at hg.python.org to add the Server Side Clone to the hgweb interface. Dj Gilcrease ?____ ( | ? ? \ ?o ? ?() ? | ?o ?|`| ? | ? ? ?| ? ? ?/`\_/| ? ? ?| | ? ,__ ? ,_, ? ,_, ? __, ? ?, ? ,_, _| ? ? ?| | ? ?/ ? ? ?| ?| ? |/ ? / ? ? ?/ ? | ? |_/ ?/ ? ?| ? / \_|_/ (/\___/ ?|/ ?/(__,/ ?|_/|__/\___/ ? ?|_/|__/\__/|_/\,/ ?|__/ ? ? ? ? ?/| ? ? ? ? ?\| From mhammond at skippinet.com.au Tue May 17 09:38:07 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 17 May 2011 17:38:07 +1000 Subject: [Python-Dev] Updated version of PEP-0397 - Python launcher for Windows. Message-ID: <4DD225DF.2060605@skippinet.com.au> Hi all, I've updated PEP-0397 to try and address some of the comments from the last draft. I've checked the new version into hg, so you can find a full diff there, but the key items I've changed are: * Spelled out the "version qualifier" rules for the shebang lines. * Spelled out some customization options, both for fine-tuning the specific Python version selected and for supporting other Python implementations via "custom" commands. * Indicated the launcher is not supported at all on Win2k or earlier. * Removed some cruft. The new version is attached and I welcome all comments, including bike-shedding on the environment variable names and INI section/value names. Note that the reference implementation has not changed - I'll update that once there is general agreement on the functionality described in the PEP. Thanks, Mark -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pep-0397.txt URL: From victor.stinner at haypocalc.com Tue May 17 16:01:35 2011 From: victor.stinner at haypocalc.com (Victor Stinner) Date: Tue, 17 May 2011 16:01:35 +0200 Subject: [Python-Dev] Success x86 XP-4 2.7 buildbot without any log and should be a failure Message-ID: <201105171601.35813.victor.stinner@haypocalc.com> Hi, I broke recently all tests of CJK encodings (#12057) in Python 2.7 (sorry, it is now fixed). But the "x86 XP-4 2.7" buildbot is green, I don't understand how (the bug was not fixed in the build 894): http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%202.7/builds/894 This build doesn't contain any log. Victor From ziade.tarek at gmail.com Tue May 17 17:36:10 2011 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Tue, 17 May 2011 17:36:10 +0200 Subject: [Python-Dev] "packaging" merge imminent Message-ID: Hello I am about to merge packaging in the stdlib, and we will continue our work there :) The impact is: - addition of Lib/packaging - addition of test/test_packaging.py - changes in Lib/sysconfig.py - addition of Lib/sysconfig.cfg For the last one, I would like to make sure again that everyone is ok with having a .cfg file added in the Lib/ directory. If not, we need to discuss how to do this differently. == purpose of sysconfig.cfg == The sysconfig.cfg file is a ini-like file that sysconfig.py reads to get the installation paths. We currently have these paths harcoded in the python module. The next change I have planned is to allow several levels of configuration, like distutils.cfg does. sysconfig.py will look for a sysconfig.cfg file in these places: 1. the current working directory -- so can be potentially included in a project source release 2. the user home (specific location be defined, maybe in ~/local) [inherits from the previous one] 3. the global [inherits from the previous one] I have decided to make it a .cfg file instead of a .py file for various reasons: - easier for people to edit, without the danger of ending-up with an over-engineered python module (that's the problem we have with setup.py files) - the override logic is easier to implement and understand: if I want to change a single path, I add a ini file in my home with this single path. If I have no complains, the merge will happen tomorrow of my time == next moves == - make sysconfig.py stop reading Makefile and pyconfig.h, this will be done by adding a _sysconfig.py file created by the Makefile - continue our work in packaging for 3.3 - we're planning to merge the doc in Doc/packaging very soon (still working on it) Cheers Tarek -- Tarek Ziad? | http://ziade.org From lists at cheimes.de Tue May 17 18:42:59 2011 From: lists at cheimes.de (Christian Heimes) Date: Tue, 17 May 2011 18:42:59 +0200 Subject: [Python-Dev] "packaging" merge imminent In-Reply-To: References: Message-ID: <4DD2A593.90203@cheimes.de> Am 17.05.2011 17:36, schrieb Tarek Ziad?: > The next change I have planned is to allow several levels of > configuration, like distutils.cfg does. sysconfig.py will look for a > sysconfig.cfg file in these places: > > 1. the current working directory -- so can be potentially included in > a project source release > 2. the user home (specific location be defined, maybe in ~/local) > [inherits from the previous one] > 3. the global You may want to study my site package PEP [1] regarding possible security implications. I recommend that you ignore the current working directory and user's home directory under conditions like different effective user or the -E option. A good place for a local sysconfig.cfg could be the user's stdlib directory (e.g. ~/.local/lib/python3.2/sysconfig.cfg). Christian [1] http://www.python.org/dev/peps/pep-0370 From jdunck at gmail.com Tue May 17 19:40:04 2011 From: jdunck at gmail.com (Jeremy Dunck) Date: Tue, 17 May 2011 12:40:04 -0500 Subject: [Python-Dev] Bug in json (the format and the module) Message-ID: This blog post describes a bug in a common usage pattern of JSON: http://timelessrepo.com/json-isnt-a-javascript-subset That is, there are some characters which are legal in JSON serializations, but not in JavaScript strings. This works OK for JSON parsers, but a common use case of JSON is JSONP, where the result of a request is presumed to be executable javascript: