[issue16268] dir(closure) does not find __dir__

2012-10-31 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-30 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

The same fix, but with a unit test.
Note that object.__dir__ did not exist in previous versions, but I found a 
similar failure with __format__, which also applies to 2.7.

--
nosy: +amaury.forgeotdarc
Added file: http://bugs.python.org/file27801/init_cell_type-2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-30 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc amaur...@gmail.com:


--
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-30 Thread Bradley Froehle

Bradley Froehle added the comment:

Your patch looks good to me, and I can verify that it properly tests for the 
issue in Python 3.3.

On a related note, I've found that PyType_Ready(...) isn't called for a few 
other core PyTypeObjects... see #16369.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-30 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
resolution:  - duplicate
status: open - closed
superseder:  - Global PyTypeObjects not initialized with PyType_Ready(...)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-29 Thread Bradley Froehle

Bradley Froehle added the comment:

This rather obscure bug seems to be caused by a failure to properly initialize 
PyCell_Type.

Running with GDB, we see that _PyType_Lookup(class 'cell',  __dir__) 
fails in:

/* Look in tp_dict of types in MRO */
mro = type-tp_mro;

/* If mro is NULL, the type is either not yet initialized
   by PyType_Ready(), or already cleared by type_clear().
   Either way the safest thing to do is to return NULL. */
if (mro == NULL)
return NULL;

Since:

(gdb) print PyCell_Type-tp_mro
$9 = (PyObject *) 0x0

Searching the code base shows that we never call PyType_Ready(PyCell_Type).

A patch is attached.

--
keywords: +patch
nosy: +bfroehle
Added file: http://bugs.python.org/file27783/init_cell_type.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-29 Thread Bradley Froehle

Bradley Froehle added the comment:

Note that we fail to initialize PyCell_Type in all versions of Python, even if 
there aren't any visible ramifications in earlier versions.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16268] dir(closure) does not find __dir__

2012-10-17 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Here is a somewhat simpler way to reproduce (following the same definition of 
x):

 dir(x)
  ...
TypeError: object does not provide __dir__
 x.__dir__
built-in method __dir__ of cell object at 0x10c182950
 dir(x)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', 
'__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', 
'__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'cell_contents']

The dir() documentation says, If the object has a method named __dir__(), this 
method will be called and must return the list of attributes.

(from http://docs.python.org/py3k/library/functions.html#dir )

--
nosy: +chris.jerdonek
title: dir(closure) claims that a closure has no __dir__, only to work later 
after manually invoking __dir__ from its type - dir(closure) does not find 
__dir__
versions: +Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16268
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com