Commit 28385b16 authored by Lisandro Dalcin's avatar Lisandro Dalcin

remove those 'Refnanny' prefixes in refnanny.pyx

parent df2ad2f0
...@@ -11,10 +11,10 @@ cdef log(level, action, obj, lineno): ...@@ -11,10 +11,10 @@ cdef log(level, action, obj, lineno):
LOG_NONE, LOG_ALL = range(2) LOG_NONE, LOG_ALL = range(2)
class RefnannyException(Exception): class Error(Exception):
pass pass
class RefnannyContext(object): class Context(object):
def __init__(self): def __init__(self):
self.refs = {} # id -> (count, [lineno]) self.refs = {} # id -> (count, [lineno])
self.errors = [] self.errors = []
...@@ -52,17 +52,17 @@ class RefnannyContext(object): ...@@ -52,17 +52,17 @@ class RefnannyContext(object):
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 Error("\n".join(self.errors))
cdef void* Refnanny_NewContext(char* funcname, int lineno) except NULL: cdef void* NewContext(char* funcname, int lineno) except NULL:
if exc.PyErr_Occurred() != NULL: if exc.PyErr_Occurred() != NULL:
print "error flag set on newcontext?" print "error flag set on newcontext?"
return NULL return NULL
ctx = RefnannyContext() ctx = Context()
Py_INCREF(ctx) Py_INCREF(ctx)
return <void*>ctx return <void*>ctx
cdef void Refnanny_GOTREF(void* ctx, void* p_obj, int lineno): cdef void GOTREF(void* ctx, void* p_obj, int lineno):
cdef exc.PyObject* type = NULL, *value = NULL, *tb = NULL cdef exc.PyObject* type = NULL, *value = NULL, *tb = NULL
if ctx == NULL: return if ctx == NULL: return
exc.PyErr_Fetch(&type, &value, &tb) exc.PyErr_Fetch(&type, &value, &tb)
...@@ -78,7 +78,7 @@ cdef void Refnanny_GOTREF(void* ctx, void* p_obj, int lineno): ...@@ -78,7 +78,7 @@ cdef void Refnanny_GOTREF(void* ctx, void* p_obj, int lineno):
Py_XDECREF(<object>tb) Py_XDECREF(<object>tb)
raise raise
cdef void Refnanny_GIVEREF(void* ctx, void* p_obj, int lineno): cdef void GIVEREF(void* ctx, void* p_obj, int lineno):
cdef exc.PyObject* type = NULL, *value = NULL, *tb = NULL cdef exc.PyObject* type = NULL, *value = NULL, *tb = NULL
if ctx == NULL: return if ctx == NULL: return
exc.PyErr_Fetch(&type, &value, &tb) exc.PyErr_Fetch(&type, &value, &tb)
...@@ -94,16 +94,16 @@ cdef void Refnanny_GIVEREF(void* ctx, void* p_obj, int lineno): ...@@ -94,16 +94,16 @@ cdef void Refnanny_GIVEREF(void* ctx, void* p_obj, int lineno):
Py_XDECREF(<object>tb) Py_XDECREF(<object>tb)
raise raise
cdef void Refnanny_INCREF(void* ctx, void* obj, int lineno): cdef void INCREF(void* ctx, void* obj, int lineno):
if obj is not NULL: Py_INCREF(<object>obj) if obj is not NULL: Py_INCREF(<object>obj)
Refnanny_GOTREF(ctx, obj, lineno) GOTREF(ctx, obj, lineno)
cdef void Refnanny_DECREF(void* ctx, void* obj, int lineno): cdef void DECREF(void* ctx, void* obj, int lineno):
# GIVEREF raises exception if we hit 0 # GIVEREF raises exception if we hit 0
Refnanny_GIVEREF(ctx, obj, lineno) GIVEREF(ctx, obj, lineno)
if obj is not NULL: Py_DECREF(<object>obj) if obj is not NULL: Py_DECREF(<object>obj)
cdef int Refnanny_FinishContext(void* ctx) except -1: cdef int FinishContext(void* ctx) except -1:
cdef exc.PyObject* type = NULL, *value = NULL, *tb = NULL cdef exc.PyObject* type = NULL, *value = NULL, *tb = NULL
if ctx == NULL: if ctx == NULL:
assert False assert False
...@@ -136,11 +136,11 @@ ctypedef struct RefnannyAPIStruct: ...@@ -136,11 +136,11 @@ ctypedef struct RefnannyAPIStruct:
int (*FinishContext)(void*) except -1 int (*FinishContext)(void*) except -1
cdef RefnannyAPIStruct api cdef RefnannyAPIStruct api
api.INCREF = Refnanny_INCREF api.INCREF = INCREF
api.DECREF = Refnanny_DECREF api.DECREF = DECREF
api.GOTREF = Refnanny_GOTREF api.GOTREF = GOTREF
api.GIVEREF = Refnanny_GIVEREF api.GIVEREF = GIVEREF
api.NewContext = Refnanny_NewContext api.NewContext = NewContext
api.FinishContext = Refnanny_FinishContext api.FinishContext = FinishContext
RefnannyAPI = PyCObject_FromVoidPtr(&api, NULL) RefnannyAPI = PyCObject_FromVoidPtr(&api, NULL)
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