Things to check first
cbor2 version
6.0.1
Python version
3.12
What happened?
With the recently released cbor2 6.0.x, cbor2.CBORDecodeError is not a subclass of ValueError.
When using data serialization libraries like the stdlib's json, it is a common convention that .loads(...) or similar raises a subclass of ValueError (the passed value was incorrect). This used to work fine in cbor2 as well until the very recent 6.0.x releases.
How can we reproduce the bug?
Using older cbor2 (5.x), this would have worked just fine:
try:
cbor2.loads(b'\xde\xad\xbe\xef')
except ValueError:
print('Validation failed')
On 6.0.x, the decoding error is not caught as ValueError.
Things to check first
I have searched the existing issues and didn't find my bug already reported there
I have checked that my bug is still present in the latest release
cbor2 version
6.0.1
Python version
3.12
What happened?
With the recently released
cbor26.0.x,cbor2.CBORDecodeErroris not a subclass ofValueError.When using data serialization libraries like the stdlib's
json, it is a common convention that.loads(...)or similar raises a subclass ofValueError(the passed value was incorrect). This used to work fine incbor2as well until the very recent 6.0.x releases.How can we reproduce the bug?
Using older
cbor2(5.x), this would have worked just fine:On 6.0.x, the decoding error is not caught as
ValueError.