Commit 156f3c8
Preserve ValueError context when re-raising invalid type codes
Two ValueType conversion sites in tuples.py — the params-tuple
decoder and the row-header decoder — caught ValueError from
ValueType(raw) and re-raised as DecodeError with `from None`,
suppressing the original exception. That loses the underlying
Python enum's error phrasing (e.g., "X is not a valid ValueType"),
which is the only diagnostic detail beyond the byte value and index
we already include in the message. It also diverges from the rest
of the file, which chains with `from e` (struct errors) or lets the
raise propagate implicitly.
Change both sites to chain with `from e` so the cause is preserved
in traceback output and log-format exception chains. Extend the two
existing negative tests to assert __cause__ is a ValueError.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6db31c4 commit 156f3c8
2 files changed
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
| 188 | + | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
271 | | - | |
| 270 | + | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
| 412 | + | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
414 | 417 | | |
415 | 418 | | |
416 | 419 | | |
| |||
422 | 425 | | |
423 | 426 | | |
424 | 427 | | |
425 | | - | |
| 428 | + | |
426 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
427 | 433 | | |
428 | 434 | | |
429 | 435 | | |
| |||
0 commit comments