Commit 3bdab41f authored by Mark Florisson's avatar Mark Florisson

Acquire the GIL in nogil functions to build the traceback

--HG--
extra : transplant_source : %B7Vz%D9%E7%DB%81%D5R%DA%91%FC%01%AA%7B%91%91%D6%FD%93
parent 8d1f3cb6
...@@ -1457,7 +1457,16 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1457,7 +1457,16 @@ class FuncDefNode(StatNode, BlockNode):
# TODO: Fix exception tracing (though currently unused by cProfile). # TODO: Fix exception tracing (though currently unused by cProfile).
# code.globalstate.use_utility_code(get_exception_tuple_utility_code) # code.globalstate.use_utility_code(get_exception_tuple_utility_code)
# code.put_trace_exception() # code.put_trace_exception()
if lenv.nogil:
code.putln("{")
code.put_ensure_gil()
code.put_add_traceback(self.entry.qualified_name) code.put_add_traceback(self.entry.qualified_name)
if lenv.nogil:
code.put_release_ensured_gil()
code.putln("}")
else: else:
warning(self.entry.pos, "Unraisable exception in function '%s'." \ warning(self.entry.pos, "Unraisable exception in function '%s'." \
% self.entry.qualified_name, 0) % self.entry.qualified_name, 0)
......
...@@ -19,3 +19,19 @@ cdef int g(int x) nogil: ...@@ -19,3 +19,19 @@ cdef int g(int x) nogil:
cdef int y cdef int y
y = x + 42 y = x + 42
return y 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