From jimjjewett at gmail.com Sat Apr 1 00:01:54 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Fri, 31 Mar 2006 17:01:54 -0500 Subject: [Python-Dev] Class decorators Message-ID: Nick Coghlan wrote: > [ much good, including the @instance decorator ] > P.S. If all you want is somewhere to store mutable > state between invocations, you can always use the > function's own attribute space >>> def f(): print "Hi world from %s!" % f >>> f() Hi world from ! Not really. That assumes the expected name is (permanently) bound to *this* function in this function's globals. That's normally true, but not always, so relying on it seems wrong. >>> f="a string" >>> g() Hi world from a string! And of course, sometimes I really do want shared state, or helpers (like other methods on a class), or one-time ininitialization plus per-call parameters (like the send method on 2.5 generators), or ... -jJ From skip at pobox.com Sat Apr 1 00:58:22 2006 From: skip at pobox.com (skip at pobox.com) Date: Fri, 31 Mar 2006 16:58:22 -0600 Subject: [Python-Dev] gmane.comp.python.devel.3000 has disappeared In-Reply-To: References: Message-ID: <17453.46094.197153.725065@montanaro.dyndns.org> Terry> For about a week, I have been reading and occasionally posting to Terry> the new pydev-3000 mailing list via the gmane mirror Terry> gmane.comp.lang.devel.3000. Today, it has disappeared and was Terry> still gone after reloading their newsgroup list. Was this Terry> intentional on the part of the mail list maintainers? (I Terry> certainly hope not!) Or is it a repairable glitch somewhere Terry> between the list and gmane? Gmane is subscribed. I've sent a message to them. Hopefully they will get things corrected soon. Skip From martin at v.loewis.de Sat Apr 1 00:59:03 2006 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sat, 01 Apr 2006 00:59:03 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigned abug/patch In-Reply-To: References: <9e804ac0603271427p332b5a9cid84380b44aca1a33@mail.gmail.com> <00ff01c6523f$7c583290$bf03030a@trilan> <1143554576.2310.161.camel@geddy.wooz.org> <17449.21764.475497.457592@montanaro.dyndns.org> <44298954.4040705@v.loewis.de> Message-ID: <442DB437.6070108@v.loewis.de> Robert Kern wrote: > FWIW: Trac has a Sourceforge bug tracker import script: > > http://projects.edgewall.com/trac/browser/trunk/contrib/sourceforge2trac.py > > Apologies: for the other blank reply. That isn't actually worth that much: somebody would need to operate it, too. Mere existence doesn't help. Regards, Martin From barry at python.org Sat Apr 1 00:38:22 2006 From: barry at python.org (Barry Warsaw) Date: Fri, 31 Mar 2006 17:38:22 -0500 Subject: [Python-Dev] gmane.comp.python.devel.3000 has disappeared In-Reply-To: References: Message-ID: <1143844702.346.11.camel@resist.wooz.org> On Fri, 2006-03-31 at 15:13 -0500, Terry Reedy wrote: > For about a week, I have been reading and occasionally posting to the new > pydev-3000 mailing list via the gmane mirror gmane.comp.lang.devel.3000. > Today, it has disappeared and was still gone after reloading their > newsgroup list. Was this intentional on the part of the mail list > maintainers? (I certainly hope not!) Or is it a repairable glitch > somewhere between the list and gmane? No idea, but the ng's do appear to be gone. Definitely not intentional on our part! -Barry -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 309 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20060331/27b9ec8b/attachment.pgp From jimjjewett at gmail.com Sat Apr 1 01:10:49 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Fri, 31 Mar 2006 18:10:49 -0500 Subject: [Python-Dev] reference leaks, __del__, and annotations Message-ID: Duncan Booth wrote: > Surely if you have a cycle what you want to do is to pick just *one* of the > objects in the cycle and break the link which makes it participate in the > cycle. No, I really meant to do them all. I was trying to avoid creating an attractive nuisance. In http://mail.python.org/pipermail/python-dev/2006-March/063239.html, Thomas Wouters categorized the purpose of __del__ methods as [paraphrased] (A) Resource Cleanup (cycles irrelevant) (B) Object created a cycle, and knows how to break it safely. (C) Those which do things the style guide warns against. The catch is that objects in the first two categories have no way to know when they should do the cleanup, except by creating a __del__ method (as generators now do). For category (A), their __del__ methods should be called as early as possible. Even for category (B), it does no harm. Why waste time recalculating cycles more often than required? If the object is lying about whether it can be used to safely break cycles, that is a bug, and I would rather catch it as early as possible, instead of letting it hide behind "oh well, the cycle was already broken". In fairness, I had not fully considered category(C), when an object intends not only to revive itself, but to prevent its subobjects from cleaning up either. Nick Coghlan > A simple Boolean attribute (e.g. __finalized__) should be enough. ... > If it's both present and true, the GC can ignore the finaliser on that instance That doesn't really take care of resource release, which needs to be called, and called early.(And the name will sound odd if it holds resources only sometimes, so that it has to flip the __finalized__ attribute.) -jJ From tjreedy at udel.edu Sat Apr 1 01:36:31 2006 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 31 Mar 2006 18:36:31 -0500 Subject: [Python-Dev] gmane.comp.python.devel.3000 has disappeared References: Message-ID: "Guido van Rossum" wrote in message news:ca471dc20603311238o79dafb4bu5ad78bccd7b593a2 at mail.gmail.com... > Wasn't my intention. Good ;-) > gmane is black magic to me (I've never used it) so I can't be much > help debugging this... I did add 3 new admins and changed the list > password. Since one of the last messages I read was your announcement of the coming changeover, I suspect some part of that might be the cause. Skip > Gmane is subscribed. I've sent a message to them. Hopefully they will > get > things corrected soon. I posted a note to gmane.discuss before I read the second sentence. But I will probably have to confirm my humaness before it goes thru, so I will let it sit a day first. Thanks for responding. Terry Jan Reedy From greg.ewing at canterbury.ac.nz Sat Apr 1 02:52:23 2006 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 01 Apr 2006 12:52:23 +1200 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: <442D2E47.8070809@gmail.com> References: <442D2E47.8070809@gmail.com> Message-ID: <442DCEC7.9090906@canterbury.ac.nz> Nick Coghlan wrote: > Generators are even more special, in that they only require finalisation in > the first place if they're stopped on a yield statement inside a try-finally > block. I find it rather worrying that there could be a few rare cases in which my generators cause memory leaks, through no fault of my own and without my being able to do anything about it. Will there be a coding practice one can follow to ensure that this doesn't happen? -- Greg From ncoghlan at gmail.com Sat Apr 1 06:58:34 2006 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sat, 01 Apr 2006 14:58:34 +1000 Subject: [Python-Dev] Class decorators In-Reply-To: References: Message-ID: <442E087A.1060401@gmail.com> Jim Jewett wrote: > Nick Coghlan wrote: > >> [ much good, including the @instance decorator ] > >> P.S. If all you want is somewhere to store mutable >> state between invocations, you can always use the >> function's own attribute space > > >>> def f(): print "Hi world from %s!" % f > > >>> f() > Hi world from ! > > Not really. That assumes the expected name is (permanently) bound to > *this* function in this function's globals. That's normally true, but > not always, so relying on it seems wrong. Well, true. If you want it to be bullet-proof, you have to use a closure instead: >>> def make_f(): ... def f(): ... print "Hi world from %s!" % f ... return f ... >>> f = make_f() >>> f() Hi world from ! The point about the decorators still holds - they stay with the function they're decorating (the inner one), and you don't need to make any of the changes needed in order to decorate the class instead. The above is also a use case for a *function* decorator I've occasionally wanted - an @result decorator, that is the equivalent of the @instance decorator I suggested for classes: >>> def result(f): ... return f() ... >>> @result ... def f(): ... def f(): ... print "Hi world from %s!" % f ... return f ... >>> f() Hi world from ! I never actually did it, though, as I was stuck on Python 2.2 at the time. This is something of a tangent to the real discussion though, so I'll leave this one there :) Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From ncoghlan at gmail.com Sat Apr 1 07:27:45 2006 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sat, 01 Apr 2006 15:27:45 +1000 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: <442DCEC7.9090906@canterbury.ac.nz> References: <442D2E47.8070809@gmail.com> <442DCEC7.9090906@canterbury.ac.nz> Message-ID: <442E0F51.7030608@gmail.com> Greg Ewing wrote: > Nick Coghlan wrote: > >> Generators are even more special, in that they only require finalisation in >> the first place if they're stopped on a yield statement inside a try-finally >> block. > > I find it rather worrying that there could be a > few rare cases in which my generators cause > memory leaks, through no fault of my own and > without my being able to do anything about it. The GC changes PJE is looking at are to make sure you *can* do something about it. If the generator hasn't been started, or has already finished, then the GC won't consider it as needing finalisation. > Will there be a coding practice one can follow > to ensure that this doesn't happen? I believe PJE's fix should take care of most cases (depending on how aggressive we can safely be, it may even take care of all of them). If there are any remaining cases, I think the main thing is to avoid keeping half-finished generators around: from contextlib import closing with closing(itr): # Use the iterator in here as you wish # secure in the knowledge it will be # cleaned up promptly when you are done # whether it is a file, a generator or # something with a database connection for item in itr: print item Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From greg.ewing at canterbury.ac.nz Sat Apr 1 08:50:02 2006 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 01 Apr 2006 18:50:02 +1200 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: <442E0F51.7030608@gmail.com> References: <442D2E47.8070809@gmail.com> <442DCEC7.9090906@canterbury.ac.nz> <442E0F51.7030608@gmail.com> Message-ID: <442E229A.8030608@canterbury.ac.nz> Nick Coghlan wrote: > from contextlib import closing > > with closing(itr): > # Use the iterator in here as you wish > # secure in the knowledge it will be > # cleaned up promptly when you are done > # whether it is a file, a generator or > # something with a database connection > for item in itr: > print item I seem to remember we've been here before. I'll be disappointed if I have to wrap every for-loop that I write in a with-statement on the offchance that it might be using a generator that needs finalisation in order to avoid leaking memory. I'm becoming more and more convinced that we desperately need something better than __del__ methods to do finalisation. A garbage collector that can't be relied upon to collect garbage is simply not acceptable. -- Greg From tds333+pydev at gmail.com Sat Apr 1 11:19:21 2006 From: tds333+pydev at gmail.com (Wolfgang Langner) Date: Sat, 1 Apr 2006 11:19:21 +0200 Subject: [Python-Dev] gmane.comp.python.devel.3000 has disappeared In-Reply-To: <17453.46094.197153.725065@montanaro.dyndns.org> References: <17453.46094.197153.725065@montanaro.dyndns.org> Message-ID: <4c45c1530604010119j377a80e2xdc0dd8cf64cfaff5@mail.gmail.com> On 4/1/06, skip at pobox.com wrote: > > Terry> For about a week, I have been reading and occasionally posting to > Terry> the new pydev-3000 mailing list via the gmane mirror > Terry> gmane.comp.lang.devel.3000. Today, it has disappeared and was > Terry> still gone after reloading their newsgroup list. Was this > Terry> intentional on the part of the mail list maintainers? (I > Terry> certainly hope not!) Or is it a repairable glitch somewhere > Terry> between the list and gmane? > > Gmane is subscribed. I've sent a message to them. Hopefully they will get > things corrected soon. Yes Gmane is subscribed. I checked if there is a pydev-3000 newsgroup on there server. Python 3000 new group is: http://dir.gmane.org/gmane.comp.python.python-3000.devel I tested it (subscribed) and it works. Try to refresh your subscription list in the news reader. -- bye by Wolfgang From thomas at python.org Sat Apr 1 12:06:38 2006 From: thomas at python.org (Thomas Wouters) Date: Sat, 1 Apr 2006 12:06:38 +0200 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: <442E0F51.7030608@gmail.com> References: <442D2E47.8070809@gmail.com> <442DCEC7.9090906@canterbury.ac.nz> <442E0F51.7030608@gmail.com> Message-ID: <9e804ac0604010206r23c50904o71fecdbc45a80d37@mail.gmail.com> On 4/1/06, Nick Coghlan wrote: > > Greg Ewing wrote: > > I find it rather worrying that there could be a > > few rare cases in which my generators cause > > memory leaks, through no fault of my own and > > without my being able to do anything about it. > > The GC changes PJE is looking at are to make sure you *can* do something > about > it. If the generator hasn't been started, or has already finished, then > the GC > won't consider it as needing finalisation. Actually, if a generator has already finished, it no longer holds a suspended frame alive, and there is no cycle (at least not through the generator.) That's why test_generators no longer leaks; explicitly closing the generator breaks the cycle. So the only thing fixing GC would add is cleaning up cycles where a created but not started generator is the only thing keeping the cycle alive. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060401/903cf1d2/attachment.html From thomas at python.org Sat Apr 1 12:19:34 2006 From: thomas at python.org (Thomas Wouters) Date: Sat, 1 Apr 2006 12:19:34 +0200 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: <442E229A.8030608@canterbury.ac.nz> References: <442D2E47.8070809@gmail.com> <442DCEC7.9090906@canterbury.ac.nz> <442E0F51.7030608@gmail.com> <442E229A.8030608@canterbury.ac.nz> Message-ID: <9e804ac0604010219x2c4f5306w5053570eae1de04d@mail.gmail.com> On 4/1/06, Greg Ewing wrote: > I'm becoming more and more convinced that we > desperately need something better than __del__ > methods to do finalisation. A garbage collector > that can't be relied upon to collect garbage > is simply not acceptable. Sure. I don't believe it's too hard, it just means violating some of the premises people have been writing __del__ methods under. For instance, to clean up cycles nicely we might have to set some attributes to None before calling __del__, so you can't rely on attributes being meaningful anymore. However, this is already the case for global names; I've seen many people wonder about their __del__ method raising warnings (since exceptions are ignored) going, say, 'NoneType has no attribute 'registry'' when they try to un-register their class but the global registry has been cleaned up already. While we're at it, I would like for the new __del__ (which would probably have to be a new method) to disallow reviving self, just because it makes it unnecessarily complicated and it's rarely needed. Allowing a partially deleted object (or an object part of a partially deleted reference-cycle) to revive itself is not terribly useful, and there's no way to restore the rest of the cycle. I suggested a __dealloc__ method earlier in the thread to do this. I didn't think of allowing attributes to be cleared before calling the method, but I do believe that is necessary to allow, now that I've thought more about it. An alternative would be to make GC check for a 'cleanup-cycle' method on any of the objects in the cycle, and just feed it the complete cycle of objects, asking it to clean it up itself (or maybe reconnect one of the objects itself.) That would also make debugging uncollectable cycles a lot easier ;-) But I'm not sure whether that will improve things. The generator example, the trigger for this discussion, could solve its cycle by just closing itself, after which the cycle is either broken or reconnected, but I don't know if other typical cycles could be resolved that easily. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060401/e0aa5a9a/attachment.htm From thomas at python.org Sat Apr 1 12:23:32 2006 From: thomas at python.org (Thomas Wouters) Date: Sat, 1 Apr 2006 12:23:32 +0200 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: References: Message-ID: <9e804ac0604010223n37dc60f1le1d91b5e161517a0@mail.gmail.com> On 4/1/06, Jim Jewett wrote: > Nick Coghlan > > A simple Boolean attribute (e.g. __finalized__) should be enough. ... > > If it's both present and true, the GC can ignore the finaliser on that > instance > > That doesn't really take care of resource release, which needs to be > called, and called early.(And the name will sound odd if it holds > resources only sometimes, so that it has to flip the __finalized__ > attribute.) Well, I don't want to sound too gross, but any such class could store its resources *in* __finalized__, leaving it an empty container when there is no resource to release. D'oh--not-sounding-gross-failed-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060401/4e3ae5ea/attachment.html From thomas at python.org Sat Apr 1 12:31:48 2006 From: thomas at python.org (Thomas Wouters) Date: Sat, 1 Apr 2006 12:31:48 +0200 Subject: [Python-Dev] reference leaks, __del__, and annotations In-Reply-To: <9e804ac0604010223n37dc60f1le1d91b5e161517a0@mail.gmail.com> References: <9e804ac0604010223n37dc60f1le1d91b5e161517a0@mail.gmail.com> Message-ID: <9e804ac0604010231i5b253d8cxe56be4c2f57b8d31@mail.gmail.com> On 4/1/06, Thomas Wouters wrote: > > > On 4/1/06, Jim Jewett wrote: > > > Nick Coghlan > > > A simple Boolean attribute (e.g. __finalized__) should be enough. ... > > > If it's both present and true, the GC can ignore the finaliser on that > > instance > > > > That doesn't really take care of resource release, which needs to be > > called, and called early.(And the name will sound odd if it holds > > resources only sometimes, so that it has to flip the __finalized__ > > attribute.) > > > Well, I don't want to sound too gross, but any such class could store its > resources *in* __finalized__, leaving it an empty container when there is no > resource to release. > Eh, that would mean the attribute would have to be called '__notfinalized__' of course ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060401/12b77b4d/attachment.htm From mwh at python.net Sat Apr 1 15:54:25 2006 From: mwh at python.net (Michael Hudson) Date: Sat, 01 Apr 2006 14:54:25 +0100 Subject: [Python-Dev] refleaks in 2.4 In-Reply-To: <20060327145824.GA23444@code0.codespeak.net> (Armin Rigo's message of "Mon, 27 Mar 2006 16:58:24 +0200") References: <20060327145824.GA23444@code0.codespeak.net> Message-ID: <2mfykxv1ta.fsf@starship.python.net> Armin Rigo writes: > Hi Neal, > > On Sun, Mar 26, 2006 at 11:39:50PM -0800, Neal Norwitz wrote: >> test_pkg leaked [10, 10, 10] references > > This one at least appears to be caused by dummy (deleted) entries in the > dictionary of interned strings. So it is not really a leak. It's actually because somewhere in the bowels of compilation, the file name being compiled gets interned and test_pkg writes out some temporary files and imports them. If this doesn't happen on the trunk, did this feature get lost somewhere? > It is a pain that it is so hard to figure this out, though. > Wouldn't it make sense to find a trick to exclude these dummy > entries from the total reference count? E.g. by subtracting the > refcount of the dummy object... Something like that would be nice, yes... Cheers, mwh -- GET *BONK* BACK *BONK* IN *BONK* THERE *BONK* -- Naich using the troll hammer in cam.misc From mwh at python.net Sat Apr 1 15:59:55 2006 From: mwh at python.net (Michael Hudson) Date: Sat, 01 Apr 2006 14:59:55 +0100 Subject: [Python-Dev] improving quality In-Reply-To: <7790b6530603280739y423098a1v8c83c2558f7fdd3c@mail.gmail.com> (Chris AtLee's message of "Tue, 28 Mar 2006 10:39:18 -0500") References: <7790b6530603280739y423098a1v8c83c2558f7fdd3c@mail.gmail.com> Message-ID: <2mbqvlv1k4.fsf@starship.python.net> "Chris AtLee" writes: > On 3/28/06, Neal Norwitz wrote: >> We've made a lot of improvement with testing over the years. >> Recently, we've gotten even more serious with the buildbot, Coverity, >> and coverage (http://coverage.livinglogic.de). However, in order to >> improve quality even further, we need to do a little more work. This >> is especially important with the upcoming 2.5. Python 2.5 is the most >> fundamental set of changes to Python since 2.2. If we're to make this >> release work, we need to be very careful about it. > > This reminds me of something I've been wanting to ask for a while: > does anybody run python through valgrind on a regular basis? I've > noticed that valgrind complains a lot about invalid reads in > PyObject_Free. I know that valgrind can warn about things that turn > out not to be problems, but would generating a suppresion file and > running all or part of the test suite through valgrind on the > buildbots be useful? Have you read Misc/README.valgrind? I don't know if anyone runs Python under valgrind regularly though. Cheers, mwh -- The ultimate laziness is not using Perl. That saves you so much work you wouldn't believe it if you had never tried it. -- Erik Naggum, comp.lang.lisp From arigo at tunes.org Sat Apr 1 17:33:41 2006 From: arigo at tunes.org (Armin Rigo) Date: Sat, 1 Apr 2006 17:33:41 +0200 Subject: [Python-Dev] refleaks in 2.4 In-Reply-To: <2mfykxv1ta.fsf@starship.python.net> References: <20060327145824.GA23444@code0.codespeak.net> <2mfykxv1ta.fsf@starship.python.net> Message-ID: <20060401153341.GA22522@code0.codespeak.net> Hi Michael, On Sat, Apr 01, 2006 at 02:54:25PM +0100, Michael Hudson wrote: > It's actually because somewhere in the bowels of compilation, the file > name being compiled gets interned and test_pkg writes out some > temporary files and imports them. If this doesn't happen on the > trunk, did this feature get lost somewhere? I guess it's highly non-deterministic. If the new strings happen to take a previously-dummy entry of the interned strings dict, then after they die the entry is dummy again and we don't have an extra refcount. But if they take a fresh entry, then the dummy they become afterwards counts for one ref. A bientot, Armin. From jjl at pobox.com Sat Apr 1 18:02:33 2006 From: jjl at pobox.com (John J Lee) Date: Sat, 1 Apr 2006 16:02:33 +0000 (UTC) Subject: [Python-Dev] Name for python package repository In-Reply-To: <442B36AE.4040508@canterbury.ac.nz> References: <442B36AE.4040508@canterbury.ac.nz> Message-ID: On Thu, 30 Mar 2006, Greg Ewing wrote: > I just thought of a possible name for the > Python package repository. We could call > it the PIPE - Python Index of Packages > and Extensions. +1 John From jeremy at alum.mit.edu Sat Apr 1 19:17:27 2006 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Sat, 1 Apr 2006 12:17:27 -0500 Subject: [Python-Dev] line numbers, pass statements, implicit returns Message-ID: There are several test cases in test_trace that are commented out. We did this when we merged the ast-branch and promised to come back to them. I'm coming back to them now, but the test aren't documented well and the feature they test isn't specified well. The failing tests I've looked at so far involving pass statements and implicit "return None" statements generated by the compiler. The tests seem to verify that 1) if you have a function that ends with an if/else where the body of the else is pass, there is no line number associated with the return 2) if you have a function that ends with a try/except where the body of the except is pass, there is a line number associated with the return. Here's a failing example def ireturn_example(): a = 5 b = 5 if a == b: b = a+1 else: pass The code is traced and test_trace verifies that the return is associated with line 4! In these cases, the ast compiler will always associate a line number with the return. (Technically with the LOAD_CONST preceding the RETURN_VALUE.) This happens pretty much be accident. It always associates a line number with the first opcode generated after a new statement is visited. Since a Pass statement node has no opcode, the return generates the first opcode. Now I could add some special cases to the compiler to preserve the old behavior, the question is: Why bother? It's such an unlikely case (an else that has no effect). Does anyone depend on the current behavior for the ireturn_example()? It seems sensible to me to always generate a line number for the pass + return case, just so you see the control flow as you step through the debugger. The other case that has changed is that the new compiler does not generate code for "while 0:" I don't remember why <0.5 wink>. There are several test cases that verify line numbers for code using this kind of bogus construct. There are no lines anymore, so I would change the tests so that they don't expect the lines in question. But I have no idea what they are trying to test. Does anyone know? Jeremy From tjreedy at udel.edu Sat Apr 1 21:28:45 2006 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 1 Apr 2006 14:28:45 -0500 Subject: [Python-Dev] gmane.comp.python.devel.3000 has disappeared References: <17453.46094.197153.725065@montanaro.dyndns.org> <4c45c1530604010119j377a80e2xdc0dd8cf64cfaff5@mail.gmail.com> Message-ID: > Yes Gmane is subscribed. > I checked if there is a pydev-3000 newsgroup on there server. I found the renamed group. Prefered the original name since it sorted just after this one in the subscribed groups list. tjr From nnorwitz at gmail.com Sat Apr 1 22:23:09 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 1 Apr 2006 12:23:09 -0800 Subject: [Python-Dev] improving quality In-Reply-To: <2mbqvlv1k4.fsf@starship.python.net> References: <7790b6530603280739y423098a1v8c83c2558f7fdd3c@mail.gmail.com> <2mbqvlv1k4.fsf@starship.python.net> Message-ID: On 4/1/06, Michael Hudson wrote: > > I don't know if anyone runs Python under valgrind regularly though. I do for some definition of "regularly". It would be better to setup a cron job to truly run it regularly, perhaps once a month. It should run on both HEAD and supported release(s) (ie, 2.4 currently). I've heard of others using valgrind, I have no idea how many people and how often though. n From noamraph at gmail.com Sat Apr 1 22:32:19 2006 From: noamraph at gmail.com (Noam Raphael) Date: Sat, 1 Apr 2006 23:32:19 +0300 Subject: [Python-Dev] Saving the hash value of tuples Message-ID: Hello, I've found out that the hash value of tuples isn't saved after it's calculated. With strings it's different: the hash value of a string is calculated only on the first call to hash(string), and saved in the structure for future use. Saving the value makes dict lookup of tuples an operation with an amortized cost of O(1). Saving the hash value means that if an item of the tuple changes its hash value, the hash value of the tuple won't be changed. I think it's ok, since: 1. Hash value of things shouldn't change. 2. Dicts assume that too. I tried the change, and it turned out that I had to change cPickle a tiny bit: it uses a 2-tuple which is allocated when the module initializes to lookup tuples in a dict. I changed it to properly use PyTuple_New and Py_DECREF, and now the complete test suite passes. I run test_cpickle before the change and after it, and it took the same time (0.89 seconds on my computer). What do you think? I see three possibilities: 1. Nothing should be done, everything is as it should be. 2. The cPickle module should be changed to not abuse the tuple, but there's no reason to add an extra word to the tuple structure and break binary backwards compatibility. 3. Both should be changed. I will be happy to send a patch, if someone shows interest. Have a good day, Noam From aahz at pythoncraft.com Sat Apr 1 22:37:01 2006 From: aahz at pythoncraft.com (Aahz) Date: Sat, 1 Apr 2006 12:37:01 -0800 Subject: [Python-Dev] Saving the hash value of tuples In-Reply-To: References: Message-ID: <20060401203701.GB13210@panix.com> On Sat, Apr 01, 2006, Noam Raphael wrote: > > I've found out that the hash value of tuples isn't saved after it's > calculated. With strings it's different: the hash value of a string is > calculated only on the first call to hash(string), and saved in the > structure for future use. Saving the value makes dict lookup of tuples > an operation with an amortized cost of O(1). > [...] > I will be happy to send a patch, if someone shows interest. Regardless of whether anyone shows interest, please submit a patch! Then post the URL back here. That way if someone gets interested in the future, your code is still available. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Look, it's your affair if you want to play with five people, but don't go calling it doubles." --John Cleese anticipates Usenet From noamraph at gmail.com Sat Apr 1 23:01:44 2006 From: noamraph at gmail.com (Noam Raphael) Date: Sun, 2 Apr 2006 00:01:44 +0300 Subject: [Python-Dev] Saving the hash value of tuples In-Reply-To: <20060401203701.GB13210@panix.com> References: <20060401203701.GB13210@panix.com> Message-ID: Ok, I uploaded it. Patch no. 1462796: https://sourceforge.net/tracker/index.php?func=detail&aid=1462796&group_id=5470&atid=305470 On 4/1/06, Aahz wrote: > On Sat, Apr 01, 2006, Noam Raphael wrote: > > > > I've found out that the hash value of tuples isn't saved after it's > > calculated. With strings it's different: the hash value of a string is > > calculated only on the first call to hash(string), and saved in the > > structure for future use. Saving the value makes dict lookup of tuples > > an operation with an amortized cost of O(1). > > [...] > > I will be happy to send a patch, if someone shows interest. > > Regardless of whether anyone shows interest, please submit a patch! Then > post the URL back here. That way if someone gets interested in the > future, your code is still available. > -- > Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ > > "Look, it's your affair if you want to play with five people, but don't > go calling it doubles." --John Cleese anticipates Usenet > From tim.peters at gmail.com Sun Apr 2 00:43:41 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sat, 1 Apr 2006 17:43:41 -0500 Subject: [Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py In-Reply-To: <20060401204023.804801E4006@bag.python.org> References: <20060401204023.804801E4006@bag.python.org> Message-ID: <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> > Author: walter.doerwald > Date: Sat Apr 1 22:40:23 2006 > New Revision: 43545 > > Modified: > python/trunk/Doc/lib/libcalendar.tex > python/trunk/Lib/calendar.py > Log: > Make firstweekday a simple attribute instead > of hiding it behind a setter and a getter. Walter, what's the purpose of this patch? The first weekday is still an attribute, but instead of being settable and gettable via methods, looks like it's now settable and gettable via module-global functions, and only for the single default instance of Calendar created by the module. If so, then (a) the functionality of the Calendar class is weaker now, and in a backward-incompatible way; and, (b) the new module-global firstweekday() and setfirstweekday() functions are a more obscure way to restore the lost functionality for just one specific instance of a Calendar subclass. I don't see the attraction to any part of this. > --- python/trunk/Lib/calendar.py (original) > +++ python/trunk/Lib/calendar.py Sat Apr 1 22:40:23 2006 > @@ -128,25 +128,14 @@ > """ > > def __init__(self, firstweekday=0): > - self._firstweekday = firstweekday # 0 = Monday, 6 = Sunday > - > - def firstweekday(self): > - return self._firstweekday > - > - def setfirstweekday(self, weekday): > - """ > - Set weekday (Monday=0, Sunday=6) to start each week. > - """ > - if not MONDAY <= weekday <= SUNDAY: > - raise IllegalWeekdayError(weekday) > - self._firstweekday = weekday > + self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday Removing those Calendar methods is backward-incompatible, ... > -firstweekday = c.firstweekday > -setfirstweekday = c.setfirstweekday > +def firstweekday(): > + return c.firstweekday > + > +def setfirstweekday(firstweekday): > + if not MONDAY <= firstweekday <= SUNDAY: > + raise IllegalWeekdayError(firstweekday) > + c.firstweekday = firstweekday > + > monthcalendar = c.monthdayscalendar > prweek = c.prweek And here they're obscurely added back again, but work only for the module-global default instance `c` of the TextCalendar subclass. From brett at python.org Sun Apr 2 01:22:22 2006 From: brett at python.org (Brett Cannon) Date: Sat, 1 Apr 2006 15:22:22 -0800 Subject: [Python-Dev] PEP to list externally maintained modules and where to report bugs? Message-ID: I reported some warnings I was getting for ctypes the other day and Martin said I should report it to ctypes. I now get a warning for sqlite on OS X 10.4 about INT32_MIN being redefined (I have stdint.h on my machine and that macro is being redefined in Modules/_sqlite/cursor.c instead of using the C99 version). Anyone else think we need a PEP to point to places where externally maintained code should have bugs or patches reported? I don't want to hunt down a URL for where to do this every time and so it would be nice to have a list of what code needs bugs/patches reported where. Otherwise I am prone to just check my changes into the tree and not get them reported upstream since I want the warnings to go away. =) -Brett From brett at python.org Sun Apr 2 01:43:10 2006 From: brett at python.org (Brett Cannon) Date: Sat, 1 Apr 2006 15:43:10 -0800 Subject: [Python-Dev] PY_FORMAT_SIZE_T warnings on OS X Message-ID: I think these are all Tim's fault =) : Objects/object.c: In function '_Py_NegativeRefcount': Objects/object.c:144: warning: format '%d' expects type 'int', but argument 7 has type 'Py_ssize_t' Objects/stringobject.c: In function 'PyString_FromFormatV': Objects/stringobject.c:278: warning: format '%u' expects type 'unsigned int', but argument 3 has type 'size_t' Python/pythonrun.c: In function 'Py_Finalize': Python/pythonrun.c:393: warning: format '%d' expects type 'int', but argument 3 has type 'Py_ssize_t' Python/pythonrun.c: In function 'PyRun_InteractiveLoopFlags': Python/pythonrun.c:683: warning: format '%d' expects type 'int', but argument 3 has type 'Py_ssize_t' Modules/gcmodule.c: In function 'collect': Modules/gcmodule.c:746: warning: format '%d' expects type 'int', but argument 2 has type 'Py_ssize_t' Modules/gcmodule.c:841: warning: format '%d' expects type 'int', but argument 2 has type 'Py_ssize_t' Modules/gcmodule.c:841: warning: format '%d' expects type 'int', but argument 3 has type 'Py_ssize_t' What's odd about them is that that the use of PY_FORMAT_SIZE_T seems to be correct, so I don't know what the problem is. Unfortunately ``gcc -E Include/pyport.h`` is no help since PY_FORMAT_SIZE_T is not showing up defined (possibly because gcc says it can't find pyconfig.h). -Brett From tim.peters at gmail.com Sun Apr 2 01:59:16 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sat, 1 Apr 2006 18:59:16 -0500 Subject: [Python-Dev] PY_FORMAT_SIZE_T warnings on OS X In-Reply-To: References: Message-ID: <1f7befae0604011559j19b25c20v4415ce15ede88082@mail.gmail.com> [Brett Cannon] > I think these are all Tim's fault =) : No, they're Anthony's fault :-) He added this clause to pyport.h yesterday: # if SIZEOF_SIZE_T == SIZEOF_INT # define PY_FORMAT_SIZE_T "" and that's obviously triggering on your platform. He added this (at my suggestion) to shut up similar gcc warnings on some other box. Before he added it, PY_FORMAT_SIZE_T was "l" on that box (and on yours) If it had remained "l", you wouldn't be getting warnings now, but he still would. On his box, the gripes where about passing a size_t argument to a "%lu" format, but size_t resolved to unsigned int, not to unsigned long. sizeof(int) == sizeof(long) on that box (and on yours), so the warning isn't really helpful. > Objects/object.c: In function '_Py_NegativeRefcount': > Objects/object.c:144: warning: format '%d' expects type 'int', but > argument 7 has type 'Py_ssize_t' And I bet (you should check) that Py_ssize_t resolves to "long" on your box, and that sizeof(long) == sizeof(int) on your box, so that again the warning is just a damned nuisance. > ... [similar complaints] ... > What's odd about them is that that the use of PY_FORMAT_SIZE_T seems > to be correct, so I don't know what the problem is. My best guess is above. gcc appears to be generating type complaints based on "name equivalence" rather than "structure equivalence" here (meaning it's comparing integer types by the names they resolve to rather than to the combination of size and signedness regardless of name). Worming around that would probably require a bunch of poke-and-hope experimenting with various gcc's, of which I have none :-) > Unfortunately ``gcc -E Include/pyport.h`` is no help since PY_FORMAT_SIZE_T > is not showing up defined (possibly because gcc says it can't find pyconfig.h). You can run on it this part in isolation: #ifndef PY_FORMAT_SIZE_T # if SIZEOF_SIZE_T == SIZEOF_INT # define PY_FORMAT_SIZE_T "" # elif SIZEOF_SIZE_T == SIZEOF_LONG # define PY_FORMAT_SIZE_T "l" # elif defined(MS_WINDOWS) # define PY_FORMAT_SIZE_T "I" # else # error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" # endif #endif after sticking on the right expansions for the SIZEOF_xyz thingies -- but it's clear enough from the error messages that the SIZEOF_INT branch is triggering (it's complaining about format '%d', not format '%ld' or format '%Id'). From brett at python.org Sun Apr 2 02:40:56 2006 From: brett at python.org (Brett Cannon) Date: Sat, 1 Apr 2006 16:40:56 -0800 Subject: [Python-Dev] PY_FORMAT_SIZE_T warnings on OS X In-Reply-To: <1f7befae0604011559j19b25c20v4415ce15ede88082@mail.gmail.com> References: <1f7befae0604011559j19b25c20v4415ce15ede88082@mail.gmail.com> Message-ID: On 4/1/06, Tim Peters wrote: > [Brett Cannon] > > I think these are all Tim's fault =) : > > No, they're Anthony's fault :-) He added this clause to pyport.h yesterday: > > # if SIZEOF_SIZE_T == SIZEOF_INT > # define PY_FORMAT_SIZE_T "" > > and that's obviously triggering on your platform. He added this (at > my suggestion) to shut up similar gcc warnings on some other box. > Before he added it, PY_FORMAT_SIZE_T was "l" on that box (and on > yours) If it had remained "l", you wouldn't be getting warnings now, > but he still would. > Great, so either Anthony gets warnings or I do. > On his box, the gripes where about passing a size_t argument to a > "%lu" format, but size_t resolved to unsigned int, not to unsigned > long. sizeof(int) == sizeof(long) on that box (and on yours), so the > warning isn't really helpful. > Well that figures. > > Objects/object.c: In function '_Py_NegativeRefcount': > > Objects/object.c:144: warning: format '%d' expects type 'int', but > > argument 7 has type 'Py_ssize_t' > > And I bet (you should check) that Py_ssize_t resolves to "long" on > your box, and that sizeof(long) == sizeof(int) on your box, so that > again the warning is just a damned nuisance. > > > ... [similar complaints] ... > > > What's odd about them is that that the use of PY_FORMAT_SIZE_T seems > > to be correct, so I don't know what the problem is. > > My best guess is above. gcc appears to be generating type complaints > based on "name equivalence" rather than "structure equivalence" here > (meaning it's comparing integer types by the names they resolve to > rather than to the combination of size and signedness regardless of > name). Worming around that would probably require a bunch of > poke-and-hope experimenting with various gcc's, of which I have none > :-) This is just so ridiculous. Is there even a way to do this reasonably? Would we have to detect when Py_ssize_t resolves to either int or long and when the size of both is the same force to the same name on all platforms? > > > Unfortunately ``gcc -E Include/pyport.h`` is no help since PY_FORMAT_SIZE_T > > is not showing up defined (possibly because gcc says it can't find pyconfig.h). > > You can run on it this part in isolation: > > #ifndef PY_FORMAT_SIZE_T > # if SIZEOF_SIZE_T == SIZEOF_INT > # define PY_FORMAT_SIZE_T "" > # elif SIZEOF_SIZE_T == SIZEOF_LONG > # define PY_FORMAT_SIZE_T "l" > # elif defined(MS_WINDOWS) > # define PY_FORMAT_SIZE_T "I" > # else > # error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" > # endif > #endif > > after sticking on the right expansions for the SIZEOF_xyz thingies -- > but it's clear enough from the error messages that the SIZEOF_INT > branch is triggering (it's complaining about format '%d', not format > '%ld' or format '%Id'). > OK, so how should we solve this one? Or should we just ignore it and hope gcc eventually wises up and starting using structural equivalence for its printf checks? =) -Brett From tim.peters at gmail.com Sun Apr 2 03:22:24 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sat, 1 Apr 2006 20:22:24 -0500 Subject: [Python-Dev] PY_FORMAT_SIZE_T warnings on OS X In-Reply-To: References: <1f7befae0604011559j19b25c20v4415ce15ede88082@mail.gmail.com> Message-ID: <1f7befae0604011722h639182a1s25472d0e8961b7a8@mail.gmail.com> [Brett Cannon] > ... > This is just so ridiculous. Ya think ;-)? > Is there even a way to do this reasonably? Not really in C89. That's why C99 introduced the "z" printf modifier, and approximately a billion ;-) format macros like PY_FORMAT_SIZE_T (since there's almost nothing portably useful you can say about standard C's billion names for "some kind of integer"). In effect, the PY_FORMAT_SIZE_T case was important enough that C99 moved it directly into the printf format syntax. > Would we have to detect when Py_ssize_t resolves to either int or long It's worse that that: there's no guarantee that sizeof(Py_ssize_t) <= sizeof(long), and it fact it's not on Win64. But Windows is already taken care of here. > OK, so how should we solve this one? Or should we just ignore it and > hope gcc eventually wises up and starting using structural equivalence > for its printf checks? =) For gcc we _could_ solve it in the obvious way, which I guess Martin was hoping to avoid: change Unixish config to detect whether the platform C supports the "z" format modifier (I believe gcc does), and if so arrange to stick #define PY_FORMAT_SIZE_T "z" in the generated pyconfig.h. Note that if pyconfig.h defines PY_FORMAT_SIZE_T, pyport.h believes whatever that says. It's the purpose of "z" to format size_t-ish arguments, so gcc complaints should end then. From brett at python.org Sun Apr 2 03:26:38 2006 From: brett at python.org (Brett Cannon) Date: Sat, 1 Apr 2006 17:26:38 -0800 Subject: [Python-Dev] PY_FORMAT_SIZE_T warnings on OS X In-Reply-To: <1f7befae0604011722h639182a1s25472d0e8961b7a8@mail.gmail.com> References: <1f7befae0604011559j19b25c20v4415ce15ede88082@mail.gmail.com> <1f7befae0604011722h639182a1s25472d0e8961b7a8@mail.gmail.com> Message-ID: On 4/1/06, Tim Peters wrote: > [Brett Cannon] > > ... > > This is just so ridiculous. > > Ya think ;-)? > > > Is there even a way to do this reasonably? > > Not really in C89. That's why C99 introduced the "z" printf modifier, > and approximately a billion ;-) format macros like PY_FORMAT_SIZE_T > (since there's almost nothing portably useful you can say about > standard C's billion names for "some kind of integer"). In effect, > the PY_FORMAT_SIZE_T case was important enough that C99 moved it > directly into the printf format syntax. > > > Would we have to detect when Py_ssize_t resolves to either int or long > > It's worse that that: there's no guarantee that sizeof(Py_ssize_t) <= > sizeof(long), and it fact it's not on Win64. But Windows is already > taken care of here. > > > OK, so how should we solve this one? Or should we just ignore it and > > hope gcc eventually wises up and starting using structural equivalence > > for its printf checks? =) > > For gcc we _could_ solve it in the obvious way, which I guess Martin > was hoping to avoid: change Unixish config to detect whether the > platform C supports the "z" format modifier (I believe gcc does), and > if so arrange to stick > > #define PY_FORMAT_SIZE_T "z" > > in the generated pyconfig.h. Note that if pyconfig.h defines > PY_FORMAT_SIZE_T, pyport.h believes whatever that says. It's the > purpose of "z" to format size_t-ish arguments, so gcc complaints > should end then. > I vote we move to C99. =) If that doesn't happen, I guess the above solution is the best. I am probably not the best person to tweak the Makefile for this, but I can if no one gets to it. -Brett From anthony at interlink.com.au Sun Apr 2 06:17:30 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Sun, 2 Apr 2006 15:17:30 +1100 Subject: [Python-Dev] Firefox searchbar engine for Python bugs Message-ID: <200604021417.33521.anthony@interlink.com.au> I've created a searchbar plugin for the firefox search bar that allows you to search bugs. I think someone created one for the sidebar, but this works in the searchbar at the top of the window. I gave up trying to knit the files into the new website builder, and so it can be found here: http://www.python.org/~anthony/searchbar/ If you can think of other useful searchbar plugins (Python Docs, maybe?) let me know and I'll look at creating them. Anthony -- Anthony Baxter It's never too late to have a happy childhood. From anthony at interlink.com.au Sun Apr 2 06:23:39 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Sun, 2 Apr 2006 15:23:39 +1100 Subject: [Python-Dev] Firefox searchbar engine for Python bugs In-Reply-To: <200604021417.33521.anthony@interlink.com.au> References: <200604021417.33521.anthony@interlink.com.au> Message-ID: <200604021423.41185.anthony@interlink.com.au> On Sunday 02 April 2006 14:17, Anthony Baxter wrote: > I've created a searchbar plugin for the firefox search bar that > allows you to search bugs. I should clarify - it allows you to pull up a bug by bug ID, using the www.python.org/sf/ redirector. From guido at python.org Sun Apr 2 08:18:17 2006 From: guido at python.org (Guido van Rossum) Date: Sat, 1 Apr 2006 22:18:17 -0800 Subject: [Python-Dev] line numbers, pass statements, implicit returns In-Reply-To: References: Message-ID: On 4/1/06, Jeremy Hylton wrote: > There are several test cases in test_trace that are commented out. We > did this when we merged the ast-branch and promised to come back to > them. I'm coming back to them now, but the test aren't documented > well and the feature they test isn't specified well. > > The failing tests I've looked at so far involving pass statements and > implicit "return None" statements generated by the compiler. The > tests seem to verify that > > 1) if you have a function that ends with an if/else where the body > of the else is pass, > there is no line number associated with the return > 2) if you have a function that ends with a try/except where the > body of the except is pass, > there is a line number associated with the return. > > Here's a failing example > > def ireturn_example(): > a = 5 > b = 5 > if a == b: > b = a+1 > else: > pass > > The code is traced and test_trace verifies that the return is > associated with line 4! > > In these cases, the ast compiler will always associate a line number > with the return. (Technically with the LOAD_CONST preceding the > RETURN_VALUE.) This happens pretty much be accident. It always > associates a line number with the first opcode generated after a new > statement is visited. Since a Pass statement node has no opcode, the > return generates the first opcode. > > Now I could add some special cases to the compiler to preserve the old > behavior, the question is: Why bother? It's such an unlikely case (an > else that has no effect). Does anyone depend on the current behavior > for the ireturn_example()? It seems sensible to me to always generate > a line number for the pass + return case, just so you see the control > flow as you step through the debugger. Makes sense to me. I can't imagine what this was testing except perhaps a corner case in the algorithm for generating the (insanely complicated) linenumber mapping table. > The other case that has changed is that the new compiler does not > generate code for "while 0:" I don't remember why <0.5 wink>. There > are several test cases that verify line numbers for code using this > kind of bogus construct. There are no lines anymore, so I would > change the tests so that they don't expect the lines in question. But > I have no idea what they are trying to test. Does anyone know? Not me. This is definitely not part of the language spec! :-) -- --Guido van Rossum (home page: http://www.python.org/~guido/) From martin at v.loewis.de Sun Apr 2 08:29:36 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 02 Apr 2006 08:29:36 +0200 Subject: [Python-Dev] PY_FORMAT_SIZE_T warnings on OS X In-Reply-To: <1f7befae0604011722h639182a1s25472d0e8961b7a8@mail.gmail.com> References: <1f7befae0604011559j19b25c20v4415ce15ede88082@mail.gmail.com> <1f7befae0604011722h639182a1s25472d0e8961b7a8@mail.gmail.com> Message-ID: <442F6F50.2030002@v.loewis.de> Tim Peters wrote: > For gcc we _could_ solve it in the obvious way, which I guess Martin > was hoping to avoid: change Unixish config to detect whether the > platform C supports the "z" format modifier (I believe gcc does), and > if so arrange to stick > > #define PY_FORMAT_SIZE_T "z" It's not gcc to support "z" (except for the compile-time check); it's the C library (on Unix, the C library is part of the system, not part of the compiler). But yes: if we could detect in configure that the C library supports %zd, then we should use that. Regards, Martin From g.brandl at gmx.net Sun Apr 2 08:49:08 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Sun, 02 Apr 2006 08:49:08 +0200 Subject: [Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py In-Reply-To: <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> References: <20060401204023.804801E4006@bag.python.org> <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> Message-ID: Tim Peters wrote: >> Author: walter.doerwald >> Date: Sat Apr 1 22:40:23 2006 >> New Revision: 43545 >> >> Modified: >> python/trunk/Doc/lib/libcalendar.tex >> python/trunk/Lib/calendar.py >> Log: >> Make firstweekday a simple attribute instead >> of hiding it behind a setter and a getter. > > Walter, what's the purpose of this patch? The first weekday is still > an attribute, but instead of being settable and gettable via methods, > looks like it's now settable and gettable via module-global functions, > and only for the single default instance of Calendar created by the > module. If so, then (a) the functionality of the Calendar class is > weaker now, and in a backward-incompatible way; and, (b) the new > module-global firstweekday() and setfirstweekday() functions are a > more obscure way to restore the lost functionality for just one > specific instance of a Calendar subclass. > > I don't see the attraction to any part of this. > >> --- python/trunk/Lib/calendar.py (original) >> +++ python/trunk/Lib/calendar.py Sat Apr 1 22:40:23 2006 >> @@ -128,25 +128,14 @@ >> """ >> >> def __init__(self, firstweekday=0): >> - self._firstweekday = firstweekday # 0 = Monday, 6 = Sunday >> - >> - def firstweekday(self): >> - return self._firstweekday >> - >> - def setfirstweekday(self, weekday): >> - """ >> - Set weekday (Monday=0, Sunday=6) to start each week. >> - """ >> - if not MONDAY <= weekday <= SUNDAY: >> - raise IllegalWeekdayError(weekday) >> - self._firstweekday = weekday >> + self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday > > Removing those Calendar methods is backward-incompatible, Isn't it that the Calendar class was just added and therefore is new to 2.5? >> -firstweekday = c.firstweekday >> -setfirstweekday = c.setfirstweekday >> +def firstweekday(): >> + return c.firstweekday >> + >> +def setfirstweekday(firstweekday): >> + if not MONDAY <= firstweekday <= SUNDAY: >> + raise IllegalWeekdayError(firstweekday) >> + c.firstweekday = firstweekday >> + >> monthcalendar = c.monthdayscalendar >> prweek = c.prweek > > And here they're obscurely added back again, but work only for the > module-global default instance `c` of the TextCalendar subclass. Since the functions are part of the traditional calendar API which cannot be broken. Georg From fredrik at pythonware.com Sun Apr 2 10:06:02 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 2 Apr 2006 10:06:02 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigned a bug/patch References: <9e804ac0603271427p332b5a9cid84380b44aca1a33@mail.gmail.com> <00ff01c6523f$7c583290$bf03030a@trilan> <1143554576.2310.161.camel@geddy.wooz.org> <17449.21764.475497.457592@montanaro.dyndns.org> <44298954.4040705@v.loewis.de> <442DB437.6070108@v.loewis.de> Message-ID: Martin v. Löwis wrote: > That isn't actually worth that much: somebody would need to operate it, > too. Mere existence doesn't help. why do you keep repeating this when I've already posted a link to a company that does this for only a few bucks per month ? From walter at livinglogic.de Sun Apr 2 10:24:04 2006 From: walter at livinglogic.de (=?iso-8859-1?Q?Walter_D=F6rwald?=) Date: Sun, 2 Apr 2006 10:24:04 +0200 (CEST) Subject: [Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py In-Reply-To: <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> References: <20060401204023.804801E4006@bag.python.org> <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> Message-ID: <61055.89.54.32.106.1143966244.squirrel@isar.livinglogic.de> Tim Peters wrote: >> Author: walter.doerwald >> Date: Sat Apr 1 22:40:23 2006 >> New Revision: 43545 >> >> Modified: >> python/trunk/Doc/lib/libcalendar.tex >> python/trunk/Lib/calendar.py >> Log: >> Make firstweekday a simple attribute instead >> of hiding it behind a setter and a getter. > > Walter, what's the purpose of this patch? The first weekday is still an attribute, but instead of being settable and > gettable via methods, looks like it's now settable and gettable via module-global functions, and only for the single default > instance of Calendar created by the module. This is because in 2.4 there where no Calendar objects and firstweekday was only setable and getable via module level functions. > If so, then (a) the functionality of the Calendar class is weaker now, No really. firstweekday is changeable simply by assigning to the attribute: import calendar cal = calendar.Calendar() cal.firstweekday = 6 The only thing lost is the range check in the setter. > and in a > backward-incompatible way; Yes, this change is backwards-incompatible, but imcompatible to code that has been in the repository since Friday, so this shouldn't be a problem! ;) > and, > (b) the new > module-global firstweekday() and setfirstweekday() functions are a more obscure way to restore the lost functionality for > just one > specific instance of a Calendar subclass. That's because in 2.4 the module level interface was all there was. > I don't see the attraction to any part of this. Simple attribute access looks much more Pythonic to me than setters and gettes (especially as the attributes of subclasses are simple attributes). Or are you talking about the Calendar class itself? > [...] Bye, Walter D?rwald From ncoghlan at gmail.com Sun Apr 2 12:21:14 2006 From: ncoghlan at gmail.com (Nick Coghlan) Date: Sun, 02 Apr 2006 20:21:14 +1000 Subject: [Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py In-Reply-To: <61055.89.54.32.106.1143966244.squirrel@isar.livinglogic.de> References: <20060401204023.804801E4006@bag.python.org> <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> <61055.89.54.32.106.1143966244.squirrel@isar.livinglogic.de> Message-ID: <442FA59A.9000005@gmail.com> Walter D?rwald wrote: > firstweekday is changeable simply by assigning to the attribute: > > import calendar > cal = calendar.Calendar() > cal.firstweekday = 6 > > The only thing lost is the range check in the setter. Any particular reason for not making it a property? Then you could keep the range check while still manipulating it as if it was a simple attribute. Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From martin at v.loewis.de Sun Apr 2 14:58:58 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 02 Apr 2006 14:58:58 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigned a bug/patch In-Reply-To: References: <9e804ac0603271427p332b5a9cid84380b44aca1a33@mail.gmail.com> <00ff01c6523f$7c583290$bf03030a@trilan> <1143554576.2310.161.camel@geddy.wooz.org> <17449.21764.475497.457592@montanaro.dyndns.org> <44298954.4040705@v.loewis.de> <442DB437.6070108@v.loewis.de> Message-ID: <442FCA92.1020707@v.loewis.de> Fredrik Lundh wrote: >> That isn't actually worth that much: somebody would need to operate it, >> too. Mere existence doesn't help. > > why do you keep repeating this when I've already posted a link to a > company that does this for only a few bucks per month ? Because they don't do that. They won't import the Python SF data on their own: somebody has to tell them. Even then, they won't do that: somebody has to provide them with the data (if for no other reason that SF gives access only to project admins). If you are (still) talking about python-hosting.com: where on their website do they say that they will import SF data into trac when asked to? In short: somebody has to take charge, and make sure the thing is available. Maybe it is as simple as filing a support request, but somebody *still* has to do that (or else they won't guess that something is broken). I haven't heard anybody volunteering to do this specific job, working with this specific company. I don't volunteer to do that (I work with SF on issues with their tracker, but only because nobody else does, and because I believe these things need to be done). My impression of of python-hosting is that they provide the machine, and the initial setup. Then you are mostly on your own. Regards, Martin From pj at place.org Sat Apr 1 15:48:13 2006 From: pj at place.org (Paul Jimenez) Date: Sat, 01 Apr 2006 07:48:13 -0600 Subject: [Python-Dev] New uriparse.py Message-ID: <20060401134813.721B082CA@place.org> Announcing uriparse.py, submitted for inclusion in the standard library. Patch request 1462525. Per the original discussion at http://mail.python.org/pipermail/python-dev/2005-November/058301.html I'm submitting a library meant to deprecate the existing urlparse library. Questions and comments welcome. --pj From p.f.moore at gmail.com Sun Apr 2 16:15:04 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 2 Apr 2006 15:15:04 +0100 Subject: [Python-Dev] Firefox searchbar engine for Python bugs In-Reply-To: <200604021423.41185.anthony@interlink.com.au> References: <200604021417.33521.anthony@interlink.com.au> <200604021423.41185.anthony@interlink.com.au> Message-ID: <79990c6b0604020715w34651995h28d5e4ec1c0fac8e@mail.gmail.com> On 4/2/06, Anthony Baxter wrote: > On Sunday 02 April 2006 14:17, Anthony Baxter wrote: > > I've created a searchbar plugin for the firefox search bar that > > allows you to search bugs. > > I should clarify - it allows you to pull up a bug by bug ID, using the > www.python.org/sf/ redirector. I just use a "Quick Search" item, keyword pysf, URL http://www.python.org/sf. I also have one with keyword "pep" and URL javascript:window.location=%22http://www.python.org/peps/pep-%22+%220000%s%22.slice(-4)+%22.html%22 (the latter is a bit more fiddly to automatically pad a number to 4 digits, so I can write "pep 1" for example). Paul. From fredrik at pythonware.com Sun Apr 2 17:01:51 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 2 Apr 2006 17:01:51 +0200 Subject: [Python-Dev] I'm not getting email from SF when assignedabug/patch References: <1143648409.10799.159.camel@resist.wooz.org> <442C11E2.6050106@v.loewis.de> <442C1C7E.4050502@v.loewis.de> Message-ID: Brett Cannon wrote: > > oh, I forgot that the Procrastination & Stop energy Foundation was involved > > in this. > Fredrik, if you would like to help move this all forward, great; I > would appreciate the help. You can write a page scraper to get the > data out of SF if you don't believe SF will cooperate fast enough for > your tastes or I am giving them too long to try to fix things on their > end (I don't expect they will fix things fast enough either, but > because of school ending soon I don't have time right now to start > working on a scraper myself plus I am willing to give them a little > time to try to fix the XML export so we can minimize headaches on our > end). here > > If you would rather contribute by collecting a list of possible > trackers along with who will maintain it, then please do. I am not > going to dive into that quite yet, but if you want to parallelize the > work needed then I would appreciate the help. The tracker will need > to be able to import the SF data somehow (probably will require a > custom tool so the volunteers need to be aware of this), be able to > export data (so we can back it up on a regular basis so we don't have > to go through this again), and an email interface for at least > replying to tracker items. A community-wide announcement will > probably be needed to get a good group of volunteers together for any > one non-commercial tracker. > > But I am not procrastinating. I don't think I have ever come off as a > procrastinator on this list and I don't think I deserve the label. I > am not putting more time in now because I am near the end of term here > at school and thus passing my courses takes precendent over a new bug > tracker. I ended up the chairman at the infrastructure committee > during one of my busiest school terms I have ever had. But I will see > this through and it will be done in a timely manner. > > -Brett > _______________________________________________ > 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/python-python-dev%40m.gmane.org > From fredrik at pythonware.com Sun Apr 2 17:31:15 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 2 Apr 2006 17:31:15 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigned a bug/patch References: <1143648409.10799.159.camel@resist.wooz.org> <442C11E2.6050106@v.loewis.de> <442C1C7E.4050502@v.loewis.de> Message-ID: Brett Cannon wrote: > > oh, I forgot that the Procrastination & Stop energy Foundation was involved > > in this. > > Fredrik, if you would like to help move this all forward, great; I > would appreciate the help. You can write a page scraper to get the > data out of SF challenge accepted ;-) http://effbot.python-hosting.com/browser/stuff/sandbox/sourceforge/ contains three basic tools; getindex to grab index information from a python tracker, getpages to get "raw" xhtml versions of the item pages, and getfiles to get attached files. I'm currently downloading a tracker snapshot that could be useful for testing; it'll take a few more hours before all data are downloaded (provided that SF doesn't ban me, and I don't stumble upon more cases where a certain rhettinger has pasted binary gunk into an iso-8859-1 form ;-). $ python status.py tracker-105470 6681 items 1201 pages (17%) 104 files tracker-305470 3610 items 0 pages (0%) 0 files tracker-355470 430 items 430 pages (100%) 80 files the final step is to finish the "off-line scraper" library (a straightfor- ward ET hack), and make a snapshot archive available to interested parties. (drop me a line if you want a copy) > If you would rather contribute by collecting a list of possible > trackers along with who will maintain it, then please do. I am not > going to dive into that quite yet, but if you want to parallelize the > work needed then I would appreciate the help. that is what I expected the PSF infrastructure committee to do (I hope you're not the only one in that committee?); it's a bit disappointing to hear that we're still stuck on the SF export issue. (wasn't there someone with backchannel access to the SF data ?) > The tracker will need to be able to import the SF data somehow (probably will require a > custom tool so the volunteers need to be aware of this), be able to > export data (so we can back it up on a regular basis so we don't have > to go through this again), and an email interface for at least > replying to tracker items. A community-wide announcement will > probably be needed to get a good group of volunteers together for any > one non-commercial tracker. > But I am not procrastinating. I don't think I have ever come off as a > procrastinator on this list and I don't think I deserve the label. I wasn't talking about individuals, I was referring to the trend where PSF moves something off a public forum, and the work just ends up going nowhere. From fredrik at pythonware.com Sun Apr 2 17:49:42 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 2 Apr 2006 17:49:42 +0200 Subject: [Python-Dev] Bug Day on Friday, 31st of March References: Message-ID: Georg Brandl wrote: > it's time for the 7th Python Bug Day. The aim of the bug day is to close > as many bugs, patches and feature requests as possible, this time with a > special focus on new features that can still go into the upcoming 2.5 alpha > release. so, how did it go? a status report / summary would be nice, I think ? From martin at v.loewis.de Sun Apr 2 19:02:30 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 02 Apr 2006 19:02:30 +0200 Subject: [Python-Dev] New uriparse.py In-Reply-To: <20060401134813.721B082CA@place.org> References: <20060401134813.721B082CA@place.org> Message-ID: <443003A6.4060509@v.loewis.de> Paul Jimenez wrote: > Announcing uriparse.py, submitted for inclusion in the standard library. > Patch request 1462525. > Per the original discussion at > http://mail.python.org/pipermail/python-dev/2005-November/058301.html > I'm submitting a library meant to deprecate the > existing urlparse library. Questions and comments welcome. My initial reaction was "why is it necessary to break everything"? I then re-read the thread, and found this is all fine. However, this shows (to me) that there is a big lack of rationale in this contribution. You explained it as "urlparse breaks abstractions"; however, this didn't mean anything to me. Saying "urlparse doesn't comply with STD66 (aka RFC3986) because it hard-codes URI schemes, instead of applying the same syntax to all of them" is something I would have understood as a problem. So in short: are you willing to write documentation for this? The rationale section could either go into the urllib documentation (pointing out that particular problem, and referring to urilib as an improvement) Regards, Martin From martin at v.loewis.de Sun Apr 2 19:09:08 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 02 Apr 2006 19:09:08 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigned a bug/patch In-Reply-To: References: <1143648409.10799.159.camel@resist.wooz.org> <442C11E2.6050106@v.loewis.de> <442C1C7E.4050502@v.loewis.de> Message-ID: <44300534.4010002@v.loewis.de> Fredrik Lundh wrote: >> If you would rather contribute by collecting a list of possible >> trackers along with who will maintain it, then please do. I am not >> going to dive into that quite yet, but if you want to parallelize the >> work needed then I would appreciate the help. > > that is what I expected the PSF infrastructure committee to do (I hope > you're not the only one in that committee?); it's a bit disappointing to > hear that we're still stuck on the SF export issue. > > (wasn't there someone with backchannel access to the SF data ?) Yes. We found a way to export all data (except for file attachments), through a different exporter. This gives all data, unfortunately, it is ill-formed XML (& is not properly entity-referenced sometimes). Anybody who wants to work with these data, please let me know; I made a snapshot a few days ago. The "backchannel access to SF data" was actually someone different: he experimented with the existing export, confirmed the problem, promised to talk to Paul Moore about that, and referred us to the other XML exporter as a work-around (that one allows to export 500 items at a time). Regards, Martin From fredrik at pythonware.com Sun Apr 2 19:20:16 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 2 Apr 2006 19:20:16 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigneda bug/patch References: <1143648409.10799.159.camel@resist.wooz.org> <442C11E2.6050106@v.loewis.de> <442C1C7E.4050502@v.loewis.de> <44300534.4010002@v.loewis.de> Message-ID: Martin v. Löwis wrote: > Yes. We found a way to export all data (except for file attachments), > through a different exporter. This gives all data, unfortunately, it > is ill-formed XML (& is not properly entity-referenced sometimes). so why didn't Brett know about this ? > Anybody who wants to work with these data, please let me know; > I made a snapshot a few days ago. the scraper I wrote in response to Brett's post has successfully down- loaded 80% of the data at this very moment (including attachments), so I'll probably keep playing with that one instead... From martin at v.loewis.de Sun Apr 2 19:36:58 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 02 Apr 2006 19:36:58 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigneda bug/patch In-Reply-To: References: <1143648409.10799.159.camel@resist.wooz.org> <442C11E2.6050106@v.loewis.de> <442C1C7E.4050502@v.loewis.de> <44300534.4010002@v.loewis.de> Message-ID: <44300BBA.6050702@v.loewis.de> Fredrik Lundh wrote: >> Yes. We found a way to export all data (except for file attachments), >> through a different exporter. This gives all data, unfortunately, it >> is ill-formed XML (& is not properly entity-referenced sometimes). > > so why didn't Brett know about this ? I'm not sure; I'm sure I mentioned it. Regards, Martin From guido at python.org Sun Apr 2 19:38:04 2006 From: guido at python.org (Guido van Rossum) Date: Sun, 2 Apr 2006 10:38:04 -0700 Subject: [Python-Dev] Saving the hash value of tuples In-Reply-To: References: Message-ID: On 4/1/06, Noam Raphael wrote: > I've found out that the hash value of tuples isn't saved after it's > calculated. With strings it's different: the hash value of a string is > calculated only on the first call to hash(string), and saved in the > structure for future use. Saving the value makes dict lookup of tuples > an operation with an amortized cost of O(1). Have you done any measurements to confirm that this makes any difference? I'm not particularly enamored of theoretical optimizations. This one in particular has a definite cost in space which needs to be weighed seriously. > Saving the hash value means that if an item of the tuple changes its > hash value, the hash value of the tuple won't be changed. I think it's > ok, since: > 1. Hash value of things shouldn't change. > 2. Dicts assume that too. Sure. (But you do realize that if a tuple contains a mutable value its hash value raises an exception, right?) > I tried the change, and it turned out that I had to change cPickle a > tiny bit: it uses a 2-tuple which is allocated when the module > initializes to lookup tuples in a dict. I changed it to properly use > PyTuple_New and Py_DECREF, and now the complete test suite passes. I > run test_cpickle before the change and after it, and it took the same > time (0.89 seconds on my computer). Not just cPickle. I believe enumerate() also reuses a tuple. > What do you think? I see three possibilities: > 1. Nothing should be done, everything is as it should be. > 2. The cPickle module should be changed to not abuse the tuple, but > there's no reason to add an extra word to the tuple structure and > break binary backwards compatibility. > 3. Both should be changed. I'm -1 on the change. Tuples are pretty fundamental in Python and hashing them is relatively rare. I think the extra required space for all tuples isn't worth the potential savings for some cases. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From jjl at pobox.com Sun Apr 2 19:55:10 2006 From: jjl at pobox.com (John J Lee) Date: Sun, 2 Apr 2006 17:55:10 +0000 (UTC) Subject: [Python-Dev] New uriparse.py In-Reply-To: <443003A6.4060509@v.loewis.de> References: <20060401134813.721B082CA@place.org> <443003A6.4060509@v.loewis.de> Message-ID: On Sun, 2 Apr 2006, "Martin v. L?wis" wrote: > Paul Jimenez wrote: >> Announcing uriparse.py, submitted for inclusion in the standard library. >> Patch request 1462525. [...] > abstractions"; however, this didn't mean anything to me. Saying > "urlparse doesn't comply with STD66 (aka RFC3986) because > it hard-codes URI schemes, instead of applying the same > syntax to all of them" is something I would have understood > as a problem. Evidently Paul quickly realised that back at the time of the original thread: hence the lack of posts from Paul protesting at Guido & Mike Brown's explanations, and the appearance now of this nice module :-) > So in short: are you willing to write documentation for this? > The rationale section could either go into the urllib documentation > (pointing out that particular problem, and referring to urilib > as an improvement) Currently of course we have both the functions in urllib, plus module urlparse. This module is roughly a replacement for urlparse. Probably if this module is accepted (after a few changes, no doubt) the urllib functions should then be deprecated (which would probably trigger adding a few more functions to the new module). I guess module urlparse would also be deprecated. I have a list of concrete and mostly easily-resolved problems with the module (including not liking the name). I also suspect there are issues related to unicode, %-encoding &c. exist which should be resolved before including this in the stdlib; I won't comment further on that until I've read the relevant RFCs. I've posted detailed comments on the tracker. John From crutcher at gmail.com Sun Apr 2 20:05:42 2006 From: crutcher at gmail.com (Crutcher Dunnavant) Date: Sun, 2 Apr 2006 11:05:42 -0700 Subject: [Python-Dev] String formating in python 3000 Message-ID: Python currently supports 'S % X', where S is a strinng, and X is one of: * a sequence * a map * treated as (X,) But I have some questions about this for python 3000. 1. Shouldn't there be a format method, like S.format(), or S.fmt()? 2. What about using __call__ instead of / in addition to __rmod__? * "time: %s"(time.ctime()) == "time: %s" % time.ctime() * "%(a)s %(b)s"(a=1, b=2) == "%(a)s %(b)s" % {'a'=1, 'b'=2} -- Crutcher Dunnavant littlelanguages.com monket.samedi-studios.com From guido at python.org Sun Apr 2 20:10:55 2006 From: guido at python.org (Guido van Rossum) Date: Sun, 2 Apr 2006 11:10:55 -0700 Subject: [Python-Dev] String formating in python 3000 In-Reply-To: References: Message-ID: Hi Crutcher, We've created a separate list for discussing Python 3000. http://mail.python.org/mailman/listinfo/python-3000 --Guido On 4/2/06, Crutcher Dunnavant wrote: > Python currently supports 'S % X', where S is a strinng, and X is one of: > * a sequence > * a map > * treated as (X,) > > But I have some questions about this for python 3000. > > 1. Shouldn't there be a format method, like S.format(), or S.fmt()? > > 2. What about using __call__ instead of / in addition to __rmod__? > * "time: %s"(time.ctime()) == "time: %s" % time.ctime() > * "%(a)s %(b)s"(a=1, b=2) == "%(a)s %(b)s" % {'a'=1, 'b'=2} > > -- > Crutcher Dunnavant > littlelanguages.com > monket.samedi-studios.com > _______________________________________________ > 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 (home page: http://www.python.org/~guido/) From aahz at pythoncraft.com Sun Apr 2 20:15:03 2006 From: aahz at pythoncraft.com (Aahz) Date: Sun, 2 Apr 2006 11:15:03 -0700 Subject: [Python-Dev] String formating in python 3000 In-Reply-To: References: Message-ID: <20060402181503.GA6583@panix.com> On Sun, Apr 02, 2006, Crutcher Dunnavant wrote: > > But I have some questions about this for python 3000. Please use the python-3000 list for questions like this. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Look, it's your affair if you want to play with five people, but don't go calling it doubles." --John Cleese anticipates Usenet From crutcher at gmail.com Sun Apr 2 20:37:27 2006 From: crutcher at gmail.com (Crutcher Dunnavant) Date: Sun, 2 Apr 2006 11:37:27 -0700 Subject: [Python-Dev] String formating in python 3000 In-Reply-To: <20060402181503.GA6583@panix.com> References: <20060402181503.GA6583@panix.com> Message-ID: Yep, moved this there. On 4/2/06, Aahz wrote: > On Sun, Apr 02, 2006, Crutcher Dunnavant wrote: > > > > But I have some questions about this for python 3000. > > Please use the python-3000 list for questions like this. > -- > Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ > > "Look, it's your affair if you want to play with five people, but don't > go calling it doubles." --John Cleese anticipates Usenet > -- Crutcher Dunnavant littlelanguages.com monket.samedi-studios.com From tim.peters at gmail.com Sun Apr 2 20:57:42 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sun, 2 Apr 2006 14:57:42 -0400 Subject: [Python-Dev] Bug Day on Friday, 31st of March In-Reply-To: References: Message-ID: <1f7befae0604021157k21272e57j5d9d18b680000125@mail.gmail.com> [/F] > so, how did it go? a status report / summary would be nice, I think ? http://wiki.python.org/moin/PythonBugDayStatus has been kept up to date. Note that, e.g., there are still open items in the "Bugs/patches to assess for commit" section, if you want to do more than just read. From g.brandl at gmx.net Sun Apr 2 22:52:57 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Sun, 02 Apr 2006 22:52:57 +0200 Subject: [Python-Dev] Bug Day on Friday, 31st of March In-Reply-To: <1f7befae0604021157k21272e57j5d9d18b680000125@mail.gmail.com> References: <1f7befae0604021157k21272e57j5d9d18b680000125@mail.gmail.com> Message-ID: Tim Peters wrote: > [/F] >> so, how did it go? a status report / summary would be nice, I think ? 19 bugs, 9 patches (which were mostly created to fix one of the bugs). Not much, but better than nothing and there has been quite a participation from "newbies". > http://wiki.python.org/moin/PythonBugDayStatus > > has been kept up to date. Note that, e.g., there are still open items > in the "Bugs/patches to assess for commit" section, if you want to do > more than just read. BTW, Tim, thanks for coming. I'm often in a situation that I look at a patch and say, "yes, that's working, but I'm not sure whether to apply this" and need a yes or no from someone up the ranks. Cheers, Georg From tim.peters at gmail.com Sun Apr 2 23:05:31 2006 From: tim.peters at gmail.com (Tim Peters) Date: Sun, 2 Apr 2006 17:05:31 -0400 Subject: [Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py In-Reply-To: <61055.89.54.32.106.1143966244.squirrel@isar.livinglogic.de> References: <20060401204023.804801E4006@bag.python.org> <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> <61055.89.54.32.106.1143966244.squirrel@isar.livinglogic.de> Message-ID: <1f7befae0604021405g16193eadicfef4bf7e4d280e6@mail.gmail.com> [Tim, gripes about ...] >>> Author: walter.doerwald >>> Date: Sat Apr 1 22:40:23 2006 >>> New Revision: 43545 >>> >>> Modified: >>> python/trunk/Doc/lib/libcalendar.tex >>> python/trunk/Lib/calendar.py >>> Log: >>> Make firstweekday a simple attribute instead >>> of hiding it behind a setter and a getter. [Walter][ > This is because in 2.4 there where no Calendar objects and firstweekday was > only setable and getable via module level functions. I didn't realize that, of course . Skipping the rest ;-), then, it would be best to make firstweekday a property on the new base class. > ... > The only thing lost is the range check in the setter. Which isn't a good thing to lose. It's not good that the current Calendar constructor skips that sanity check either ("errors should never pass silently"). > ... > Simple attribute access looks much more Pythonic to me than setters and gettes > (especially as the attributes of subclasses are simple attributes). > Or are you talking about the Calendar class itself? Yes, it would be best if Calendar had a property, so that sanity checks were performed when setting `firstweekday`, and also if the Calendar constructor performed that sanity check (which could happen "by magic" if `firstweekday` were a property). From tdelaney at avaya.com Sun Apr 2 23:47:22 2006 From: tdelaney at avaya.com (Delaney, Timothy (Tim)) Date: Mon, 3 Apr 2006 07:47:22 +1000 Subject: [Python-Dev] SF #1462485 - StopIteration raised in body of 'with' statement suppressed Message-ID: <2773CAC687FD5F4689F526998C7E4E5F074364@au3010avexu1.global.avaya.com> Discovered this while playing around with the 2.5 released end of last week. Given: @contextmanager def gen(): print '__enter__' yield print '__exit__' with gen(): raise StopIteration('body') I would expect to get the StopIteration exception raised. Instead it's suppressed by the @contextmanager decorator. I think we should only suppress the exception if it's *not* the exception passed into gen.throw() i.e. it's raised by the generator. Does this sound like the correct behaviour? I've attached tests and a fix implementing this to the bug report. I can't confirm right now (at work, need to install 2.5) but I'm also wondering what will happen if KeyboardInterrupt or SystemExit is raised from inside the generator when it's being closed via __exit__. I suspect a RuntimeError will be raised, whereas I think these should pass through. Tim Delaney From tdelaney at avaya.com Sun Apr 2 23:52:01 2006 From: tdelaney at avaya.com (Delaney, Timothy (Tim)) Date: Mon, 3 Apr 2006 07:52:01 +1000 Subject: [Python-Dev] SF #1462700 - Errors in PCbuild Message-ID: <2773CAC687FD5F4689F526998C7E4E5FF1E632@au3010avexu1.global.avaya.com> Discovered a couple of minor errors in pcbuild.sln and pythoncore.vsproj while working out how to compile 2.5 on Windows using the VS C++ Toolkit for the bug day (no Visual Studio at home). FWIW, I eventually ended up using Nant (using the task). Nant couldn't build 2.5 without the fixes - basically, _ctypes_test didn't have any dependencies, and so was being built first. And the GUIDs for pythoncore were different between pcbuild.sln and pythoncore.vsproj. I've attached the fix to the bug report. Tim Delaney From noamraph at gmail.com Sun Apr 2 23:54:14 2006 From: noamraph at gmail.com (Noam Raphael) Date: Mon, 3 Apr 2006 00:54:14 +0300 Subject: [Python-Dev] Saving the hash value of tuples In-Reply-To: References: Message-ID: On 4/2/06, Guido van Rossum wrote: > > I tried the change, and it turned out that I had to change cPickle a > > tiny bit: it uses a 2-tuple which is allocated when the module > > initializes to lookup tuples in a dict. I changed it to properly use > > PyTuple_New and Py_DECREF, and now the complete test suite passes. I > > run test_cpickle before the change and after it, and it took the same > > time (0.89 seconds on my computer). > > Not just cPickle. I believe enumerate() also reuses a tuple. Maybe it does, but I believe that it doesn't calculate the hash value of it - otherwise, the test suite would probably have failed. > > > What do you think? I see three possibilities: > > 1. Nothing should be done, everything is as it should be. > > 2. The cPickle module should be changed to not abuse the tuple, but > > there's no reason to add an extra word to the tuple structure and > > break binary backwards compatibility. > > 3. Both should be changed. > > I'm -1 on the change. Tuples are pretty fundamental in Python and > hashing them is relatively rare. I think the extra required space for > all tuples isn't worth the potential savings for some cases. That's fine with me. But what about option 2? Perhaps cPickle (and maybe enumerate) should properly discard their tuples, so that if someone in the future decides that saving the hash value is a good idea, he won't encounter strange bugs? At least in cPickle I didn't notice any loss of speed because of the change, and it's quite sensible, since there's a tuple-reuse mechanism anyway. Noam From tdelaney at avaya.com Sun Apr 2 23:59:01 2006 From: tdelaney at avaya.com (Delaney, Timothy (Tim)) Date: Mon, 3 Apr 2006 07:59:01 +1000 Subject: [Python-Dev] Bug Day on Friday, 31st of March Message-ID: <2773CAC687FD5F4689F526998C7E4E5FF1E633@au3010avexu1.global.avaya.com> Georg Brandl wrote: > Tim Peters wrote: >> [/F] >>> so, how did it go? a status report / summary would be nice, I >>> think ? > > 19 bugs, 9 patches (which were mostly created to fix one of the bugs). > Not much, but better than nothing and there has been quite a > participation > from "newbies". I've just added 1462485 and 1462700 to be assessed for commit. So make that 11 patches (although technically not finished on the day :) Tim Delaney From walter at livinglogic.de Mon Apr 3 00:12:30 2006 From: walter at livinglogic.de (=?ISO-8859-1?Q?Walter_D=F6rwald?=) Date: Mon, 03 Apr 2006 00:12:30 +0200 Subject: [Python-Dev] [Python-checkins] r43545 - in python/trunk: Doc/lib/libcalendar.tex Lib/calendar.py In-Reply-To: <1f7befae0604021405g16193eadicfef4bf7e4d280e6@mail.gmail.com> References: <20060401204023.804801E4006@bag.python.org> <1f7befae0604011443v52d051cfvcd0b01773ece3ec0@mail.gmail.com> <61055.89.54.32.106.1143966244.squirrel@isar.livinglogic.de> <1f7befae0604021405g16193eadicfef4bf7e4d280e6@mail.gmail.com> Message-ID: <44304C4E.8000707@livinglogic.de> Tim Peters wrote: > [Tim, gripes about ...] >>>> Author: walter.doerwald >>>> Date: Sat Apr 1 22:40:23 2006 >>>> New Revision: 43545 >>>> >>>> Modified: >>>> python/trunk/Doc/lib/libcalendar.tex >>>> python/trunk/Lib/calendar.py >>>> Log: >>>> Make firstweekday a simple attribute instead >>>> of hiding it behind a setter and a getter. > > [Walter][ >> This is because in 2.4 there where no Calendar objects and firstweekday was >> only setable and getable via module level functions. > > I didn't realize that, of course . Skipping the rest ;-), > then, it would be best to make firstweekday a property on the new base > class. > >> ... >> The only thing lost is the range check in the setter. > > Which isn't a good thing to lose. It's not good that the current > Calendar constructor skips that sanity check either ("errors should > never pass silently"). I've changed calendar so that firstweekday is only used modulo 7 everywhere (There was only one spot missing, all other cases used firstweekday modulo 7 anyway. >> ... >> Simple attribute access looks much more Pythonic to me than setters and gettes >> (especially as the attributes of subclasses are simple attributes). >> Or are you talking about the Calendar class itself? > > Yes, it would be best if Calendar had a property, so that sanity > checks were performed when setting `firstweekday`, and also if the > Calendar constructor performed that sanity check (which could happen > "by magic" if `firstweekday` were a property). Range checks should no longer be neccessary, as any value works now. Bye, Walter D?rwald From fredrik at pythonware.com Mon Apr 3 00:28:29 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 3 Apr 2006 00:28:29 +0200 Subject: [Python-Dev] I'm not getting email from SF when assigned abug/patch References: <1143648409.10799.159.camel@resist.wooz.org><442C11E2.6050106@v.loewis.de><442C1C7E.4050502@v.loewis.de> Message-ID: > > Fredrik, if you would like to help move this all forward, great; I > > would appreciate the help. You can write a page scraper to get the > > data out of SF > > challenge accepted ;-) > > http://effbot.python-hosting.com/browser/stuff/sandbox/sourceforge/ > > contains three basic tools; getindex to grab index information from a > python tracker, getpages to get "raw" xhtml versions of the item pages, > and getfiles to get attached files. > > I'm currently downloading a tracker snapshot that could be useful for > testing; it'll take a few more hours before all data are downloaded > (provided that SF doesn't ban me, and I don't stumble upon more > cases where a certain rhettinger has pasted binary gunk into an > iso-8859-1 form ;-). alright, it took my poor computer nearly eight hours to grab all the data, and some tracker items needed special treatment to work around some interesting SF bugs, but I've finally managed to download *all* items available via the SF tracker index, and *all* data files available via the item pages: tracker-105470 (bugs) 6682 items 6682 pages (100%) 1912 files tracker-305470 (patches) 3610 items 3610 pages (100%) 4663 files tracker-355470 (feature requests) 430 items 430 pages (100%) 80 files the complete data set is about 300 megabytes uncompressed, and ~85 megabytes zipped. the scripts are designed to make it easy to update the dataset; adding new items and files only takes a couple of minutes; refreshing the item information may take a few hours. ::: I've also added a basic "extract" module which parses the XHTML pages and the data files. this module can be used by import scripts, or be used to convert the dataset into other formats (e.g. a single XML file) for further processing. the source code is available via the above link; I'll post the ZIP file some- where tomorrow (drop me a line if you want the URL). From skip at pobox.com Mon Apr 3 00:59:44 2006 From: skip at pobox.com (skip at pobox.com) Date: Sun, 2 Apr 2006 17:59:44 -0500 Subject: [Python-Dev] Whole bunch of test failures on OSX Message-ID: <17456.22368.611952.670565@montanaro.dyndns.org> I'm not sure this is going to be all that helpful. If there's more I can do to help track down these problems, let me know. Last night I ran make test EXTRATESTOPTS='-R :: -uall -r' on my Mac laptop after a fresh svn up. I wasn't ready for how long that would run! I got plenty of test failures: 285 tests OK. 12 tests failed: test_codecencodings_cn test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_tw test_decimal test_difflib test_logging test_optparse test_warnings 15 tests skipped: test_al test_cd test_cl test_dl test_gdbm test_gl test_imgfile test_linuxaudiodev test_locale test_nis test_ossaudiodev test_pep277 test_sunaudiodev test_winreg test_winsound Those skips are all expected on darwin. The test_codecencodings_tw failure looks like this: File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 88, in test_customreplace_encode "test.xmlcharnamereplace")[0], sout) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 74, in xmlcharnamereplace if ord(c) in codepoint2name: File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 260, in ord return _ord(c) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 260, in ord return _ord(c) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 260, in ord return _ord(c) ... many more at the same line ... with "maximum recursion depth exceeded" at the bottom. Similar problem in test_codecmaps_hk except the recursion was in _unichr(): File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 299, in test_mapping_file unich = unichrs(data[1]) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 275, in unichrs = lambda s: u''.join(map(unichr, map(eval, s.split('+')))) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 253, in unichr return _unichr(v) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 253, in unichr return _unichr(v) File "/Users/skip/src/python-svn/trunk/Lib/test/test_multibytecodec_support.py", line 253, in unichr return _unichr(v) ... The other codec-related failures looked the same to my casual eye. The test_difflib error was an assertion failure involving a big-ass chunk of HTML: test test_difflib failed -- Traceback (most recent call last): File "/Users/skip/src/python-svn/trunk/Lib/test/test_difflib.py", line 145, in test_html_diff self.assertEqual(actual,expect) AssertionError: '\n\n\n\n\n\n \n \n