`cbor2.CBORDecodeError` should be a subclass of `ValueError`
- Lenguaje dominante
- Rust
- Estrellas
- 305
- Forks
- 79
- Merge medio
- 21 h 59 min
- PR fusionados (30 d)
- 2
Descripción
### 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
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:
```python
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`.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.