Skip to content

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

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
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
Member

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
@arhadthedev arhadthedev added the needs backport to 3.11 only 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.

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy