Repository navigation
Add Python 3.15 encoding normalization helper - #9115
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters: 1
📒 Files selected for processing: 2
✨ Finishing Touches
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: :4: SyntaxWarning: invalid decimal literal dependencies:
dependent tests: (164 tests)
Legend:
|
Extract _codecs._normalize_encoding and delegate encodings.normalize_encoding to it using the final CPython 3.15 library source. Preserve case and dots, validate UTF-8 before NUL truncation, and retain wrapper warnings and bytes conversion. Add bounded regression assertions without changing registry keys. Lib/encodings/__init__.py was updated via scripts/update_lib migrate from CPython d220409a13b77de7a6c30abe16ea90db01528edc, with byte-identical output. AI assistance: OpenAI Codex implemented and source-reviewed this split, ran update_lib, prepared bounded regressions and performed focused automated validation. No human manual testing is claimed. Assisted-by: OpenAI Codex:model version unavailable
412ddea to
a93f8f8
Compare
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a93f8f85fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| assert _codecs._normalize_encoding(encoding) == expected | ||
| assert _codecs._normalize_encoding(encoding=EncodingName(encoding)) == expected |
There was a problem hiding this comment.
Remove prohibited test-file changes
This newly added regression block changes test data, control flow, and assertions in extra_tests/snippets/stdlib_codecs_wide.py, but the repository's critical test policy permits test-file changes only for adding or removing expected-failure markers. Because none of this block is such a marker change, the test-file hunk needs to be removed before this commit complies.
AGENTS.md reference: AGENTS.md:L273-L279
Useful? React with 👍 / 👎.
Summary
Extract the native
_codecs._normalize_encodinghelper from #8954, alongside the final Python 3.15encodings.normalize_encodingdelegation. Preserve ASCII case and dots, collapse other UTF-8 bytes to interior underscores, and validate the whole string before stopping normalization at NUL. Accept string subclasses and theencoding=keyword.The Python wrapper retains its existing non-ASCII deprecation warning and ASCII bytes support. Main already has that warning and the cache bound; this is not presented as a fix for an email warning. Registry lookup normalization/error messages are unchanged. No IDNA, punycode, bytearray, or other encoding module changes.
CPython provenance
Only
Lib/encodings/__init__.pywas updated, using the repository's actual exact-file workflow:Source: CPython d220409a13b77de7a6c30abe16ea90db01528edc. Input and generated output are byte-identical:
849a5e31effe6c647b6d526b92f2f063a67fac36e7750267f721f15e3693de08169c48324f227bf51b88d8b2e1a6a9df39067533The supported
migratecommand was chosen becausecopy-libresolves the top-level package and would copy all ofencodings. No manual Lib edits or new test skips were used.Native behavior was source-reviewed against final CPython
_codecsmodule.c:1025–1062andunicodeobject.c:3465–3513.Validation
cargo build --release --locked --no-default-features --features threading,stdlib,stdio,importlib,host_env --bin rustpython -j 1.stdlib_codecs_wide.py, extracted by AST into a bounded script and run on the candidate RustPython binary with a 30-second timeout. The candidateencodings.__file__was asserted. Covers positional/keyword/subclass binding, argument errors, case/dot preservation, punctuation collapse, Unicode, NUL, surrogate-after-NUL validation, native warning absence, and wrapper warning/bytes behavior.cargo clippy --release --locked -p rustpython-vm --no-default-features --features compiler,threading,host_env -j 1 -- -D warnings.Not run: the pre-existing whole codec snippet, pytest/full snippet suite, full codecs test suites, workspace/C-API tests, all-target Clippy, WASM, or a CPython 3.15 runtime oracle. These are focused automated results, not full-suite or platform validation.
AI assistance
OpenAI Codex extracted and source-reviewed the implementation, ran the library update tool, wrote bounded regression assertions, and performed the automated checks listed above. This contribution is made under the maintainer exemption. No human manual testing is claimed.