summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-21 22:02:28 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-07-22 09:29:53 +0200
commitf1d5dc81ac37fe9a7c7ca860900ee6a16150bb09 (patch)
treedb47ad3e6ec10a8a4e7f93028c0758ae31b0af9b
parentd11d45aad969be313b9e046d0d42b179a3fb6906 (diff)
[py3] Switched to Python 3-compatible introspection.
-rw-r--r--django/contrib/syndication/views.py8
-rw-r--r--django/test/_doctest.py8
2 files changed, 8 insertions, 8 deletions
diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py
index 773a1cd7bd..3c84f1f60c 100644
--- a/django/contrib/syndication/views.py
+++ b/django/contrib/syndication/views.py
@@ -60,14 +60,14 @@ class Feed(object):
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:
diff --git a/django/test/_doctest.py b/django/test/_doctest.py
index ab8f034570..b5d5da970b 100644
--- a/django/test/_doctest.py
+++ b/django/test/_doctest.py
@@ -861,7 +861,7 @@ class DocTestFinder:
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 @@ class DocTestFinder:
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 @@ class DocTestFinder:
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):