[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-10 Thread Benjamin Peterson
Benjamin Peterson added the comment: I look at it this way: If I was browsing the 2.7 code and saw that type check, would I remove it in the bugfix release? No. I'm going to mark this resolved. Thanks everyone. -- resolution: -> works for me status: open -> closed __

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: My preference is to remove the type check. It hasn't and won't serve a useful purpose so there's no reason to freeze it into the API and have it live on. That being said, it probably doesn't matter one bit how this report gets resolved. -- _

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-09 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2011/6/9 Barry A. Warsaw : > > Barry A. Warsaw added the comment: > > Raymond, I like your patch and I think it addresses the issue nicely.  I made > one small change, which is to add a test for non-list-sequenceness instead of > changing the existing __di

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-09 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Raymond, I like your patch and I think it addresses the issue nicely. I made one small change, which is to add a test for non-list-sequenceness instead of changing the existing __dir__is_list test. I think both tests are useful to keep. Benjamin, what do

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Soren Hansen
Soren Hansen added the comment: 2011/6/5 Benjamin Peterson : > 2011/6/4 Soren Hansen : >> ...I end up with a "RuntimeError: maximum recursion depth exceeded". I >> can't say I'm surprised :) > Ah, sorry I should have thought before writing that. :) > self.__class__.__dir__.__get__(self, self.__c

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2011/6/4 Soren Hansen : > > Soren Hansen added the comment: > > 2011/6/4 Benjamin Peterson : >> 2011/6/4 Soren Hansen : >>> So my question is: If this change stays (which seems clear given that the >>> only changes proposed here are ways of relaxing the typ

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Soren Hansen
Soren Hansen added the comment: 2011/6/4 Benjamin Peterson : > 2011/6/4 Soren Hansen : >> So my question is: If this change stays (which seems clear given that the >> only changes proposed here are ways of relaxing the type requirement of the >> __dir__ method's return value, not reverting the

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2011/6/4 Soren Hansen : > > Soren Hansen added the comment: > > When I first investigated this problem (I reported the original bug on > Launchpad), my first attempt to address this issue in pymox had me quite > stumped. The class in question has a __getat

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Soren Hansen
Soren Hansen added the comment: When I first investigated this problem (I reported the original bug on Launchpad), my first attempt to address this issue in pymox had me quite stumped. The class in question has a __getattr__ method. Up until now, this hasn't affected the use of dir(), but it

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- keywords: +patch Added file: http://bugs.python.org/file22246/dir.patch ___ Python tracker ___ ___ P

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-04 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: Using sorted() makes sense to me. Note that I've at least accomplished one goal, which is to have a tracker issue that discusses the merits of the change. That way, no matter what the RM decides, I can at least point to an issue for justification when I r

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: or something like: result = obj.__dir__() if not isinstance(result, list): result = list(result) result.sort() return result -- ___ Python tracker _

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Can sorted() be used instead? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2011/6/3 Raymond Hettinger : > > Raymond Hettinger added the comment: > > I believe the type check was gratuitous to begin with and should be removed.   > There's no reason the result has to be a list. The reason for it is that the sort() method is called o

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: I believe the type check was gratuitous to begin with and should be removed. There's no reason the result has to be a list. -- ___ Python tracker

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Nick Coghlan
Nick Coghlan added the comment: It would be broken in the same way that it was broken in 2.7.1 though. That can be a plus when it comes to maintenance releases. OTOH, this does turn a silent failure (__dir__() ignored on old-style classes) into a noisy failure (must return a list). If you ma

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread R. David Murray
R. David Murray added the comment: I would guess that if you instead skipped __dir__ completely for old style classes it would expose a different bug in this or some other package. -- ___ Python tracker _

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Benjamin Peterson
Benjamin Peterson added the comment: 2011/6/3 Nick Coghlan : > > Nick Coghlan added the comment: > > Ah, I wondered about that when I saw Barry was using old-style classes in his > example. Perhaps the answer then is to add a PyInstance_Check() to skip > invocation of __dir__() completely for

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Nick Coghlan
Nick Coghlan added the comment: Ah, I wondered about that when I saw Barry was using old-style classes in his example. Perhaps the answer then is to add a PyInstance_Check() to skip invocation of __dir__() completely for old-style classes? -- ___ P

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Benjamin Peterson
Benjamin Peterson added the comment: No additional type-checking was added. The problem is that __dir__ didn't work on old-style classes at all in 2.7.1: $ python Python 2.7.1 (r271:86832, Mar 24 2011, 22:44:47) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more in

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-03 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I don't believe there is any reason to have tightened up > the type constraints while fixing that - dir() should be > returning sorted(obj.__dir__()) and not caring about the > exact return type of the magic method. +1 -- nosy: +rhettinger _

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-02 Thread Andreas Stührk
Changes by Andreas Stührk : -- nosy: +Trundle ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-02 Thread Nick Coghlan
Nick Coghlan added the comment: Hmm, that behaviour looks unrelated to the specific problem Michael reported. The initial problem in this space was that defining __dir__() completely determined the result of dir() calls, but object.__dir__() didn't actually work, so you couldn't easily get th

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-02 Thread R. David Murray
R. David Murray added the comment: As I recall the issue that triggered the change was reported by Michael Foord, so I'm adding him as nosy too. -- nosy: +michael.foord, r.david.murray ___ Python tracker

[issue12248] __dir__ semantics changed in Python 2.7.2

2011-06-02 Thread Barry A. Warsaw
New submission from Barry A. Warsaw : I'm making this a release blocker for 2.7.2 because I want to ensure that the change is deliberate and appropriate. This is triggered by a bug report in Ubuntu where the change in behavior was noticed: https://bugs.launchpad.net/nova/+bug/791221/+index I