Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b58b84

Browse files
committed
Add __author__ variable.
Robustify: don't rely on modules being present in sys.modules.
1 parent 66efbc7 commit 8b58b84

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Lib/inspect.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
# This module is in the public domain. No warranties.
2626

27-
__version__ = 'Ka-Ping Yee <[email protected]>, 1 Jan 2001'
27+
__author__ = 'Ka-Ping Yee <[email protected]>'
28+
__date__ = '1 Jan 2001'
2829

2930
import sys, types, string, dis, imp, tokenize
3031

@@ -196,7 +197,7 @@ def getfile(object):
196197
def getmodule(object):
197198
"""Try to guess which module an object was defined in."""
198199
if isclass(object):
199-
return sys.modules[object.__module__]
200+
return sys.modules.get(object.__module__)
200201
try:
201202
file = getsourcefile(object)
202203
except TypeError:
@@ -630,3 +631,5 @@ def stack(context=1):
630631
def trace(context=1):
631632
"""Return a list of records for the stack below the current exception."""
632633
return getinnerframes(sys.exc_traceback, context)
634+
635+

0 commit comments

Comments
 (0)