From: Robert Bradshaw Date: Thu, 11 Mar 2010 20:37:38 +0000 (-0800) Subject: Get rid of unraisable warnings in the refnanny. X-Git-Tag: 0.13.beta0~319^2~2^2~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9cefe9056a631a1c1d83c84b093e01b3bbc221ae;p=cython.git Get rid of unraisable warnings in the refnanny. --- diff --git a/Cython/Runtime/refnanny.pyx b/Cython/Runtime/refnanny.pyx index a7af2535..43943aec 100644 --- a/Cython/Runtime/refnanny.pyx +++ b/Cython/Runtime/refnanny.pyx @@ -92,12 +92,16 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): cdef PyObject* type = NULL, *value = NULL, *tb = NULL PyErr_Fetch(&type, &value, &tb) try: - if p_obj is NULL: - (ctx).regref(None, lineno, True) - else: - (ctx).regref(p_obj, lineno, False) - except Exception, e: - report_unraisable(e) + try: + if p_obj is NULL: + (ctx).regref(None, lineno, True) + else: + (ctx).regref(p_obj, lineno, False) + except object, e: + report_unraisable(e) + except: + # __Pyx_GetException may itself raise errors + pass PyErr_Restore(type, value, tb) cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): @@ -106,12 +110,16 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): cdef bint decref_ok = False PyErr_Fetch(&type, &value, &tb) try: - if p_obj is NULL: - decref_ok = (ctx).delref(None, lineno, True) - else: - decref_ok = (ctx).delref(p_obj, lineno, False) - except Exception, e: - report_unraisable(e) + try: + if p_obj is NULL: + decref_ok = (ctx).delref(None, lineno, True) + else: + decref_ok = (ctx).delref(p_obj, lineno, False) + except object, e: + report_unraisable(e) + except: + # __Pyx_GetException may itself raise errors + pass PyErr_Restore(type, value, tb) return decref_ok @@ -132,13 +140,17 @@ cdef void FinishContext(PyObject** ctx): cdef object errors = None PyErr_Fetch(&type, &value, &tb) try: - errors = (ctx[0]).end() - pos = (ctx[0]).filename, (ctx[0]).name - if errors: - print u"%s: %s()" % pos - print errors - except Exception, e: - report_unraisable(e) + try: + errors = (ctx[0]).end() + pos = (ctx[0]).filename, (ctx[0]).name + if errors: + print u"%s: %s()" % pos + print errors + except Exception, e: + report_unraisable(e) + except: + # __Pyx_GetException may itself raise errors + pass Py_DECREF(ctx[0]) ctx[0] = NULL PyErr_Restore(type, value, tb)