Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[py3] Switched to Python 3-compatible introspection.

  • Loading branch information...
commit f1d5dc81ac37fe9a7c7ca860900ee6a16150bb09 1 parent d11d45a
@aaugustin aaugustin authored
Showing with 8 additions and 8 deletions.
  1. +4 −4 django/contrib/syndication/views.py
  2. +4 −4 django/test/_doctest.py
View
8 django/contrib/syndication/views.py
@@ -60,14 +60,14 @@ def __get_dynamic_attr(self, attname, obj, default=None):
except AttributeError:
return default
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
# the function may raise the TypeError. This technique is more
# accurate.
- if hasattr(attr, 'func_code'):
- argcount = attr.func_code.co_argcount
+ if hasattr(attr, '__code__'):
+ argcount = attr.__code__.co_argcount
else:
- argcount = attr.__call__.func_code.co_argcount
+ argcount = attr.__call__.__code__.co_argcount
if argcount == 2: # one argument is 'self'
return attr(obj)
else:
View
8 django/test/_doctest.py
@@ -861,7 +861,7 @@ def _from_module(self, module, object):
if module is None:
return True
elif inspect.isfunction(object):
- return module.__dict__ is object.func_globals
+ return module.__dict__ is object.__globals__
elif inspect.isclass(object):
return module.__name__ == object.__module__
elif inspect.getmodule(object) is not None:
@@ -926,7 +926,7 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
if isinstance(val, staticmethod):
val = getattr(obj, valname)
if isinstance(val, classmethod):
- val = getattr(obj, valname).im_func
+ val = getattr(obj, valname).__func__
# Recurse to methods, properties, and nested classes.
if ((inspect.isfunction(val) or inspect.isclass(val) or
@@ -998,8 +998,8 @@ def _find_lineno(self, obj, source_lines):
break
# Find the line number for functions & methods.
- if inspect.ismethod(obj): obj = obj.im_func
- if inspect.isfunction(obj): obj = obj.func_code
+ if inspect.ismethod(obj): obj = obj.__func__
+ if inspect.isfunction(obj): obj = obj.__code__
if inspect.istraceback(obj): obj = obj.tb_frame
if inspect.isframe(obj): obj = obj.f_code
if inspect.iscode(obj):
Please sign in to comment.
Something went wrong with that request. Please try again.