Commit 065a5ab8 authored by Jeremy Hylton's avatar Jeremy Hylton

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 <built-in method __new__ of type object at 0x812a440>: it's not the same object as datetime.math.__new__

Bugfix candidate.
parent 16849a7e
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment