[issue16268] dir(closure) does not find __dir__
Bradley Froehle
report at bugs.python.org
Mon Oct 29 22:01:32 CET 2012
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 <report at bugs.python.org>
<http://bugs.python.org/issue16268>
_______________________________________
More information about the Python-bugs-list
mailing list