Commit 5de6eb59 authored by Mark Florisson's avatar Mark Florisson

Acquire the GIL in nogil functions to build the traceback

parent 9d91a4ea
......@@ -1456,7 +1456,16 @@ class FuncDefNode(StatNode, BlockNode):
# TODO: Fix exception tracing (though currently unused by cProfile).
# code.globalstate.use_utility_code(get_exception_tuple_utility_code)
# code.put_trace_exception()
if lenv.nogil:
code.putln("{")
code.put_ensure_gil()
code.put_add_traceback(self.entry.qualified_name)
if lenv.nogil:
code.put_release_ensured_gil()
code.putln("}")
else:
warning(self.entry.pos, "Unraisable exception in function '%s'." \
% self.entry.qualified_name, 0)
......
......@@ -19,3 +19,19 @@ cdef int g(int x) nogil:
cdef int y
y = x + 42
return y
cdef int with_gil_func() except 0 with gil:
raise Exception("error!")
cdef int nogil_func() nogil except 0:
with_gil_func()
def test_nogil_exception_propagation():
"""
>>> test_nogil_exception_propagation()
Traceback (most recent call last):
...
Exception: error!
"""
with nogil:
nogil_func()
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