GeezerVison is showing github.com — Normalize lone CR to LF in str source for `exec()`, `eval()` and `-c` by Copilot · Pull Request #9762 · RustPython/RustPython
Conversation
Copilot
AI
commented
Nov 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
When source is passed to exec() or eval() as a str, or via -c, a lone \r inside a string literal stays '\r'. CPython reads it as '\n', as it does for CRLF. The language reference says line-ending sequences are replaced by LF "even inside string literals". Docstrings with CR-only breaks also went uncleaned, and exec(text) differed from exec(text.encode()).
These paths skip the source decoder and reach compile_with_syntax_warning_handler, which only replaced "\r\n". The parser copies literal text from the source as is, so an unnormalized CR ended up in the value.
crates/compiler/src/lib.rs: compile_with_syntax_warning_handler now also replaces any remaining \r with \n, after the CRLF replacement.
eval('"""a\rb"""') # before: 'a\rb' after: 'a\nb'
- The
#[cfg(windows)] \r\n replacement near line 2082 is untouched.
- No regression test is added.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Review skipped
Bot user detected.
To trigger a single review, invoke the @coderabbitai review command.
Run configuration
-
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
- 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.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot
AI
changed the title
[WIP] Fix lone carriage return in string literals for exec and eval
Normalize lone CR to LF in str source for exec(), eval() and -c
Nov 9, 2026
Reviewers
youknowone
Awaiting requested review from youknowone
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|