diff options
Diffstat (limited to 'numpy/f2py/cfuncs.py')
-rw-r--r-- | numpy/f2py/cfuncs.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index 74a0ab363..a6b1c933d 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -1032,14 +1032,24 @@ if (tmp_fun==NULL) { fprintf(stderr,\"Call-back argument must be function|instance|instance.__call__|f2py-function but got %s.\\n\",(fun==NULL?\"NULL\":Py_TYPE(fun)->tp_name)); goto capi_fail; } +#if PY_VERSION_HEX >= 0x03000000 +\tif (PyObject_HasAttrString(tmp_fun,\"__code__\")) { +\t\tif (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\"__code__\"),\"co_argcount\")) +#else \tif (PyObject_HasAttrString(tmp_fun,\"func_code\")) { \t\tif (PyObject_HasAttrString(tmp = PyObject_GetAttrString(tmp_fun,\"func_code\"),\"co_argcount\")) +#endif \t\t\ttot = PyInt_AsLong(PyObject_GetAttrString(tmp,\"co_argcount\")) - di; \t\tPy_XDECREF(tmp); \t} \t/* Get the number of optional arguments */ +#if PY_VERSION_HEX >= 0x03000000 +\tif (PyObject_HasAttrString(tmp_fun,\"__defaults__\")) +\t\tif (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\"__defaults__\"))) +#else \tif (PyObject_HasAttrString(tmp_fun,\"func_defaults\")) \t\tif (PyTuple_Check(tmp = PyObject_GetAttrString(tmp_fun,\"func_defaults\"))) +#endif \t\t\topt = PyTuple_Size(tmp); \t\tPy_XDECREF(tmp); \t/* Get the number of extra arguments */ |