[Numpy-svn] r8288 - trunk/numpy/f2py
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Mar 6 18:59:55 EST 2010
Author: ptvirtan
Date: 2010-03-06 17:59:55 -0600 (Sat, 06 Mar 2010)
New Revision: 8288
Modified:
trunk/numpy/f2py/cfuncs.py
Log:
3K: f2py: make create_cb_arglist work with Py3 functions
Modified: trunk/numpy/f2py/cfuncs.py
===================================================================
--- trunk/numpy/f2py/cfuncs.py 2010-03-06 23:59:41 UTC (rev 8287)
+++ trunk/numpy/f2py/cfuncs.py 2010-03-06 23:59:55 UTC (rev 8288)
@@ -1032,14 +1032,24 @@
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 */
More information about the Numpy-svn
mailing list