`cbor2.CBORDecodeError` should be a subclass of `ValueError`
- Vorherrschende Sprache
- Rust
- Sterne
- 305
- Forks
- 79
- Ø Merge
- 21 Std. 59 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
### 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`.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.