From: Guido van Rossum <guido@python.org>
Date: Sun, 28 Sep 1997 05:38:51 +0000 (+0000)
Subject: In whichmodule(), use __module__ if set.
X-Git-Tag: v1.5a4~133
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4518823ad0e7a408ef664dcebe8907ca66b72750;p=python

In whichmodule(), use __module__ if set.
---

diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index b5fddd0e7e..6021a03da4 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -632,6 +632,10 @@ whichmodule(PyObject *global, PyObject *global_name) {
     PyObject *module = 0, *modules_dict = 0,
         *global_name_attr = 0, *name = 0;
 
+    module = PyObject_GetAttrString(global, "__module__");
+    if (module) return module;
+    PyErr_Clear();
+
     if ((module = PyDict_GetItem(class_map, global))) {
         Py_INCREF(module);
         return module;