]> granicus.if.org Git - python/commitdiff
Issue #3158: Provide a couple of fallbacks for in case a method_descriptor
authorZachary Ware <zachary.ware@gmail.com>
Thu, 6 Feb 2014 21:46:38 +0000 (15:46 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Thu, 6 Feb 2014 21:46:38 +0000 (15:46 -0600)
doesn't have __objclass__.

Lib/doctest.py

index fcfcbb037b7b900111a5773cb0549b4eb2210c29..d212ad6be1ea97dfdc82cc7bea39b76e43127315 100644 (file)
@@ -945,7 +945,13 @@ class DocTestFinder:
         elif inspect.isfunction(object):
             return module.__dict__ is object.__globals__
         elif inspect.ismethoddescriptor(object):
-            return module.__name__ == object.__objclass__.__module__
+            if hasattr(object, '__objclass__'):
+                obj_mod = object.__objclass__.__module__
+            elif hasattr(object, '__module__'):
+                obj_mod = object.__module__
+            else:
+                return True # [XX] no easy way to tell otherwise
+            return module.__name__ == obj_mod
         elif inspect.isclass(object):
             return module.__name__ == object.__module__
         elif hasattr(object, '__module__'):