From: Johannes Gijsbers Date: Sat, 11 Sep 2004 15:53:22 +0000 (+0000) Subject: Use __module__ attribute when available instead of using isclass() predicate X-Git-Tag: v2.4b1~297 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9324526a7658c5450eba24b48065d87d5db5ab1f;p=python Use __module__ attribute when available instead of using isclass() predicate (functions and methods have grown the __module__ attribute too). See bug #570300. --- diff --git a/Lib/inspect.py b/Lib/inspect.py index 3c47cd9b44..5e3f7e2c90 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -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)