summaryrefslogtreecommitdiff
path: root/tests/run/trace_nogil.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/trace_nogil.pyx')
-rw-r--r--tests/run/trace_nogil.pyx22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/run/trace_nogil.pyx b/tests/run/trace_nogil.pyx
new file mode 100644
index 000000000..175935ced
--- /dev/null
+++ b/tests/run/trace_nogil.pyx
@@ -0,0 +1,22 @@
+# cython: linetrace=True
+
+cdef void foo(int err) except * nogil:
+ with gil:
+ raise ValueError(err)
+
+
+# Test from gh-4637
+def handler(int err):
+ """
+ >>> handler(0)
+ All good
+ >>> handler(1) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ ValueError: 1
+ """
+ if (err % 2):
+ with nogil:
+ foo(err)
+ else:
+ print("All good")