Commit 85d7fe69 authored by Robert Bradshaw's avatar Robert Bradshaw

Print refnanny errors rather than raise them.

parent 27f4b996
......@@ -1594,7 +1594,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln(" if (!__Pyx_Refnanny)")
code.putln(" Py_FatalError(\"failed to import refnanny module\");")
code.putln("}")
code.putln("__pyx_refchk = __Pyx_Refnanny->NewContext(\"%s\", __LINE__);"% header3)
code.putln("__pyx_refchk = __Pyx_Refnanny->NewContext(\"%s\", __LINE__, __FILE__);"% header3)
code.putln("#endif")
code.putln("%s = PyTuple_New(0); %s" % (Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos)));
......@@ -2338,7 +2338,7 @@ typedef struct {
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*NewContext)(const char*, int);
void* (*NewContext)(const char*, int, char*);
int (*FinishContext)(void**);
} __Pyx_RefnannyAPIStruct;
static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
......@@ -2350,7 +2350,7 @@ static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
#define __Pyx_GIVEREF(r) __Pyx_Refnanny->GIVEREF(__pyx_refchk, (PyObject *)(r), __LINE__)
#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
#define __Pyx_SetupRefcountContext(name) \
void* __pyx_refchk = __Pyx_Refnanny->NewContext((name), __LINE__)
void* __pyx_refchk = __Pyx_Refnanny->NewContext((name), __LINE__, __FILE__)
#define __Pyx_FinishRefcountContext() \
__Pyx_Refnanny->FinishContext(&__pyx_refchk)
#else
......
......@@ -15,7 +15,10 @@ class Error(Exception):
pass
class Context(object):
def __init__(self):
def __init__(self, name, line=0, filename=None):
self.name = name
self.start = line
self.filename = filename
self.refs = {} # id -> (count, [lineno])
self.errors = []
......@@ -57,11 +60,11 @@ class Context(object):
cdef PyObject* NewContext(char* funcname, int lineno) except NULL:
cdef PyObject* NewContext(char* funcname, int lineno, char* filename) except NULL:
cdef PyObject* type = NULL, *value = NULL, *tb = NULL
PyErr_Fetch(&type, &value, &tb)
try:
ctx = Context()
ctx = Context(funcname, lineno, filename)
PyErr_Restore(<object>type, <object>value, <object>tb)
Py_INCREF(ctx)
return <PyObject*>ctx
......@@ -120,6 +123,7 @@ cdef int FinishContext(PyObject** ctx) except -1:
PyErr_Fetch(&type, &value, &tb)
try:
errors = (<object>ctx[0]).end()
pos = (<object>ctx[0]).filename, (<object>ctx[0]).name
PyErr_Restore(<object>type, <object>value, <object>tb)
except:
Py_XDECREF(<object>type)
......@@ -130,7 +134,8 @@ cdef int FinishContext(PyObject** ctx) except -1:
Py_XDECREF(<object>ctx[0])
ctx[0] = NULL
if errors:
raise Error(errors)
print "%s: %s()" % pos
print errors # raise Error(errors)
return 0
......@@ -144,7 +149,7 @@ ctypedef struct RefnannyAPIStruct:
void (*DECREF)(PyObject*, PyObject*, int)
void (*GOTREF)(PyObject*, PyObject*, int)
void (*GIVEREF)(PyObject*, PyObject*, int)
PyObject* (*NewContext)(char*, int) except NULL
PyObject* (*NewContext)(char*, int, char*) except NULL
int (*FinishContext)(PyObject**) except -1
cdef RefnannyAPIStruct api
......
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