summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-09-19 23:00:12 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-09-19 23:00:12 (GMT)
commitf0cfdf731470d1780c1a49d00a76e5ed1598466a (patch)
tree87642038f0d95b919f25b0785fcae642861d6e6f /Lib
parent065a5ab8fb89b6f082a8361b860b48c00f21c301 (diff)
downloadcpython-f0cfdf731470d1780c1a49d00a76e5ed1598466a.zip
cpython-f0cfdf731470d1780c1a49d00a76e5ed1598466a.tar.gz
cpython-f0cfdf731470d1780c1a49d00a76e5ed1598466a.tar.bz2
Fiddle comments and variable names in whichmodule().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pickle.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index d4085cf..954da4e 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -611,30 +611,29 @@ def _keep_alive(x, memo):
memo[id(memo)]=[x]
-classmap = {}
+classmap = {} # called classmap for backwards compatibility
-# This is no longer used to find classes, but still for functions
-def whichmodule(cls, clsname):
- """Figure out the module in which a class occurs.
+def whichmodule(func, funcname):
+ """Figure out the module in which a function occurs.
Search sys.modules for the module.
Cache in classmap.
Return a module name.
- If the class cannot be found, return __main__.
+ If the function cannot be found, return __main__.
"""
- if cls in classmap:
- return classmap[cls]
+ if func in classmap:
+ return classmap[func]
for name, module in sys.modules.items():
- if module is None:
+ if module is None:
continue # skip dummy package entries
if name != '__main__' and \
- hasattr(module, clsname) and \
- getattr(module, clsname) is cls:
+ hasattr(module, funcname) and \
+ getattr(module, funcname) is func:
break
else:
name = '__main__'
- classmap[cls] = name
+ classmap[func] = name
return name