Skip to content

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

Merged
pablogsal merged 2 commits into
python:mainfrom
sobolevn:issue-102310
Apr 23, 2023
Merged

gh-102310: Change error range for invalid bytes literals#103663
pablogsal merged 2 commits into
python:mainfrom
sobolevn:issue-102310

Conversation

@sobolevn

@sobolevn sobolevn commented Apr 21, 2023

Copy link
Copy Markdown
Member

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

Eclips4 commented Apr 21, 2023

Copy link
Copy Markdown
Member

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

@sobolevn

Copy link
Copy Markdown
Member Author

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

@pablogsal

Copy link
Copy Markdown
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
Copy Markdown
Member Author

Done! 😊

@pablogsal
pablogsal merged commit 0fd3891 into python:main Apr 23, 2023
@arhadthedev arhadthedev added the needs backport to 3.11 only security fixes label Apr 23, 2023
@miss-islington

Copy link
Copy Markdown
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
Copy Markdown

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

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.

6 participants