Commit f85c0c4e authored by Robert Bradshaw's avatar Robert Bradshaw

Refnanny unraisable fix.

parent 9cefe905
...@@ -59,8 +59,11 @@ class Context(object): ...@@ -59,8 +59,11 @@ class Context(object):
else: else:
return None return None
cdef void report_unraisable(object e): cdef void report_unraisable(object e=None):
try: try:
if e is None:
import sys
e = sys.exc_info()[1]
print u"refnanny raised an exception: %s" % e print u"refnanny raised an exception: %s" % e
except: except:
pass # We absolutely cannot exit with an exception pass # We absolutely cannot exit with an exception
...@@ -97,8 +100,8 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno): ...@@ -97,8 +100,8 @@ cdef void GOTREF(PyObject* ctx, PyObject* p_obj, int lineno):
(<object>ctx).regref(None, lineno, True) (<object>ctx).regref(None, lineno, True)
else: else:
(<object>ctx).regref(<object>p_obj, lineno, False) (<object>ctx).regref(<object>p_obj, lineno, False)
except object, e: except:
report_unraisable(e) report_unraisable()
except: except:
# __Pyx_GetException may itself raise errors # __Pyx_GetException may itself raise errors
pass pass
...@@ -115,8 +118,8 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno): ...@@ -115,8 +118,8 @@ cdef int GIVEREF_and_report(PyObject* ctx, PyObject* p_obj, int lineno):
decref_ok = (<object>ctx).delref(None, lineno, True) decref_ok = (<object>ctx).delref(None, lineno, True)
else: else:
decref_ok = (<object>ctx).delref(<object>p_obj, lineno, False) decref_ok = (<object>ctx).delref(<object>p_obj, lineno, False)
except object, e: except:
report_unraisable(e) report_unraisable()
except: except:
# __Pyx_GetException may itself raise errors # __Pyx_GetException may itself raise errors
pass pass
...@@ -146,8 +149,8 @@ cdef void FinishContext(PyObject** ctx): ...@@ -146,8 +149,8 @@ cdef void FinishContext(PyObject** ctx):
if errors: if errors:
print u"%s: %s()" % pos print u"%s: %s()" % pos
print errors print errors
except Exception, e: except:
report_unraisable(e) report_unraisable()
except: except:
# __Pyx_GetException may itself raise errors # __Pyx_GetException may itself raise errors
pass pass
......
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