Skip to content

Commit f1d5dc8

Browse files
committed
[py3] Switched to Python 3-compatible introspection.
1 parent d11d45a commit f1d5dc8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

django/contrib/syndication/views.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def __get_dynamic_attr(self, attname, obj, default=None):
6060
except AttributeError:
6161
return default
6262
if callable(attr):
63-
# Check func_code.co_argcount rather than try/excepting the
63+
# Check __code__.co_argcount rather than try/excepting the
6464
# function and catching the TypeError, because something inside
6565
# the function may raise the TypeError. This technique is more
6666
# accurate.
67-
if hasattr(attr, 'func_code'):
68-
argcount = attr.func_code.co_argcount
67+
if hasattr(attr, '__code__'):
68+
argcount = attr.__code__.co_argcount
6969
else:
70-
argcount = attr.__call__.func_code.co_argcount
70+
argcount = attr.__call__.__code__.co_argcount
7171
if argcount == 2: # one argument is 'self'
7272
return attr(obj)
7373
else:

django/test/_doctest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def _from_module(self, module, object):
861861
if module is None:
862862
return True
863863
elif inspect.isfunction(object):
864-
return module.__dict__ is object.func_globals
864+
return module.__dict__ is object.__globals__
865865
elif inspect.isclass(object):
866866
return module.__name__ == object.__module__
867867
elif inspect.getmodule(object) is not None:
@@ -926,7 +926,7 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
926926
if isinstance(val, staticmethod):
927927
val = getattr(obj, valname)
928928
if isinstance(val, classmethod):
929-
val = getattr(obj, valname).im_func
929+
val = getattr(obj, valname).__func__
930930

931931
# Recurse to methods, properties, and nested classes.
932932
if ((inspect.isfunction(val) or inspect.isclass(val) or
@@ -998,8 +998,8 @@ def _find_lineno(self, obj, source_lines):
998998
break
999999

10001000
# Find the line number for functions & methods.
1001-
if inspect.ismethod(obj): obj = obj.im_func
1002-
if inspect.isfunction(obj): obj = obj.func_code
1001+
if inspect.ismethod(obj): obj = obj.__func__
1002+
if inspect.isfunction(obj): obj = obj.__code__
10031003
if inspect.istraceback(obj): obj = obj.tb_frame
10041004
if inspect.isframe(obj): obj = obj.f_code
10051005
if inspect.iscode(obj):

0 commit comments

Comments
 (0)