Repository navigation
Commit 1ccaa71
committed
fix(protocol): raise StructError from _make_pack for any size (#2291)
Problem: for a size with no struct format code, _make_pack called
int.to_bytes outside any handler, so a value out of range, a non-integer
or a bad size leaked OverflowError, AttributeError or ValueError instead
of the documented StructError; _make_index(..., pack=True) leaked them too.
Fix: raise StructError from the errors of int.to_bytes, as the
struct.pack path does from struct.error, and document StructError on
_make_index.
Test: test_make_pack_raises_struct_error_for_every_size.1 parent 7b57bb0 commit 1ccaa71
2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1886 | 1886 | | |
1887 | 1887 | | |
1888 | 1888 | | |
1889 | | - | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
1890 | 1895 | | |
1891 | 1896 | | |
1892 | 1897 | | |
| |||
1964 | 1969 | | |
1965 | 1970 | | |
1966 | 1971 | | |
| 1972 | + | |
| 1973 | + | |
1967 | 1974 | | |
1968 | 1975 | | |
1969 | 1976 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
463 | 486 | | |
464 | 487 | | |
465 | 488 | | |
| |||
0 commit comments