8000 Improve error message for unterminated strings with escapes · Issue #100445 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Improve error message for unterminated strings with escapes #100445

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

Closed
hauntsaninja opened this issue Dec 23, 2022 · 0 comments
Closed

Improve error message for unterminated strings with escapes #100445

hauntsaninja opened this issue Dec 23, 2022 · 0 comments
Labels
type-feature A feature request or enhancement

Comments

@hauntsaninja
Copy link
Contributor
hauntsaninja commented Dec 23, 2022

Inspired by #55688 and #94768.

Currently, this code raises the following error:

>>> "asdf\"
  File "<stdin>", line 1
    "asdf\"
    ^
SyntaxError: unterminated string literal (detected at line 1)

Maybe there's room to make this error message more helpful, to make the source of the error more obvious for users unfamiliar with escapes. Could the following be better?

>>> "asdf\"
  File "<stdin>", line 1
    "asdf\"
    ^
SyntaxError: unterminated string literal (detected at line 1); perhaps you escaped the end quote?

(The raw string situation in the linked issues that inspired this is a little extra tricky, since the workaround is still not clear. But hopefully the message still makes it clearer to users what is going on)

Linked PRs

@hauntsaninja hauntsaninja added the type-feature A feature request or enhancement label Dec 23, 2022
@hauntsaninja hauntsaninja changed the title Improve error message for unterminated raw strings Improve error message for unterminated strings with escapes Dec 23, 2022
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue Dec 23, 2022
AlexWaygood added a commit to hauntsaninja/cpython that referenced this issue Apr 24, 2023
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue Sep 16, 2023
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue Sep 16, 2023
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue Sep 16, 2023
hauntsaninja added a commit to hauntsaninja/cpython that referenced this issue Oct 18, 2023
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant
0