-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
untokenize() does not round-trip for code containing line breaks (\
+ \n
)
#125553
Labels
Comments
pablogsal
pushed a commit
that referenced
this issue
Jan 21, 2025
pablogsal
pushed a commit
that referenced
this issue
Jan 21, 2025
danigm
added a commit
to danigm/hypothesis
that referenced
this issue
Feb 26, 2025
In python 3.13.2 untokenize() does not round-trip for code containing line breaks (\ + \n). This patch removes the test case for the space removal before line break. python/cpython#125553
hugovk
pushed a commit
to hugovk/cpython
that referenced
this issue
Feb 26, 2025
…ythonGH-126010) (cherry picked from commit 7ad793e) Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
danigm
added a commit
to danigm/hypothesis
that referenced
this issue
Feb 27, 2025
In python 3.13.2 untokenize() does not round-trip for code containing line breaks (\ + \n). This patch removes the test case for the space removal before line break. python/cpython#125553
Zac-HD
pushed a commit
to HypothesisWorks/hypothesis
that referenced
this issue
Mar 1, 2025
In python 3.13.2 untokenize() does not round-trip for code containing line breaks (\ + \n). This patch removes the test case for the space removal before line break. python/cpython#125553
Zac-HD
pushed a commit
to HypothesisWorks/hypothesis
that referenced
this issue
Mar 2, 2025
In python 3.13.2 untokenize() does not round-trip for code containing line breaks (\ + \n). This patch removes the test case for the space removal before line break. python/cpython#125553
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
Bug description:
Code which contains line breaks is not round-trip invariant:
Notice that the space between
+
and\
is now missing. The current tokenizer code simply inserts a backslash when it encounters two subsequent tokens with a differeing row offset:cpython/Lib/tokenize.py
Lines 179 to 182 in 9c2bb7d
I think this should be fixed. The docstring of
tokenize.untokenize
says:To fix this, it will probably be necessary to inspect the raw line contents and count how much whitespace there is at the end of the line.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
untokenize
#126010untokenize
(GH-126010) #129153untokenize
(GH-126010) #130579The text was updated successfully, but these errors were encountered: