From e22c666d0623e6273d748f787a84d3108a57f1c3 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 9 May 2025 19:17:50 +0200 Subject: [PATCH] tests/cpydiff: Explain the numeric literal parsing difference. Fixes issue #17224. Signed-off-by: Jeff Epler --- tests/cpydiff/syntax_spaces.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/cpydiff/syntax_spaces.py b/tests/cpydiff/syntax_spaces.py index 03d25d561..86faa5981 100644 --- a/tests/cpydiff/syntax_spaces.py +++ b/tests/cpydiff/syntax_spaces.py @@ -1,8 +1,15 @@ """ categories: Syntax,Spaces -description: uPy requires spaces between literal numbers and keywords, CPy doesn't -cause: Unknown -workaround: Unknown +description: MicroPython requires spaces between literal numbers and keywords, 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". + +workaround: Add a space between the integer literal and the intended next token. + +This also fixes the ``SyntaxWarning`` in CPython. """ try: