-
-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
ast.unparse doesn't observe the new PEP701 string delimiter rules #108469
Comments
@isidentical can you take a look? |
Yep! |
@tonybaloney just saw the #108553, are you interested on providing a fix in the PR too or is it a test case PR? I'd be happy to help / answer questions regarding the old f-string unparsing logic if you have any. Lines 1226 to 1260 in 4116592
|
@isidentical I'd be happy to submit a PR. I looked at the code and couldn't really work out what it was doing or why though. There are some private methods for escaping strings or using a different string delimiter which I guess would be redundant from 3.12 but couldn't see if that was the only change needed |
I think so. Most of that code was trying to get rid of backslashes and figure out what quote we can use for nested f-strings which doesn't create a problem anymore. |
We'd better move fast. We won't make it to the Sept 4th release. Hurry for Oct 2rd release. |
… [3.12] (#108553) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
…PEP701 [3.12] (pythonGH-108553) (cherry picked from commit 2c4c26c) Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com> Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Bug report
Checklist
and am confident this bug has not been reported before
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
Python 3.12.0b4 (v3.12.0b4:97a6a41816, Jul 11 2023, 11:19:02) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
A clear and concise description of the bug:
The
ast.unparse
Unparser doesn't seem to respect PEP701, for example, if you use double quotes in an f-string then unparse the AST it will use a backslash--Furthermore, if you use the nested f-string example in the PEP, it crashes completely when unparsing the AST
Linked PRs
The text was updated successfully, but these errors were encountered: