Raise OverflowError for float overflow in struct packing - #8360
Conversation
Raise OverflowError when a finite f64 value overflows while being converted for the struct f format. Remove the expected-failure marker from the corresponding regression test. Assisted-by: Codex:gpt-5
📝 WalkthroughWalkthroughFloat packing now preserves the parsed ChangesFloat packing
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] lib: cpython/Lib/email dependencies: dependent tests: (53 tests)
[x] lib: cpython/Lib/shlex.py dependencies:
dependent tests: (10 tests)
[x] lib: cpython/Lib/weakref.py dependencies:
dependent tests: (222 tests)
[x] lib: cpython/Lib/struct.py dependencies:
dependent tests: (179 tests)
[ ] lib: cpython/Lib/unittest dependencies:
dependent tests: (408 tests)
[x] lib: cpython/Lib/csv.py dependencies:
dependent tests: (4 tests)
[x] lib: cpython/Lib/pydoc.py dependencies:
dependent tests: (5 tests)
[ ] test: cpython/Lib/test/test_bytes.py (TODO: 22) dependencies: dependent tests: (no tests depend on bytes) [x] lib: cpython/Lib/bz2.py dependencies:
dependent tests: (101 tests)
[x] lib: cpython/Lib/sqlite3 dependencies:
dependent tests: (2 tests)
[ ] test: cpython/Lib/test/test_memoryview.py (TODO: 9) dependencies: dependent tests: (no tests depend on memoryview) [x] lib: cpython/Lib/io.py dependencies:
dependent tests: (108 tests)
[x] test: cpython/Lib/test/test_thread.py (TODO: 4) dependencies: dependent tests: (14 tests) Legend:
|
Raise OverflowError when a finite f64 value overflows while being converted for the struct f format. Remove the expected-failure marker from the corresponding regression test. Assisted-by: Codex:gpt-5
Summary
structfformat.OverflowErrorwith the CPython-compatible message instead of silently packing an IEEE 754 infinity.Behavior changes
Before:
After:
References
PyFloat_Pack4: https://github.com/python/cpython/blob/v3.14.6/Objects/floatobject.c#L2180-L2185Summary by CodeRabbit