From 065a5ab8fb89b6f082a8361b860b48c00f21c301 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Thu, 19 Sep 2002 22:57:26 +0000 Subject: [PATCH] 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. --- Lib/pickle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/pickle.py b/Lib/pickle.py index 4bc54ec5f9..d4085cfbc0 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: -- 2.50.0