Repository navigation
Accept the format keyword in Struct initialization - #9064
Conversation
Keep the existing conversion and initialization path while binding format as positional-or-keyword, matching Python 3.14. Assisted-by: OpenAI Codex:model identifier unavailable
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to The change appears mergeable after normal checks, including completion of hosted CI. Pre-merge checks |
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Extract the Python 3.14-compatible
Struct(format=...)argument binding from #8954.Bind the existing format converter as one required positional-or-keyword field. This accepts keyword construction and initialization while preserving the current constructor, converter, parser, state replacement, and subclass behavior. No 3.15 initialization tracking, reinitialization warning, or error-type change is included.
Both CPython 3.14.7 and 3.14.8 accept
formatby position or keyword. Main currently binds the converter through its positional-only blanket implementation. The related changes in #8950 concern non-ASCII errors and uninitialized.format, not this binder.Add a small regression to the existing struct snippet for str/bytes keyword construction, inherited initialization, successful keyword reinitialization, and failed parsing preserving the prior usable state. Existing positional cases remain unchanged.
Validation
-D warnings.Hosted CI is pending.
The generic argument binder's pre-existing diagnostic wording is not claimed to match every CPython argument-error message. No canonical assertions, README wording, or implementation-name guards are changed.
Summary by CodeRabbit
struct.Structnow acceptsformatas a keyword argument when creating or reinitializing an instance. String and bytes formats are supported, and invalid formats raisestruct.errorwithout replacing the existing format.