]> granicus.if.org Git - python/commitdiff
Fix for bug #966623 - classes created with type() in an exec(, {}) don't
authorAnthony Baxter <anthonybaxter@gmail.com>
Fri, 11 Jun 2004 14:41:18 +0000 (14:41 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Fri, 11 Jun 2004 14:41:18 +0000 (14:41 +0000)
have a __module__. Test for this case.

Bugfix candidate, will backport.

Misc/NEWS
Objects/typeobject.c

index dd75f61e07b766784785eccec46870fa5d355468..86eac9fa83d565aeaed5c600999fec40de77ab19 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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.
index 818572fa6f63c50526e62a160dd9787a1d313fbf..ee6e5d988d36a18dd79518a11a91e13d348fe1b5 100644 (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;
        }