[issue12248] __dir__ semantics changed in Python 2.7.2

Benjamin Peterson report at bugs.python.org
Fri Jun 3 23:03:03 CEST 2011


Benjamin Peterson <benjamin at python.org> 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 information.
>>> class Foo:
... def __dir__(self):
... return ['a', 'b', 'c']
...
>>> class Bar:
... def __dir__(self):
... return ('a', 'b', 'c')
...
>>> print dir(Foo())
['__dir__', '__doc__', '__module__']
>>> print dir(Bar())
['__dir__', '__doc__', '__module__']

Loosening type-checks on dir() is fine with me but is really a 3.3 issue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12248>
_______________________________________


More information about the Python-bugs-list mailing list