Commit 237050b4 authored by robertwb's avatar robertwb

Merge pull request #56 from markflorisson88/master

Acquire the GIL to build the traceback in nogil functions
parents 359ba798 5de6eb59
...@@ -1456,7 +1456,16 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1456,7 +1456,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