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.
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: