refnanny: Do Python operations exception-safely in refnanny.pyx
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 21 Feb 2009 14:43:17 +0000 (15:43 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Sat, 21 Feb 2009 14:43:17 +0000 (15:43 +0100)
Cython/Runtime/refnanny.pyx

index b3b3991ce6229cd407d22e406ca90acd39e59053..2f698e40173770ff1aafd313425c7b4036f0abd2 100644 (file)
@@ -124,6 +124,9 @@ cdef void FinishContext(PyObject** ctx):
     try:
         errors = (<object>ctx[0]).end()
         pos = (<object>ctx[0]).filename, (<object>ctx[0]).name
+        if errors:
+            print u"%s: %s()" % pos
+            print errors # raise Error(errors)
         PyErr_Restore(<object>type, <object>value, <object>tb)
     except:
         Py_XDECREF(<object>type)
@@ -132,9 +135,6 @@ cdef void FinishContext(PyObject** ctx):
     finally:
         Py_XDECREF(<object>ctx[0])
         ctx[0] = NULL
-    if errors:
-        print u"%s: %s()" % pos
-        print errors # raise Error(errors)
 
 cdef extern from "Python.h":
     object PyCObject_FromVoidPtr(void*, void (*)(void*))