mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
16849a7e53
commit
065a5ab8fb
1 changed files with 2 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue