Skip to content

Commit

Permalink
Merge pull request #155 from mrkn/fix_without_gvl_for_exception
Browse files Browse the repository at this point in the history
Fix without_gvl for exceptions occurred in a block
  • Loading branch information
mrkn authored Feb 10, 2022
2 parents 69cf4dd + a6fea92 commit f7cde02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/pycall/pycall.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ pycall_without_gvl(VALUE (* func)(VALUE), VALUE arg)

pycall_set_with_gvl();

if (state) {
rb_jump_tag(state);
}

return result;
}

Expand Down
10 changes: 10 additions & 0 deletions test/pycall/test-gvl.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7cde02

Please sign in to comment.