Skip to content

cpython difference parsing "invalid" literals #17224

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

Open
jepler opened this issue Apr 30, 2025 · 0 comments
Open

cpython difference parsing "invalid" literals #17224

jepler opened this issue Apr 30, 2025 · 0 comments
Labels

Comments

@jepler
Copy link
Contributor

jepler commented Apr 30, 2025

Port, board and/or hardware

unix

MicroPython version

MicroPython v1.26.0-preview.24.gcd8fad919f.dirty on 2025-04-22; linux [GCC 12.2.0] version

Reproduction

  1. micropython -c 'print(0x1or 2)
  2. python3.9 -c 'print(0x1or 2)

Expected behaviour

Both implementations print the same value

Observed behaviour

micropython raises an exception, while python prints "1" (Python versions starting with 3.11 print a warning though)

Additional Information

The warning about this syntax appeared in Python 3.11 as a result of https://bugs.python.org/issue43833. There appears to be no intent to actually convert this to a SyntaxError, though only for the risk of breaking existing code, not because anyone likes the construct.

Sorry for not filing this bug on April 1. Some post on mastodon alerted me to the fact that 0x1for....real is valid Python and I just had to check it out on micropython.

Code of Conduct

Yes, I agree

@jepler jepler added the bug label Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant