Skip to content

Commit e22c666

Browse files
jeplerdpgeorge
authored andcommitted
tests/cpydiff: Explain the numeric literal parsing difference.
Fixes issue micropython#17224. Signed-off-by: Jeff Epler <[email protected]>
1 parent 44bcfe5 commit e22c666

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/cpydiff/syntax_spaces.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
"""
22
categories: Syntax,Spaces
3-
description: uPy requires spaces between literal numbers and keywords, CPy doesn't
4-
cause: Unknown
5-
workaround: Unknown
3+
description: MicroPython requires spaces between literal numbers and keywords, CPython doesn't
4+
cause: Different parser implementation
5+
6+
MicroPython's tokenizer treats a sequence like ``1and`` as a single token, while CPython treats it as two tokens.
7+
8+
Since CPython 3.11, this syntax causes a ``SyntaxWarning`` for an "invalid literal".
9+
10+
workaround: Add a space between the integer literal and the intended next token.
11+
12+
This also fixes the ``SyntaxWarning`` in CPython.
613
"""
714

815
try:

0 commit comments

Comments
 (0)