Kaydet (Commit) 8b58b84d authored tarafından Ka-Ping Yee's avatar Ka-Ping Yee

Add __author__ variable.

Robustify: don't rely on modules being present in sys.modules.
üst 66efbc74
...@@ -24,7 +24,8 @@ Here are some of the useful functions provided by this module: ...@@ -24,7 +24,8 @@ Here are some of the useful functions provided by this module:
# This module is in the public domain. No warranties. # This module is in the public domain. No warranties.
__version__ = 'Ka-Ping Yee <ping@lfw.org>, 1 Jan 2001' __author__ = 'Ka-Ping Yee <ping@lfw.org>'
__date__ = '1 Jan 2001'
import sys, types, string, dis, imp, tokenize import sys, types, string, dis, imp, tokenize
...@@ -196,7 +197,7 @@ modulesbyfile = {} ...@@ -196,7 +197,7 @@ modulesbyfile = {}
def getmodule(object): def getmodule(object):
"""Try to guess which module an object was defined in.""" """Try to guess which module an object was defined in."""
if isclass(object): if isclass(object):
return sys.modules[object.__module__] return sys.modules.get(object.__module__)
try: try:
file = getsourcefile(object) file = getsourcefile(object)
except TypeError: except TypeError:
...@@ -630,3 +631,5 @@ def stack(context=1): ...@@ -630,3 +631,5 @@ def stack(context=1):
def trace(context=1): def trace(context=1):
"""Return a list of records for the stack below the current exception.""" """Return a list of records for the stack below the current exception."""
return getinnerframes(sys.exc_traceback, context) return getinnerframes(sys.exc_traceback, context)
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