Commit c5b25ce1 authored by Stefan Behnel's avatar Stefan Behnel

Restore the previous PyThreadState_Get() calls in the refnanny, but with a...

Restore the previous PyThreadState_Get() calls in the refnanny, but with a comment explaining the purpose of the "useless" calls.
parent 9d2ae85b
...@@ -84,6 +84,7 @@ cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except N ...@@ -84,6 +84,7 @@ cdef PyObject* SetupContext(char* funcname, int lineno, char* filename) except N
# like caching and resetting exceptions. # like caching and resetting exceptions.
return NULL return NULL
cdef (PyObject*) type = NULL, value = NULL, tb = NULL, result = NULL cdef (PyObject*) type = NULL, value = NULL, tb = NULL, result = NULL
PyThreadState_Get() # Check that we hold the GIL
PyErr_Fetch(&type, &value, &tb) PyErr_Fetch(&type, &value, &tb)
try: try:
ctx = Context(funcname, lineno, filename) ctx = Context(funcname, lineno, filename)
...@@ -132,19 +133,20 @@ cdef void GIVEREF(PyObject* ctx, PyObject* p_obj, int lineno): ...@@ -132,19 +133,20 @@ cdef void GIVEREF(PyObject* ctx, PyObject* p_obj, int lineno):
cdef void INCREF(PyObject* ctx, PyObject* obj, int lineno): cdef void INCREF(PyObject* ctx, PyObject* obj, int lineno):
Py_XINCREF(obj) Py_XINCREF(obj)
PyThreadState_Get() PyThreadState_Get() # Check that we hold the GIL
GOTREF(ctx, obj, lineno) GOTREF(ctx, obj, lineno)
cdef void DECREF(PyObject* ctx, PyObject* obj, int lineno): cdef void DECREF(PyObject* ctx, PyObject* obj, int lineno):
if GIVEREF_and_report(ctx, obj, lineno): if GIVEREF_and_report(ctx, obj, lineno):
Py_XDECREF(obj) Py_XDECREF(obj)
PyThreadState_Get() PyThreadState_Get() # Check that we hold the GIL
cdef void FinishContext(PyObject** ctx): cdef void FinishContext(PyObject** ctx):
if ctx == NULL or ctx[0] == NULL: return if ctx == NULL or ctx[0] == NULL: return
cdef (PyObject*) type = NULL, value = NULL, tb = NULL cdef (PyObject*) type = NULL, value = NULL, tb = NULL
cdef object errors = None cdef object errors = None
cdef Context context cdef Context context
PyThreadState_Get() # Check that we hold the GIL
PyErr_Fetch(&type, &value, &tb) PyErr_Fetch(&type, &value, &tb)
try: try:
context = <Context>ctx[0] context = <Context>ctx[0]
......
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