diff --git a/Lib/pickle.py b/Lib/pickle.py index 35ab91b9143..876c81b70a1 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -943,8 +943,7 @@ def whichmodule(func, funcname): if module is None: continue # skip dummy package entries if name != '__main__' and \ - hasattr(module, funcname) and \ - getattr(module, funcname) is func: + getattr(module, funcname, None) is func: break else: name = '__main__'