Commit 2e6bce73 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

refnanny

parent 05b93dae
...@@ -45,21 +45,30 @@ class RefnannyContext(object): ...@@ -45,21 +45,30 @@ class RefnannyContext(object):
msg += "\n Acquired on lines: " + ", ".join(["%d" % x for x in linenos]) msg += "\n Acquired on lines: " + ", ".join(["%d" % x for x in linenos])
self.errors.append("References leaked: %s" % msg) self.errors.append("References leaked: %s" % msg)
if self.errors: if self.errors:
print self.errors # print self.errors
# raise RefnannyException("\n".join(self.errors)) raise RefnannyException("\n".join(self.errors))
cdef public void* __Pyx_Refnanny_NewContext(char* funcname, int lineno) except NULL: cdef public void* __Pyx_Refnanny_NewContext(char* funcname, int lineno) except NULL:
if exc.PyErr_Occurred() != NULL:
print "error flag set on newcontext?"
return NULL
ctx = RefnannyContext() ctx = RefnannyContext()
Py_INCREF(ctx) Py_INCREF(ctx)
return <void*>ctx return <void*>ctx
cdef public void __Pyx_Refnanny_GOTREF(void* ctx, object obj, int lineno): cdef public void __Pyx_Refnanny_GOTREF(void* ctx, object obj, int lineno):
cdef exc.PyObject* type, *value, *tb
if ctx == NULL: return if ctx == NULL: return
exc.PyErr_Fetch(&type, &value, &tb)
(<object>ctx).regref(obj, lineno) (<object>ctx).regref(obj, lineno)
exc.PyErr_Restore(<object>type, <object>value, <object>tb)
cdef public void __Pyx_Refnanny_GIVEREF(void* ctx, object obj, int lineno): cdef public void __Pyx_Refnanny_GIVEREF(void* ctx, object obj, int lineno):
cdef exc.PyObject* type, *value, *tb
if ctx == NULL: return if ctx == NULL: return
exc.PyErr_Fetch(&type, &value, &tb)
(<object>ctx).delref(obj, lineno) (<object>ctx).delref(obj, lineno)
exc.PyErr_Restore(<object>type, <object>value, <object>tb)
cdef public void __Pyx_Refnanny_INCREF(void* ctx, object obj, int lineno): cdef public void __Pyx_Refnanny_INCREF(void* ctx, object obj, int lineno):
Py_INCREF(obj) Py_INCREF(obj)
...@@ -72,17 +81,16 @@ cdef public void __Pyx_Refnanny_DECREF(void* ctx, object obj, int lineno): ...@@ -72,17 +81,16 @@ cdef public void __Pyx_Refnanny_DECREF(void* ctx, object obj, int lineno):
Py_DECREF(obj) Py_DECREF(obj)
cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1: cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1:
# cdef exc.PyObject* type, *value, *tb cdef exc.PyObject* type, *value, *tb
## if exc.PyErr_Occurred(): if ctx == NULL:
## exc.PyErr_Fetch(&type, &value, &tb) assert False
## Py_XDECREF(<object>type); Py_XDECREF(<object>value); Py_XDECREF(<object>tb) exc.PyErr_Fetch(&type, &value, &tb)
## print "cleared!"
## print (exc.PyErr_Occurred() == NULL)
obj = <object>ctx obj = <object>ctx
try: try:
obj.end() obj.end()
finally: finally:
Py_DECREF(obj) Py_DECREF(obj)
exc.PyErr_Restore(<object>type, <object>value, <object>tb)
return 0 return 0
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