From fd14ceea624450fe4d66099f59e45a9a60307fe7 Mon Sep 17 00:00:00 2001
From: Dag Sverre Seljebotn <dagss@student.matnat.uio.no>
Date: Sat, 21 Feb 2009 15:43:17 +0100
Subject: [PATCH] refnanny: Do Python operations exception-safely in
 refnanny.pyx

---
 Cython/Runtime/refnanny.pyx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Cython/Runtime/refnanny.pyx b/Cython/Runtime/refnanny.pyx
index b3b3991ce..2f698e401 100644
--- a/Cython/Runtime/refnanny.pyx
+++ b/Cython/Runtime/refnanny.pyx
@@ -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*))
-- 
2.30.9