mrkn / pycall.rb

Calling Python functions from the Ruby language
MIT License
1.05k stars 72 forks source link

exceptions not raised from within without_gvl block #154

Closed amcox closed 2 years ago

amcox commented 2 years ago

When an exception, whether from a python or ruby function, is encountered within a without_gvl block, PyCall discards the exception and returns nil instead of raising the exception.

For example:

math = PyCall.import_module("math")
math.factorial(-1)
# raises an exception PyCall::PyError: <class 'ValueError'>: factorial() not defined for negative values 

PyCall.without_gvl do math.factorial(-1) end
# returns nil without raising an exception

I would expect the exception to be raised when exiting the block.

mrkn commented 2 years ago

@amcox Thank you for reporting this. Good catch. I'll fix it soon.