8000 2to3: Apply `methodattrs` fixes. · numpy/numpy@0a5746d · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a5746d

Browse files
committed
2to3: Apply methodattrs fixes.
Replaces old style `f.im_func` and `f.im_class` method attributes with `f.__func__` and `f.__class__`. Closes #3070.
1 parent 02cfcb9 commit 0a5746d

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

numpy/compat/_inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def getargspec(func):
125125
"""
126126

127127
if ismethod(func):
128-
func = func.im_func
128+
func = func.__func__
129129
if not isfunction(func):
130130
raise TypeError('arg is not a Python function')
131131
args, varargs, varkw = getargs(func.__code__)

numpy/distutils/mingw32ccompiler.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ def link(self,
199199
func = distutils.cygwinccompiler.CygwinCCompiler.link
200200
else:
201201
func = UnixCCompiler.link
202-
if sys.version_info[0] >= 3:
203-
func(*args[:func.__code__.co_argcount])
204-
else:
205-
func(*args[:func.im_func.__code__.co_argcount])
202+
func(*args[:func.__code__.co_argcount])
206203
return
207204

208205
def object_filenames (self,

numpy/lib/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
557557
arguments = "()"
558558
try:
559559
if hasattr(object, '__init__'):
560-
arguments = inspect.formatargspec(*inspect.getargspec(object.__init__.im_func))
560+
arguments = inspect.formatargspec(*inspect.getargspec(object.__init__.__func__))
561561
arglist = arguments.split(', ')
562562
if len(arglist) > 1:
563563
arglist[1] = "("+arglist[1]
@@ -593,7 +593,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
593593
print >> output, "Instance of class: ", object.__class__.__name__
594594
print >> output
595595
if hasattr(object, '__call__'):
596-
arguments = inspect.formatargspec(*inspect.getargspec(object.__call__.im_func))
596+
arguments = inspect.formatargspec(*inspect.getargspec(object.__call__.__func__))
597597
arglist = arguments.split(', ')
598598
if len(arglist) > 1:
599599
arglist[1] = "("+arglist[1]
@@ -621,7 +621,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
621621

622622
elif inspect.ismethod(object):
623623
name = object.__name__
624-
arguments = inspect.formatargspec(*inspect.getargspec(object.im_func))
624+
arguments = inspect.formatargspec(*inspect.getargspec(object.__func__))
625625
arglist = arguments.split(', ')
626626
if len(arglist) > 1:
627627
arglist[1] = "("+arglist[1]

numpy/testing/noseclasses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _from_module(self, module, object):
4848
# to make by extension code writers, having this safety in place
4949
# isn't such a bad idea
5050
#print '_fm C3-1' # dbg
51-
return module.__name__ == object.im_class.__module__
51+
return module.__name__ == object.__self__.__class__.__module__
5252
elif inspect.getmodule(object) is not None:
5353
#print '_fm C4' # dbg
5454
#print 'C4 mod',module,'obj',object # dbg
@@ -100,7 +100,7 @@ def _find(self, tests, obj, name, module, source_lines, globs, seen):
100100
if isinstance(val, staticmethod):
101101
val = getattr(obj, valname)
102102
if isinstance(val, classmethod):
103-
val = getattr(obj, valname).im_func
103+
val = getattr(obj, valname).__func__
104104

105105
# Recurse to methods, properties, and nested classes.
106106
if ((isfunction(val) or isclass(val) or

0 commit comments

Comments
 (0)
0