diff --git a/ext/pycall/pycall.c b/ext/pycall/pycall.c index afe6903..c69373d 100644 --- a/ext/pycall/pycall.c +++ b/ext/pycall/pycall.c @@ -107,6 +107,10 @@ pycall_without_gvl(VALUE (* func)(VALUE), VALUE arg) pycall_set_with_gvl(); + if (state) { + rb_jump_tag(state); + } + return result; } diff --git a/test/pycall/test-gvl.rb b/test/pycall/test-gvl.rb new file mode 100644 index 0000000..02ceda4 --- /dev/null +++ b/test/pycall/test-gvl.rb @@ -0,0 +1,10 @@ +class PyCallGvlTest < Test::Unit::TestCase + def test_exception + math = PyCall.import_module("math") + assert_raise_message(/factorial\(\) not defined for negative values/) do + PyCall.without_gvl do + math.factorial(-1) + end + end + end +end