[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
cbor2 version
5.5.1
Python version
3.11.6
What happened?
Python Exceptions raised in the object_hook callback in cbor2.load are not propagated correctly in the C module, and result in this exception: "SystemError: returned a result with an exception set".
I would expect the original Python exceptions to be propagated up, matching the python implementation behavior.
How can we reproduce the bug?
import pytest
import cbor2
from cbor2._decoder import loads as loads_py
from _cbor2 import loads as loads_c
def dec_objhook(decoder, d):
raise TypeError("Unsupported type")
a = {
'a': 1,
'hello': 'world',
'test': {'foo': 'bar'}
}
test = cbor2.dumps(a)
with pytest.raises(TypeError):
loads_py(test, object_hook=dec_objhook)
with pytest.raises(TypeError):
loads_c(test, object_hook=dec_objhook)
Things to check first
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
cbor2 version
5.5.1
Python version
3.11.6
What happened?
Python Exceptions raised in the returned a result with an exception set".
object_hook
callback in cbor2.load are not propagated correctly in the C module, and result in this exception: "SystemError:I would expect the original Python exceptions to be propagated up, matching the python implementation behavior.
How can we reproduce the bug?