Fix for bug #966623 - classes created with type() in an exec(, {}) don't

have a __module__. Test for this case.

Bugfix candidate, will backport.
This commit is contained in:
Anthony Baxter 2004-06-11 14:41:18 +00:00
parent 51ffac6db7
commit 3ecdb250af
2 changed files with 8 additions and 0 deletions

View File

@ -12,6 +12,10 @@ What's New in Python 2.4 alpha 1?
Core and builtins
-----------------
- Bug #966623. classes created with type() in an exec(, {}) don't
have a __module__, but code in typeobject assumed it would always
be there.
- Python no longer relies on the LC_NUMERIC locale setting to be
the "C" locale; as a result, it no longer tries to prevent changing
the LC_NUMERIC category.

View File

@ -87,6 +87,10 @@ type_module(PyTypeObject *type, void *context)
if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) {
mod = PyDict_GetItemString(type->tp_dict, "__module__");
if (!mod) {
PyErr_Format(PyExc_AttributeError, "__module__");
return 0;
}
Py_XINCREF(mod);
return mod;
}