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
f-strings: do not allow backslashes #72108
Comments
See https://mail.python.org/pipermail/python-dev/2016-August/145979.html for details. PEP-498 is going to be changed to disallow backslashes inside braces (the expression portions of an f-string). However, I can't get that change done in time for 3.6 beta 1. So, this bug will disallow any backslashes in f-strings. Before the next beta, I'll implement the correct behavior. This is a breaking change: f-strings like f'\\t{3}' which worked in 3.6 alphas will not work in 3.6 beta 1, but will work in beta 2. f-strings like f'{\'x\'}' which worked in 3.6 alphas, will not work in any beta or release version of 3.6. |
This looks a little ugly. |
True. My goal is to get the simplest possible thing working now, and then before beta 2 fix it so that backslashes again work in the text portions of an f-string. After that, I'll fix this particular piece of code (and the others, plus the tests that can be made to work). Here's an updated patch. I'm planning on committing it today. |
New changeset d7ce127b5c0f by Eric V. Smith in branch 'default': |
See bpo-27948 for adding backslashes back in to the string parts of an f-string. |
New changeset 899ee1e68a8d by Eric V. Smith in branch 'default': |
New changeset 80eb6eb57537 by Eric V. Smith in branch 'default': |
New changeset fd4e4fa75260 by Eric V. Smith in branch 'default': |
I haven’t looked, but my guess at why test_unparse could fail would be trying to generate code for an f-string with control characters in. Maybe it is taking stuff like f'''{x} and generating f'{x}\n{y}\n' |
New changeset df5b6d1c7ea8 by Benjamin Peterson in branch 'default': |
The problem with test_unparse is that: I'll open another issue for this. |
bpo-28002 tracks the problem with Tools/parser/unparse.py. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: