Repository navigation
Fix source decoding diagnostics and normalize decoded newlines - #9429
youknowone merged 1 commit into
Conversation
Track coding-cookie locations, preserve codec initialization errors as SyntaxError, and normalize decoded source before parsing. Add unchanged CPython 3.15 source-encoding coverage via update_lib. Assisted-by: OpenAI Codex: model version unavailable
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Encoding cookie detection crates/vm/src/vm/compile.rs |
Detection scans up to two physical lines, handles an optional UTF-8 BOM and CR/LF line endings, and returns the encoding name with the cookie’s line and byte range. |
Decoding and error reporting crates/vm/src/vm/compile.rs |
program_text passes the detected encoding name to decoding. BOM and codec errors use location data, and successfully decoded source normalizes CRLF and bare CR to LF. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
- RustPython issue 6839: This PR performs one item of the tracked CPython 3.15 standard-library migration work by adding the
test_source_encodingsuite.
Suggested reviewers: youknowone
Merge Risk: 
Minimal · up to 1f774
-
The decoding and newline changes appear mergeable with normal checks. No new merge-blocking defect was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
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. |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] test: cpython/Lib/test/test_startfile.py dependencies: dependent tests: (no tests depend on startfile) [x] lib: cpython/Lib/zipimport.py dependencies:
dependent tests: (10 tests)
[x] lib: cpython/Lib/pdb.py dependencies:
dependent tests: (2 tests)
[x] test: cpython/Lib/test/test_source_encoding.py dependencies: dependent tests: (no tests depend on source_encoding) [ ] test: cpython/Lib/test/test_setcomps.py dependencies: dependent tests: (no tests depend on setcomps) [x] test: cpython/Lib/test/test_dict.py (TODO: 1) dependencies: dependent tests: (no tests depend on dict) [ ] test: cpython/Lib/test/test_list.py dependencies: dependent tests: (no tests depend on list) [x] test: cpython/Lib/test/test_generators.py dependencies: dependent tests: (no tests depend on generator) Legend:
|
Summary
codingcandidates.SyntaxErrorwhile preserving the underlying reason, following CPython's tokenizer initialization error handling.test_source_encodingsuite usingscripts/update_lib migratefromd220409a13b77de7a6c30abe16ea90db01528edc.The native changes are confined to the source decoder and its encoding-location record. They do not replace the compiler/parser diagnostic or type-comment work in #8954.
Validation
cargo checkand strict Clippy (-D warnings) passed.compile(str)andcompile(bytes).Scope and remaining differences
This is not a claim of complete tokenizer compatibility. Successful decoder consumers are normalized together; direct string paths that bypass the decoder are not changed. CPython's pre-codec newline conversion and file-stream-relative codec error offsets remain separate work. Generic
SyntaxError.argslocation tuples also remain different even where the location attributes match. No dependency pins or Ruff patches are changed.AI assistance
OpenAI Codex assisted with the implementation, CPython source comparison, tests, and this pull request description; the model version is unavailable. Full workspace and C-API tests were not run locally; hosted CI remains pending.
Summary by CodeRabbit