[Python-checkins] cpython: Issue #3158: Provide a couple of fallbacks for in case a method_descriptor

zach.ware python-checkins at python.org
Thu Feb 6 22:47:09 CET 2014


http://hg.python.org/cpython/rev/c964b6b83720
changeset:   89002:c964b6b83720
user:        Zachary Ware <zachary.ware at gmail.com>
date:        Thu Feb 06 15:46:38 2014 -0600
summary:
  Issue #3158: Provide a couple of fallbacks for in case a method_descriptor
doesn't have __objclass__.

files:
  Lib/doctest.py |  8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Lib/doctest.py b/Lib/doctest.py
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -945,7 +945,13 @@
         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__'):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list