Commit fd14ceea authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

refnanny: Do Python operations exception-safely in refnanny.pyx

parent d01287ad
...@@ -124,6 +124,9 @@ cdef void FinishContext(PyObject** ctx): ...@@ -124,6 +124,9 @@ cdef void FinishContext(PyObject** ctx):
try: try:
errors = (<object>ctx[0]).end() errors = (<object>ctx[0]).end()
pos = (<object>ctx[0]).filename, (<object>ctx[0]).name 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) PyErr_Restore(<object>type, <object>value, <object>tb)
except: except:
Py_XDECREF(<object>type) Py_XDECREF(<object>type)
...@@ -132,9 +135,6 @@ cdef void FinishContext(PyObject** ctx): ...@@ -132,9 +135,6 @@ cdef void FinishContext(PyObject** ctx):
finally: finally:
Py_XDECREF(<object>ctx[0]) Py_XDECREF(<object>ctx[0])
ctx[0] = NULL ctx[0] = NULL
if errors:
print u"%s: %s()" % pos
print errors # raise Error(errors)
cdef extern from "Python.h": cdef extern from "Python.h":
object PyCObject_FromVoidPtr(void*, void (*)(void*)) object PyCObject_FromVoidPtr(void*, void (*)(void*))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment