Commit 2d8f7f35 authored by Stefan Behnel's avatar Stefan Behnel

Guard the local variable cleanup in nogil functions with 'with gil' sections with the GIL.

Closes https://github.com/cython/cython/issues/3590
parent c47bceca
......@@ -2146,8 +2146,9 @@ class FuncDefNode(StatNode, BlockNode):
if entry.type.is_pyobject:
if entry.is_arg and not entry.cf_is_reassigned:
continue
assure_gil('success')
# FIXME ideally use entry.xdecref_cleanup but this currently isn't reliable
code.put_var_xdecref(entry, have_gil=not lenv.nogil)
code.put_var_xdecref(entry, have_gil=gil_owned['success'])
# Decref any increfed args
for entry in lenv.arg_entries:
......@@ -2163,7 +2164,7 @@ class FuncDefNode(StatNode, BlockNode):
continue
# FIXME use entry.xdecref_cleanup - del arg seems to be the problem
code.put_var_xdecref(entry, have_gil=not lenv.nogil)
code.put_var_xdecref(entry, have_gil=gil_owned['success'])
if self.needs_closure:
assure_gil('success')
code.put_decref(Naming.cur_scope_cname, lenv.scope_class.type)
......
......@@ -463,6 +463,21 @@ def test_nogil_try_finally_error_label():
print e.args[0]
def void_with_python_objects():
"""
>>> void_with_python_objects()
"""
with nogil:
_void_with_python_objects()
cdef void _void_with_python_objects() nogil:
c = 123
with gil:
obj1 = [123]
obj2 = [456]
cdef void test_timing_callback() with gil:
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