Commit 5be59c3c authored by Lisandro Dalcin's avatar Lisandro Dalcin

cleanup unused exception class and some fixes for better runtime behavior in...

cleanup unused exception class and some fixes for better runtime behavior in refnanny support module
parent 36fb323a
...@@ -11,9 +11,6 @@ cdef log(level, action, obj, lineno): ...@@ -11,9 +11,6 @@ cdef log(level, action, obj, lineno):
LOG_NONE, LOG_ALL = range(2) LOG_NONE, LOG_ALL = range(2)
class Error(Exception):
pass
class Context(object): class Context(object):
def __init__(self, name, line=0, filename=None): def __init__(self, name, line=0, filename=None):
self.name = name self.name = name
...@@ -91,8 +88,8 @@ cdef PyObject* NewContext(char* funcname, int lineno, char* filename) except NUL ...@@ -91,8 +88,8 @@ cdef PyObject* NewContext(char* funcname, int lineno, char* filename) except NUL
return result return result
cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
cdef PyObject* type = NULL, *value = NULL, *tb = NULL
if ctx == NULL: return if ctx == NULL: return
cdef PyObject* type = NULL, *value = NULL, *tb = NULL
PyErr_Fetch(&type, &value, &tb) PyErr_Fetch(&type, &value, &tb)
try: try:
if p_obj is NULL: if p_obj is NULL:
...@@ -104,11 +101,11 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): ...@@ -104,11 +101,11 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
PyErr_Restore(<object>type, <object>value, <object>tb) PyErr_Restore(<object>type, <object>value, <object>tb)
cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno):
if ctx == NULL: return 1
cdef PyObject* type = NULL, *value = NULL, *tb = NULL cdef PyObject* type = NULL, *value = NULL, *tb = NULL
cdef bint decref_ok = False cdef bint decref_ok = False
PyErr_Fetch(&type, &value, &tb) PyErr_Fetch(&type, &value, &tb)
try: try:
assert ctx is not NULL, "ctx us NULL"
if p_obj is NULL: if p_obj is NULL:
decref_ok = (<object>ctx).delref(None, lineno, True) decref_ok = (<object>ctx).delref(None, lineno, True)
else: else:
...@@ -130,9 +127,7 @@ cdef void DECREF(PyObject* ctx, PyObject* obj, int lineno): ...@@ -130,9 +127,7 @@ cdef void DECREF(PyObject* ctx, PyObject* obj, int lineno):
if obj is not NULL: Py_DECREF(<object>obj) if obj is not NULL: Py_DECREF(<object>obj)
cdef void FinishContext(PyObject** ctx): cdef void FinishContext(PyObject** ctx):
if ctx == NULL or ctx[0] == NULL: if ctx == NULL or ctx[0] == NULL: return
# We should have reported an error earlier.
return
cdef PyObject* type = NULL, *value = NULL, *tb = NULL cdef PyObject* type = NULL, *value = NULL, *tb = NULL
cdef object errors = None cdef object errors = None
PyErr_Fetch(&type, &value, &tb) PyErr_Fetch(&type, &value, &tb)
...@@ -144,7 +139,7 @@ cdef void FinishContext(PyObject** ctx): ...@@ -144,7 +139,7 @@ cdef void FinishContext(PyObject** ctx):
print errors print errors
except Exception, e: except Exception, e:
report_unraisable(e) report_unraisable(e)
Py_XDECREF(<object>ctx[0]) Py_DECREF(<object>ctx[0])
ctx[0] = NULL ctx[0] = NULL
PyErr_Restore(<object>type, <object>value, <object>tb) PyErr_Restore(<object>type, <object>value, <object>tb)
......
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