Skip to content
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

gh-102310: Change error range for invalid bytes literals #103663

Merged
merged 2 commits into from Apr 23, 2023

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Apr 21, 2023

Before:

>>> b"Ā"
  File "<stdin>", line 1
    b"Ā"
        ^
SyntaxError: bytes can only contain ASCII literal characters

After:

» ./python.exe
Python 3.12.0a7+ (heads/main-dirty:a4967d9d59, Apr 21 2023, 16:58:05) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> b"Ā"
  File "<stdin>", line 1
    b"Ā"
    ^^^^
SyntaxError: bytes can only contain ASCII literal characters

Please, let me know if this needs a unit test.

@Eclips4
Copy link
Contributor

Eclips4 commented Apr 21, 2023

Should we add a test for this case? (and put in test_traceback.py)

@sobolevn
Copy link
Member Author

This is a SyntaxError, it would need a bit of work to do right.

@pablogsal
Copy link
Member

This is a SyntaxError, it would need a bit of work to do right.

You can add a test case in test_syntax or test_grammar

@sobolevn
Copy link
Member Author

Done! 😊

@pablogsal pablogsal merged commit 0fd3891 into python:main Apr 23, 2023
20 checks passed
@arhadthedev arhadthedev added the needs backport to 3.11 bug and security fixes label Apr 23, 2023
@miss-islington
Copy link
Contributor

Thanks @sobolevn for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 23, 2023
…nGH-103663)

(cherry picked from commit 0fd3891)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@bedevere-bot
Copy link

GH-103703 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 bug and security fixes label Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants