diff options
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r-- | numpy/lib/utils.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index dc6c16767..2e70bfd15 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1,3 +1,5 @@ +from __future__ import division + import os import sys import types @@ -86,8 +88,8 @@ if sys.version_info < (2, 4): # Can't set __name__ in 2.3 import new def _set_function_name(func, name): - func = new.function(func.func_code, func.func_globals, - name, func.func_defaults, func.func_closure) + func = new.function(func.__code__, func.__globals__, + name, func.__defaults__, func.__closure__) return func else: def _set_function_name(func, name): @@ -122,7 +124,7 @@ class _Deprecate(object): import warnings if old_name is None: try: - old_name = func.func_name + old_name = func.__name__ except AttributeError: old_name = func.__name__ if new_name is None: @@ -541,7 +543,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'): print >> output, "\n *** Total of %d references found. ***" % numfound elif inspect.isfunction(object): - name = object.func_name + name = object.__name__ arguments = inspect.formatargspec(*inspect.getargspec(object)) if len(name+arguments) > maxwidth: @@ -557,7 +559,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'): arguments = "()" try: if hasattr(object, '__init__'): - arguments = inspect.formatargspec(*inspect.getargspec(object.__init__.im_func)) + arguments = inspect.formatargspec(*inspect.getargspec(object.__init__.__func__)) arglist = arguments.split(', ') if len(arglist) > 1: arglist[1] = "("+arglist[1] @@ -593,7 +595,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'): print >> output, "Instance of class: ", object.__class__.__name__ print >> output if hasattr(object, '__call__'): - arguments = inspect.formatargspec(*inspect.getargspec(object.__call__.im_func)) + arguments = inspect.formatargspec(*inspect.getargspec(object.__call__.__func__)) arglist = arguments.split(', ') if len(arglist) > 1: arglist[1] = "("+arglist[1] @@ -621,7 +623,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'): elif inspect.ismethod(object): name = object.__name__ - arguments = inspect.formatargspec(*inspect.getargspec(object.im_func)) + arguments = inspect.formatargspec(*inspect.getargspec(object.__func__)) arglist = arguments.split(', ') if len(arglist) > 1: arglist[1] = "("+arglist[1] @@ -1154,11 +1156,11 @@ def safe_eval(source): walker = SafeEval() try: ast = compiler.parse(source, mode="eval") - except SyntaxError, err: + except SyntaxError as err: raise try: return walker.visit(ast) - except SyntaxError, err: + except SyntaxError as err: raise #----------------------------------------------------------------------------- |