From eee44f28a93adbf8ff0b9391ddd0e77e99bbc55f Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Thu, 6 Feb 2014 15:46:38 -0600 Subject: [PATCH] Issue #3158: Provide a couple of fallbacks for in case a method_descriptor doesn't have __objclass__. --- Lib/doctest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/doctest.py b/Lib/doctest.py index fcfcbb037b7..d212ad6be1e 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__'):