From: Jeremy Hylton Date: Thu, 19 Sep 2002 22:57:26 +0000 (+0000) Subject: whichmodule() should skip dummy package entries in sys.modules. X-Git-Tag: v2.3c1~4017 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=065a5ab8fb89b6f082a8361b860b48c00f21c301;p=thirdparty%2FPython%2Fcpython.git whichmodule() should skip dummy package entries in sys.modules. This fixes the charming, but unhelpful error message for >>> pickle.dumps(type.__new__) Can't pickle : it's not the same object as datetime.math.__new__ Bugfix candidate. --- diff --git a/Lib/pickle.py b/Lib/pickle.py index 4bc54ec5f9de..d4085cfbc09b 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -626,6 +626,8 @@ def whichmodule(cls, clsname): return classmap[cls] for name, module in sys.modules.items(): + if module is None: + continue # skip dummy package entries if name != '__main__' and \ hasattr(module, clsname) and \ getattr(module, clsname) is cls: