summaryrefslogtreecommitdiff
path: root/numpy/f2py/cfuncs.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2010-03-06 23:59:55 +0000
committerPauli Virtanen <pav@iki.fi>2010-03-06 23:59:55 +0000
commitdc9621d502c87ea78e1e68212724eb9ffcc2037c (patch)
treea6bbedfb4cae1745f5c685d01eb9f84cba797444 /numpy/f2py/cfuncs.py
parent11ff8356427c9f04968869c1caf75f09eff8bb79 (diff)
downloadnumpy-dc9621d502c87ea78e1e68212724eb9ffcc2037c.tar.gz
3K: f2py: make create_cb_arglist work with Py3 functions
Diffstat (limited to 'numpy/f2py/cfuncs.py')
-rw-r--r--numpy/f2py/cfuncs.py10
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 */