]> granicus.if.org Git - python/commitdiff
Use __module__ attribute when available instead of using isclass() predicate
authorJohannes Gijsbers <jlg@dds.nl>
Sat, 11 Sep 2004 15:53:22 +0000 (15:53 +0000)
committerJohannes Gijsbers <jlg@dds.nl>
Sat, 11 Sep 2004 15:53:22 +0000 (15:53 +0000)
(functions and methods have grown the __module__ attribute too). See bug #570300.

Lib/inspect.py

index 3c47cd9b4484ce668cb2850186123e55d32236f9..5e3f7e2c901fc1777316691a12f8fa02d0afb9ed 100644 (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)