Repository navigation
lexer: a line break in a string is \n whatever the file's line endings - #182
Merged
Merged
Conversation
A Pyfun file saved with Windows line endings put a carriage return before every newline of a multi-line string: `"""a<CRLF>b"""` had length 4 where Python's universal newlines give 3. Students on Windows would carry it into every triple-quoted string they print, write to a file or compare. It showed up as the one difference between the Windows and Linux runs of examples/hello.pyfun in the pre-release Python 3.12 check. push_char, which takes every literal character of a plain, raw and interpolated string, now turns `\r\n` and a lone `\r` into `\n`, as Python does. An escaped `\r` is still a carriage return. Spans are untouched, since only the literal's content changes.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Found by the pre-release Python 3.12 check for 0.10.0: the one remaining difference between the Windows and Linux runs of
examples/hello.pyfunwas a carriage return inside a multi-line string.The bug: a Pyfun file saved with Windows line endings put a
\rbefore every newline of a multi-line string."""a<CRLF>b"""had length 4, where Python's universal newlines give 3. It predates this release, and students on Windows would carry it into every triple-quoted string they print, write to a file or compare.The fix:
push_char, which takes every literal character of a plain, raw and interpolated string, turns\r\nand a lone\rinto\n, as Python does. An escaped\ris still a carriage return. Spans are untouched, since only the literal's content changes.Checked: a lexer test covers each string form, a lone
\r, and the escape.cargo fmt,cargo clippy --all-targets(clean),cargo test(every binary) anddocs/verify_lessons.pypass, and every e2e program under Python 3.12 now matches Windows/3.14 except glibc'smath.cbrt(27.0)(286 of 287, a known libm difference the test already tolerates).