GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-133197: Improve error message for `ft""` and `bt""` cases by sobolevn · Pull Request #133202 · python/cpython

Conversation

@sobolevn

@sobolevn sobolevn commented Apr 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Refs #133197

  • Issue: Improve error message for strings with conflicting prefixes #133197

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sobolevn
pythongh-133196: Improve error message for ft"" case
4f57f3d
@sobolevn
sobolevn requested review from lysnikolaou and pablogsal as code owners April 30, 2025 11:39
@bedevere-app bedevere-app Bot added the awaiting core review label Apr 30, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 30, 2025
PEP 750 changes do no guard for usage with older versions like ast.parse(t'', feature_version=(3, 13)) #133196
Closed
@sobolevn sobolevn added the skip news label Apr 30, 2025
@sobolevn

sobolevn commented Apr 30, 2025

Copy link
Copy Markdown
Member Author

Hm, looks like other string prefixes can also conflict with no clear message. Examples:

>>> tb''
  File "<python-input-3>", line 1
    tb''
      ^^
SyntaxError: invalid syntax

>>> fb''
  File "<python-input-0>", line 1
    fb''
      ^^
SyntaxError: invalid syntax

>>> ru''
  File "<python-input-1>", line 1
    ru''
      ^^
SyntaxError: invalid syntax

>>> bu''
  File "<python-input-2>", line 1
    bu''
      ^^
SyntaxError: invalid syntax

Let's handle all t cases here maybe and u-string prefixes in the next PR? It would much easier for me.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
Also handle tb cases
b269ebb
@sobolevn sobolevn changed the title gh-133196: Improve error message for ft"" case gh-133196: Improve error message for ft"" and bt"" cases Apr 30, 2025
lysnikolaou
lysnikolaou reviewed Apr 30, 2025
View reviewed changes

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Left a couple of comments inline. Also, it appears that the issue number is wrong. Could you change it please?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_syntax.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Parser/lexer/lexer.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn
Address review
40668a5
@sobolevn

sobolevn commented Apr 30, 2025

Copy link
Copy Markdown
Member Author

Now we have prefixes highlighted:
Снимок экрана 2025-04-30 в 15 19 42
Снимок экрана 2025-04-30 в 15 19 12

tomasr8 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sobolevn sobolevn changed the title gh-133196: Improve error message for ft"" and bt"" cases gh-133197: Improve error message for ft"" and bt"" cases Apr 30, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Apr 30, 2025
Improve error message for strings with conflicting prefixes #133197
Closed
@sobolevn
together
a4aa4c0
lysnikolaou
lysnikolaou approved these changes Apr 30, 2025
View reviewed changes

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM! This is a nice improvement! Let's follow up with the rest of the prefixes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sobolevn reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Apr 30, 2025
@sobolevn
sobolevn merged commit b451516 into python:main Apr 30, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 30, 2025
@dylwil3 dylwil3 mentioned this pull request Jul 21, 2025
Emit more specific syntax errors for incompatible string prefixes astral-sh/ruff#19466
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lysnikolaou lysnikolaou lysnikolaou approved these changes
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@sobolevn @lysnikolaou
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.