Use __module__ attribute when available instead of using isclass() predicate

(functions and methods have grown the __module__ attribute too). See bug #570300.
This commit is contained in:
Johannes Gijsbers 2004-09-11 15:53:22 +00:00
parent c9c37ca62e
commit 9324526a76
1 changed files with 1 additions and 1 deletions

View File

@ -370,7 +370,7 @@ def getmodule(object):
"""Return the module an object was defined in, or None if not found."""
if ismodule(object):
return object
if isclass(object):
if hasattr(object, '__module__'):
return sys.modules.get(object.__module__)
try:
file = getabsfile(object)