Repository navigation
fix(protocol): raise StructError from _make_pack for any size (#2291) - #2367
Conversation
|
Review: NEEDS CHANGES at
|
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.
1ccaa71 to
0be8298
Compare
|
Amended |
|
Ready to merge. Round 2 (Sonnet) GOOD TO GO on head 0be8298. Confirms: dangling Ordering leg (foundation): clean on this head. |
|
Correction to my comment above: "Ordering leg (foundation): clean on this head" was wrong — no ordering-leg run exists yet for this head (0be8298), and "foundation" is also the wrong leg for this diff (protocols). Running the correct leg now; will report the real result separately. |
|
Coverage: 91.58% (unit tier, Python 3.15,
Per-file detail: the |
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix — bug fixDescription
Closes #2291.
_make_packnow turns theAttributeError/OverflowError/TypeError/ValueErrorthatint.to_bytesraises for a too-big value, a negative unsigned value, a non-int, or a bad size intoStructError('<cls>: pack failed'), instead of leaking the raw exception.origin/main. Passing on the rebased head.