From 0f2e7db0da927cc3007e37c88abd03c6be2dd255 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 20 Feb 2010 18:17:14 +0000 Subject: 3K: lib: fix some bytes vs. str issues in _iotools.py and io.py -- mainly genfromtxt --- numpy/lib/function_base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'numpy/lib/function_base.py') diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index a1f7102df..17b254d82 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -13,6 +13,7 @@ __all__ = ['select', 'piecewise', 'trim_zeros', import warnings import types +import sys import numpy.core.numeric as _nx from numpy.core import linspace from numpy.core.numeric import ones, zeros, arange, concatenate, array, \ @@ -1596,7 +1597,18 @@ import re def _get_nargs(obj): if not callable(obj): raise TypeError, "Object is not callable." - if hasattr(obj,'func_code'): + if sys.version_info[0] >= 3: + import inspect + spec = inspect.getargspec(obj) + nargs = len(spec.args) + if spec.defaults: + ndefaults = len(spec.defaults) + else: + ndefaults = 0 + if inspect.ismethod(obj): + nargs -= 1 + return nargs, ndefaults + elif hasattr(obj,'func_code'): fcode = obj.func_code nargs = fcode.co_argcount if obj.func_defaults is not None: -- cgit v1.2.1