]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport:
authorAnthony Baxter <anthonybaxter@gmail.com>
Fri, 11 Jun 2004 15:09:41 +0000 (15:09 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Fri, 11 Jun 2004 15:09:41 +0000 (15:09 +0000)
Fix for bug #966623 - classes created with type() in an exec(, {}) don't
have a __module__. Test for this case.

Misc/NEWS
Objects/typeobject.c

index e917e882a34caee0f00a97889a6d1d45a300b635..b01488bca40ba22bf276f3314720d404484ca44c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.3.5?
 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.
+
 - Bug #952807:  Unpickling pickled instances of subclasses of
   datetime.date, datetime.datetime and datetime.time could yield insane
   objects.  Thanks to Jiwon Seo for a fix.
index 9213ff0334df6dfa5d469794059cbc485861c562..5898df24c8634944491fb528d7656eac8f56b885 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;
        }