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

Invalid Unicode escapes in bytes literals #9476

Open
InSyncWithFoo opened this issue Nov 17, 2024 · 1 comment
Open

Invalid Unicode escapes in bytes literals #9476

InSyncWithFoo opened this issue Nov 17, 2024 · 1 comment
Labels
enhancement request New feature or request

Comments

@InSyncWithFoo
Copy link
Contributor

Pyright seems to be accepting these Unicode escapes; it resolves all of them to b'\xFF' regardless of the actual values (playground):

a = b'\u00FF'      # Literal[b"\xff"]
b = b'\uFFFF'      # Literal[b"\xff"]
c = b'\U0000FFFF'  # Literal[b"\xff"]
d = b'\U00F0FFFF'  # Literal[b"\xff"]

However, \u and \U escapes are not recognized within bytes literals:

Python 3.14.0a1 (tags/v3.14.0a1:8cdaca8, Oct 15 2024, 20:08:21) [MSC v.1941 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> b'\u00FF'
<python-input-0>:1: SyntaxWarning: invalid escape sequence '\u'
  b'\u00FF'
b'\\u00FF'
@InSyncWithFoo InSyncWithFoo added the bug Something isn't working label Nov 17, 2024
@erictraut erictraut added enhancement request New feature or request and removed bug Something isn't working labels Nov 17, 2024
@erictraut
Copy link
Collaborator

Yeah, pyright's logic doesn't currently check for this syntax error. I think it's a reasonable enhancement request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants