Repository navigation
Fix struct complex conversion and overflow behavior - #8829
Conversation
Accept F/D through the existing buffer packing implementation and restore its complex round-trip test. Fix exact __complex__ results warning as subclasses so valid conversions also work with warnings treated as errors. Codex assisted with implementation, regression coverage, and review. Tested: CPython 3.14.7 comparison; struct/memoryview/complex/cmath; workspace and C-API tests; Clippy; pytest; prek Assisted-by: Codex:gpt-6-astra
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: RustPython/RustPython/.coderabbit.yml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughComplex packing now reads existing ChangesComplex struct formats
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Feature Suggested reviewers: Merge Risk: ⚪ Minimal · up to The supplied evidence identifies no issue that needs resolution before merge; complete the normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: [ ] test: cpython/Lib/test/test_unicodedata.py (TODO: 25) dependencies: dependent tests: (no tests depend on unicode) [x] test: cpython/Lib/test/test_itertools.py (TODO: 3) dependencies: dependent tests: (56 tests)
[x] lib: cpython/Lib/inspect.py dependencies:
dependent tests: (97 tests)
[x] lib: cpython/Lib/warnings.py dependencies:
dependent tests: (55 tests)
[x] lib: cpython/Lib/threading.py dependencies:
dependent tests: (166 tests)
[x] lib: cpython/Lib/struct.py dependencies:
dependent tests: (179 tests)
[x] lib: cpython/Lib/pydoc.py dependencies:
dependent tests: (5 tests)
[x] lib: cpython/Lib/doctest.py dependencies:
dependent tests: (36 tests)
[x] test: cpython/Lib/test/test_builtin.py (TODO: 11) dependencies: dependent tests: (no tests depend on builtin) [x] test: cpython/Lib/test/test_list.py (TODO: 1) dependencies: dependent tests: (no tests depend on list) [x] lib: cpython/Lib/trace.py dependencies:
dependent tests: (1 tests)
[x] lib: cpython/Lib/io.py dependencies:
dependent tests: (108 tests)
[x] lib: cpython/Lib/collections dependencies:
dependent tests: (332 tests)
[x] lib: cpython/Lib/abc.py dependencies:
dependent tests: (11 tests)
[x] lib: cpython/Lib/re dependencies:
dependent tests: (82 tests)
[ ] lib: cpython/Lib/zoneinfo dependencies:
dependent tests: (2 tests)
[x] lib: cpython/Lib/rlcompleter.py dependencies:
dependent tests: (4 tests)
[ ] test: cpython/Lib/test/test_sys.py (TODO: 7) dependencies: dependent tests: (239 tests)
[ ] test: cpython/Lib/test/test_pyrepl (TODO: 20) dependencies: dependent tests: (no tests depend on pyrepl) [x] lib: cpython/Lib/zipfile dependencies:
dependent tests: (99 tests)
[x] lib: cpython/Lib/hmac.py dependencies:
dependent tests: (9 tests)
[x] test: cpython/Lib/test/test_tuple.py (TODO: 1) dependencies: dependent tests: (no tests depend on tuple) [x] lib: cpython/Lib/socket.py dependencies:
dependent tests: (101 tests)
[x] test: cpython/Lib/test/test_structseq.py (TODO: 1) dependencies: dependent tests: (no tests depend on structseq) [x] lib: cpython/Lib/codecs.py dependencies:
dependent tests: (161 tests)
[ ] lib: cpython/Lib/unittest dependencies:
dependent tests: (408 tests)
[x] lib: cpython/Lib/functools.py dependencies:
dependent tests: (51 tests)
[ ] lib: cpython/Lib/http dependencies:
dependent tests: (51 tests)
[x] test: cpython/Lib/test/test_float.py (TODO: 2) dependencies: dependent tests: (no tests depend on float) [x] test: cpython/Lib/test/test_marshal.py (TODO: 4) dependencies: dependent tests: (25 tests)
[x] lib: cpython/Lib/dataclasses.py dependencies:
dependent tests: (98 tests)
Legend:
|
Merge current main and reuse its complex format types and unpacking. Keep only conversion, warning, and opposite-endian overflow fixes. Codex assisted with conflict resolution, implementation, tests, and review. Constraint: F/D format support is already present in upstream RustPython#8780 Tested: CPython 3.14.7 comparison; struct/memoryview/complex/cmath; pytest; workspace and C-API tests; Clippy; prek Assisted-by: Codex:gpt-6-astra
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Follow up on the
structF/D support added in #8780 to match CPython'sconversion and overflow behavior:
__complex__.__complex__returns an exactcomplex.OverflowErrorfor overflowing F components with opposite byte order,while preserving CPython's matching-endian casts.
Reuse the existing format types and unpacking implementation. Add regression
coverage for these cases.
AI assistance: Codex assisted with implementation, tests, review, and this description.
Testing
test_struct,test_memoryview,test_complex, andtest_cmathpytest -v: 472 passed with sqlite enabledprek run --all-filesSummary by CodeRabbit
struct.packsupports the"F"and"D"format codes for complex values, including objects converted through__complex__.__complex__method."F"in opposite-endian byte order raisesOverflowError.__complex__returns a strict subclass ofcomplex.