From: Robert Bradshaw Date: Thu, 11 Mar 2010 22:06:15 +0000 (-0800) Subject: Refnanny unraisable fix. X-Git-Tag: 0.13.beta0~319^2~2^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f85c0c4e8301760b69ddefbfdc4286a1a29c4b90;p=cython.git Refnanny unraisable fix. --- diff --git a/Cython/Runtime/refnanny.pyx b/Cython/Runtime/refnanny.pyx index 43943aec..4e6c67bf 100644 --- a/Cython/Runtime/refnanny.pyx +++ b/Cython/Runtime/refnanny.pyx @@ -59,8 +59,11 @@ class Context(object): else: return None -cdef void report_unraisable(object e): +cdef void report_unraisable(object e=None): try: + if e is None: + import sys + e = sys.exc_info()[1] print u"refnanny raised an exception: %s" % e except: pass # We absolutely cannot exit with an exception @@ -97,8 +100,8 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): (ctx).regref(None, lineno, True) else: (ctx).regref(p_obj, lineno, False) - except object, e: - report_unraisable(e) + except: + report_unraisable() except: # __Pyx_GetException may itself raise errors pass @@ -115,8 +118,8 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): decref_ok = (ctx).delref(None, lineno, True) else: decref_ok = (ctx).delref(p_obj, lineno, False) - except object, e: - report_unraisable(e) + except: + report_unraisable() except: # __Pyx_GetException may itself raise errors pass @@ -146,8 +149,8 @@ cdef void FinishContext(PyObject** ctx): if errors: print u"%s: %s()" % pos print errors - except Exception, e: - report_unraisable(e) + except: + report_unraisable() except: # __Pyx_GetException may itself raise errors pass