From: Zachary Ware Date: Thu, 6 Feb 2014 21:46:38 +0000 (-0600) Subject: Issue #3158: Provide a couple of fallbacks for in case a method_descriptor X-Git-Tag: v3.4.0rc1~66 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eee44f28a93adbf8ff0b9391ddd0e77e99bbc55f;p=thirdparty%2FPython%2Fcpython.git Issue #3158: Provide a couple of fallbacks for in case a method_descriptor doesn't have __objclass__. --- diff --git a/Lib/doctest.py b/Lib/doctest.py index fcfcbb037b7b..d212ad6be1ea 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -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__'):