[py3] Switched to Python 3-compatible introspection.
This commit is contained in:
parent
d11d45aad9
commit
f1d5dc81ac
|
@ -60,14 +60,14 @@ class Feed(object):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return default
|
return default
|
||||||
if callable(attr):
|
if callable(attr):
|
||||||
# Check func_code.co_argcount rather than try/excepting the
|
# Check __code__.co_argcount rather than try/excepting the
|
||||||
# function and catching the TypeError, because something inside
|
# function and catching the TypeError, because something inside
|
||||||
# the function may raise the TypeError. This technique is more
|
# the function may raise the TypeError. This technique is more
|
||||||
# accurate.
|
# accurate.
|
||||||
if hasattr(attr, 'func_code'):
|
if hasattr(attr, '__code__'):
|
||||||
argcount = attr.func_code.co_argcount
|
argcount = attr.__code__.co_argcount
|
||||||
else:
|
else:
|
||||||
argcount = attr.__call__.func_code.co_argcount
|
argcount = attr.__call__.__code__.co_argcount
|
||||||
if argcount == 2: # one argument is 'self'
|
if argcount == 2: # one argument is 'self'
|
||||||
return attr(obj)
|
return attr(obj)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -861,7 +861,7 @@ class DocTestFinder:
|
||||||
if module is None:
|
if module is None:
|
||||||
return True
|
return True
|
||||||
elif inspect.isfunction(object):
|
elif inspect.isfunction(object):
|
||||||
return module.__dict__ is object.func_globals
|
return module.__dict__ is object.__globals__
|
||||||
elif inspect.isclass(object):
|
elif inspect.isclass(object):
|
||||||
return module.__name__ == object.__module__
|
return module.__name__ == object.__module__
|
||||||
elif inspect.getmodule(object) is not None:
|
elif inspect.getmodule(object) is not None:
|
||||||
|
@ -926,7 +926,7 @@ class DocTestFinder:
|
||||||
if isinstance(val, staticmethod):
|
if isinstance(val, staticmethod):
|
||||||
val = getattr(obj, valname)
|
val = getattr(obj, valname)
|
||||||
if isinstance(val, classmethod):
|
if isinstance(val, classmethod):
|
||||||
val = getattr(obj, valname).im_func
|
val = getattr(obj, valname).__func__
|
||||||
|
|
||||||
# Recurse to methods, properties, and nested classes.
|
# Recurse to methods, properties, and nested classes.
|
||||||
if ((inspect.isfunction(val) or inspect.isclass(val) or
|
if ((inspect.isfunction(val) or inspect.isclass(val) or
|
||||||
|
@ -998,8 +998,8 @@ class DocTestFinder:
|
||||||
break
|
break
|
||||||
|
|
||||||
# Find the line number for functions & methods.
|
# Find the line number for functions & methods.
|
||||||
if inspect.ismethod(obj): obj = obj.im_func
|
if inspect.ismethod(obj): obj = obj.__func__
|
||||||
if inspect.isfunction(obj): obj = obj.func_code
|
if inspect.isfunction(obj): obj = obj.__code__
|
||||||
if inspect.istraceback(obj): obj = obj.tb_frame
|
if inspect.istraceback(obj): obj = obj.tb_frame
|
||||||
if inspect.isframe(obj): obj = obj.f_code
|
if inspect.isframe(obj): obj = obj.f_code
|
||||||
if inspect.iscode(obj):
|
if inspect.iscode(obj):
|
||||||
|
|
Loading…
Reference in New Issue