Skip to content

bpo-29104: Fixed parsing backslashes in f-strings. #490

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

No description provided.

Copy link
Member

@ericvsmith ericvsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than my one comment, this looks good to me. Thanks!

self.assertEqual(f'\\{6*7}', '\\42')
self.assertEqual(fr'\{6*7}', '\\42')

AMPERSAND = 123
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me literally an hour to figure out what's going on here.

Can you change this line to something:

AMPERSAND = ord('{')  # =123: Make sure we get the right unicode character (&), and not pick up local variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value is arbitrary. I didn't meant ord('{').

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. But the important part (to me) that I missed is that it's not equal to ord('&'). I had assumed it was, and that somehow that value was being used to produce the '&' in the output. But the point is that the value of the local AMPERSAND is not being used, correct?

If so, how about using 0, since most people by inspection know it's not an &?

@serhiy-storchaka serhiy-storchaka merged commit 0cd7a3f into python:master May 25, 2017
@serhiy-storchaka serhiy-storchaka deleted the bpo-29104-fstring-backslash branch May 25, 2017 10:33
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request May 25, 2017
serhiy-storchaka added a commit that referenced this pull request May 25, 2017
jaraco pushed a commit that referenced this pull request Dec 2, 2022
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.12.1 to 3.0.0.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](pytest-dev/pytest-cov@v2.12.1...v3.0.0)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants