[Scipy-svn] r6716 - trunk/scipy/interpolate/src

scipy-svn@scip... scipy-svn@scip...
Sat Sep 11 19:48:59 CDT 2010


Author: ptvirtan
Date: 2010-09-11 19:48:58 -0500 (Sat, 11 Sep 2010)
New Revision: 6716

Modified:
   trunk/scipy/interpolate/src/_fitpackmodule.c
   trunk/scipy/interpolate/src/_interpolate.cpp
   trunk/scipy/interpolate/src/multipack.h
Log:
3K: scipy.interpolate builds and passes most tests.

Modified: trunk/scipy/interpolate/src/_fitpackmodule.c
===================================================================
--- trunk/scipy/interpolate/src/_fitpackmodule.c	2010-09-12 00:48:43 UTC (rev 6715)
+++ trunk/scipy/interpolate/src/_fitpackmodule.c	2010-09-12 00:48:58 UTC (rev 6716)
@@ -46,6 +46,39 @@
 {NULL, NULL, 0, NULL}
 };
 
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "_fitpack",
+    NULL,
+    -1,
+    fitpack_module_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+
+PyObject *PyInit__fitpack(void)
+{
+    PyObject *m, *d, *s;
+
+    m = PyModule_Create(&moduledef);
+    import_array();
+
+    d = PyModule_GetDict(m);
+
+    s = PyUnicode_FromString(" 1.7 ");
+    PyDict_SetItemString(d, "__version__", s);
+    fitpack_error = PyErr_NewException ("fitpack.error", NULL, NULL);
+    Py_DECREF(s);
+    if (PyErr_Occurred()) {
+        Py_FatalError("can't initialize module fitpack");
+    }
+
+    return m;
+}
+#else
 PyMODINIT_FUNC init_fitpack(void) {
     PyObject *m, *d, *s;
     m = Py_InitModule("_fitpack", fitpack_module_methods);
@@ -60,3 +93,4 @@
         Py_FatalError("can't initialize module fitpack");
     }
 }
+#endif 

Modified: trunk/scipy/interpolate/src/_interpolate.cpp
===================================================================
--- trunk/scipy/interpolate/src/_interpolate.cpp	2010-09-12 00:48:43 UTC (rev 6715)
+++ trunk/scipy/interpolate/src/_interpolate.cpp	2010-09-12 00:48:58 UTC (rev 6716)
@@ -221,7 +221,29 @@
     {NULL, NULL, 0, NULL}
 };
 
+#if PY_VERSION_HEX >= 0x03000000
+static struct PyModuleDef moduledef = {
+    PyModuleDef_HEAD_INIT,
+    "_interpolate",
+    NULL,
+    -1,
+    interpolate_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
 
+PyObject *PyInit__interpolate(void)
+{
+    PyObject *m, *d, *s;
+
+    m = PyModule_Create(&moduledef);
+    import_array();
+
+    return m;
+}
+#else
 PyMODINIT_FUNC init_interpolate(void)
 {
     PyObject* m;
@@ -232,5 +254,5 @@
         return;
     import_array();
 }
-
+#endif
 } // extern "C"

Modified: trunk/scipy/interpolate/src/multipack.h
===================================================================
--- trunk/scipy/interpolate/src/multipack.h	2010-09-12 00:48:43 UTC (rev 6715)
+++ trunk/scipy/interpolate/src/multipack.h	2010-09-12 00:48:58 UTC (rev 6716)
@@ -31,6 +31,24 @@
 #include "Python.h"
 #include "numpy/arrayobject.h"
 
+#if PY_VERSION_HEX >= 0x03000000
+    #define PyString_AsString PyBytes_AsString
+    #define PyString_FromString PyBytes_FromString
+    #define PyString_ConcatAndDel PyBytes_ConcatAndDel
+
+    #define PyInt_AsLong PyLong_AsLong
+
+    /* Return True only if the long fits in a C long */
+    static NPY_INLINE int PyInt_Check(PyObject *op) {
+        int overflow = 0;
+        if (!PyLong_Check(op)) {
+            return 0;
+        }
+        PyLong_AsLongAndOverflow(op, &overflow);
+        return (overflow == 0);
+    }
+#endif
+
 #define PYERR(errobj,message) {PyErr_SetString(errobj,message); goto fail;}
 #define PYERR2(errobj,message) {PyErr_Print(); PyErr_SetString(errobj, message); goto fail;}
 #define ISCONTIGUOUS(m) ((m)->flags & CONTIGUOUS)



More information about the Scipy-svn mailing list