Re-enable __index__ for Py_ssize_t, fix refcount error in that function
authorRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 01:46:51 +0000 (18:46 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Thu, 1 Nov 2007 01:46:51 +0000 (18:46 -0700)
Cython/Compiler/Nodes.py
Cython/Compiler/PyrexTypes.py

index 00082716e58dfed99841b1c28a7e093519957043..da668aa2ae08262ccada9ac19621e5e09006f04c 100644 (file)
@@ -2934,7 +2934,14 @@ utility_function_predeclarations = \
 typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
 typedef struct {PyObject **p; char *s; long n; int is_unicode;} __Pyx_StringTabEntry; /*proto*/
 
-#define __pyx_PyIndex_AsSsize_t(b) PyInt_AsSsize_t(PyNumber_Index(b))
+static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject* x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
 
 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
 static INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
index f5067241ff6769c1d37249be2d2b960645d12bb6..3874474e0bf1ed7db2ba7fb03c1e4c36a1c69073 100644 (file)
@@ -417,7 +417,7 @@ class CULongLongType(CUIntType):
 class CPySSizeTType(CIntType):
 
     to_py_function = "PyInt_FromSsize_t"
-    from_py_function = "PyInt_AsSsize_t"
+    from_py_function = "__pyx_PyIndex_AsSsize_t"
 
 
 class CFloatType(CNumericType):