summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-02-06 21:46:38 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-02-06 21:46:38 (GMT)
commiteee44f28a93adbf8ff0b9391ddd0e77e99bbc55f (patch)
tree098389afdec56c15a39b37eef73a80fbd28f0ad1 /Lib/doctest.py
parenta26b3f183d1101a21c51a5bd0c75834dfe859039 (diff)
downloadcpython-eee44f28a93adbf8ff0b9391ddd0e77e99bbc55f.zip
cpython-eee44f28a93adbf8ff0b9391ddd0e77e99bbc55f.tar.gz
cpython-eee44f28a93adbf8ff0b9391ddd0e77e99bbc55f.tar.bz2
Issue #3158: Provide a couple of fallbacks for in case a method_descriptor
doesn't have __objclass__.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index fcfcbb0..d212ad6 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__'):