diff options
| author | Jeff Epler <jepler@gmail.com> | 2025-05-09 21:22:33 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-05-16 11:51:43 +1000 |
| commit | 2f97d1dd28a7e2d34df268676e533944410aab42 (patch) | |
| tree | 21c3240e567541473bf26e9921c513e7a8f559be | |
| parent | e22c666d0623e6273d748f787a84d3108a57f1c3 (diff) | |
tests/cpydiff: Document that uPy requires space after number+period.
Signed-off-by: Jeff Epler <jepler@gmail.com>
| -rw-r--r-- | tests/cpydiff/syntax_spaces.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/cpydiff/syntax_spaces.py b/tests/cpydiff/syntax_spaces.py index 86faa5981..e7d00838c 100644 --- a/tests/cpydiff/syntax_spaces.py +++ b/tests/cpydiff/syntax_spaces.py @@ -1,11 +1,11 @@ """ categories: Syntax,Spaces -description: MicroPython requires spaces between literal numbers and keywords, CPython doesn't +description: MicroPython requires spaces between literal numbers and keywords or ".", CPython doesn't cause: Different parser implementation MicroPython's tokenizer treats a sequence like ``1and`` as a single token, while CPython treats it as two tokens. -Since CPython 3.11, this syntax causes a ``SyntaxWarning`` for an "invalid literal". +Since CPython 3.11, when the literal number is followed by a token, this syntax causes a ``SyntaxWarning`` for an "invalid literal". When a literal number is followed by a "." denoting attribute access, CPython does not warn. workaround: Add a space between the integer literal and the intended next token. @@ -24,3 +24,7 @@ try: print(eval("1if 1else 0")) except SyntaxError: print("Should have worked") +try: + print(eval("0x1.to_bytes(1)")) +except SyntaxError: + print("Should have worked") |
