Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Switched to Python 3-compatible introspection.

  • Loading branch information...
commit f1d5dc81ac37fe9a7c7ca860900ee6a16150bb09 1 parent d11d45a
Aymeric Augustin authored July 21, 2012
8  django/contrib/syndication/views.py
@@ -60,14 +60,14 @@ def __get_dynamic_attr(self, attname, obj, default=None):
60 60
         except AttributeError:
61 61
             return default
62 62
         if callable(attr):
63  
-            # Check func_code.co_argcount rather than try/excepting the
  63
+            # Check __code__.co_argcount rather than try/excepting the
64 64
             # function and catching the TypeError, because something inside
65 65
             # the function may raise the TypeError. This technique is more
66 66
             # 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
69 69
             else:
70  
-                argcount = attr.__call__.func_code.co_argcount
  70
+                argcount = attr.__call__.__code__.co_argcount
71 71
             if argcount == 2: # one argument is 'self'
72 72
                 return attr(obj)
73 73
             else:
8  django/test/_doctest.py
@@ -861,7 +861,7 @@ def _from_module(self, module, object):
861 861
         if module is None:
862 862
             return True
863 863
         elif inspect.isfunction(object):
864  
-            return module.__dict__ is object.func_globals
  864
+            return module.__dict__ is object.__globals__
865 865
         elif inspect.isclass(object):
866 866
             return module.__name__ == object.__module__
867 867
         elif inspect.getmodule(object) is not None:
@@ -926,7 +926,7 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
926 926
                 if isinstance(val, staticmethod):
927 927
                     val = getattr(obj, valname)
928 928
                 if isinstance(val, classmethod):
929  
-                    val = getattr(obj, valname).im_func
  929
+                    val = getattr(obj, valname).__func__
930 930
 
931 931
                 # Recurse to methods, properties, and nested classes.
932 932
                 if ((inspect.isfunction(val) or inspect.isclass(val) or
@@ -998,8 +998,8 @@ def _find_lineno(self, obj, source_lines):
998 998
                     break
999 999
 
1000 1000
         # 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__
1003 1003
         if inspect.istraceback(obj): obj = obj.tb_frame
1004 1004
         if inspect.isframe(obj): obj = obj.f_code
1005 1005
         if inspect.iscode(obj):

0 notes on commit f1d5dc8

Please sign in to comment.
Something went wrong with that request. Please try again.