https://github.com/python/cpython/commit/f7eda8e1302ca346768c11a0a4f67539cb5fbe34
commit: f7eda8e1302ca346768c11a0a4f67539cb5fbe34
branch: 3.15
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-07-05T10:41:56Z
summary:
[3.15] gh-150459: Fix `SyntaxError` message for `from x lazy import y`
(GH-150877) (#153090)
(cherry picked from commit ec5f154e33f5d62257d041dd28aad1fe785fa3db)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst
M Grammar/python.gram
M Include/internal/pycore_pyerrors.h
M Lib/test/test_syntax.py
M Parser/action_helpers.c
M Parser/parser.c
M Parser/pegen.h
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 9bf3a67939fcf37..7f98cb5c457d492 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -229,8 +229,9 @@ import_name[stmt_ty]:
# note below: the ('.' | '...') is necessary because '...' is tokenized as
ELLIPSIS
import_from[stmt_ty]:
+ | invalid_import_from
| lazy="lazy"? 'from' a=('.' | '...')* b=dotted_name 'import'
c=import_from_targets {
- _PyPegen_checked_future_import(p, b->v.Name.id, c,
_PyPegen_seq_count_dots(a), lazy, EXTRA) }
+ _PyPegen_checked_from_import(p, a, b, c, lazy, EXTRA) }
| lazy="lazy"? 'from' a=('.' | '...')+ 'import' b=import_from_targets {
_PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), lazy ? 1 : 0,
EXTRA) }
import_from_targets[asdl_alias_seq*]:
@@ -1443,6 +1444,11 @@ invalid_import_from_as_name:
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
"cannot use %s as import target", _PyPegen_get_expr_name(a)) }
+invalid_import_from:
+ | 'from' ('.' | '...')* dotted_name a="lazy" 'import' import_from_targets {
+ RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a,
+ "use 'lazy from ... ' instead of 'from ... lazy import'") }
+
invalid_import_from_targets:
| import_from_as_names ',' NEWLINE {
RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding
parentheses") }
diff --git a/Include/internal/pycore_pyerrors.h
b/Include/internal/pycore_pyerrors.h
index e436aa6bf12cb27..c1f9d71e40077c1 100644
--- a/Include/internal/pycore_pyerrors.h
+++ b/Include/internal/pycore_pyerrors.h
@@ -123,9 +123,11 @@ extern void _PyErr_SetNone(PyThreadState *tstate, PyObject
*exception);
extern PyObject* _PyErr_NoMemory(PyThreadState *tstate);
-extern int _PyErr_EmitSyntaxWarning(PyObject *msg, PyObject *filename, int
lineno, int col_offset,
- int end_lineno, int end_col_offset,
- PyObject *module);
+// Export for test_peg_generator
+PyAPI_FUNC(int) _PyErr_EmitSyntaxWarning(PyObject *msg, PyObject *filename,
+ int lineno, int col_offset,
+ int end_lineno, int end_col_offset,
+ PyObject *module);
extern void _PyErr_RaiseSyntaxError(PyObject *msg, PyObject *filename, int
lineno, int col_offset,
int end_lineno, int end_col_offset);
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index a3d485c998ac915..232dcb92ed2901f 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -2872,6 +2872,14 @@ def check_warning(self, code, errtext,
filename="<testcase>", mode="exec"):
with self.assertWarnsRegex(SyntaxWarning, errtext):
compile(code, filename, mode)
+ def check_no_warning(self, code, filename="<testcase>", mode="exec"):
+ """Check that compiling code does not raise any warnings."""
+ import warnings
+ with warnings.catch_warnings(record=True) as caught:
+ warnings.simplefilter("always")
+ compile(code, filename, mode)
+ self.assertEqual(caught, [])
+
def test_return_in_finally(self):
source = textwrap.dedent("""
def f():
@@ -2942,6 +2950,75 @@ def test_break_and_continue_in_finally(self):
""")
self.check_warning(source, f"'{kw}' in a 'finally' block")
+ def test_from_lazy_imports(self):
+ # gh-150459
+ self.check_warning(
+ "from . lazy import x",
+ "did you mean 'lazy from . import'?",
+ )
+ self.check_warning(
+ "from . lazy import x as y",
+ "did you mean 'lazy from . import'?",
+ )
+ self.check_warning(
+ "from . lazy import *",
+ "did you mean 'lazy from . import'?",
+ )
+ self.check_warning(
+ "from .. lazy import x",
+ "did you mean 'lazy from .. import'?",
+ )
+ self.check_warning(
+ "from ... lazy import x",
+ "did you mean 'lazy from ... import'?",
+ )
+ self.check_warning(
+ "from .... lazy import x",
+ "did you mean 'lazy from .... import'?",
+ )
+ self.check_warning(
+ "from . \\\n lazy import x",
+ "did you mean 'lazy from . import'?",
+ )
+ self.check_warning(
+ "from .\\\nlazy import x",
+ "did you mean 'lazy from . import'?",
+ )
+ self.check_warning(
+ "from .\tlazy import x",
+ "did you mean 'lazy from . import'?",
+ )
+
+ def test_not_from_lazy_imports(self):
+ self.check_no_warning("from .lazy import x")
+ self.check_no_warning("from .lazy import *")
+ self.check_no_warning("from ..lazy import x")
+ self.check_no_warning("from ...lazy import x")
+ self.check_no_warning("from .lazy.sub import x")
+ self.check_no_warning("from ..lazy.sub import x")
+ self.check_no_warning("from ...lazy.sub import x")
+ self.check_no_warning("from . lazier import x")
+ self.check_no_warning("from . lazy_module import x")
+ self.check_no_warning("from . lazy.sub import x")
+ self.check_no_warning("from . sub.lazy import x")
+ self.check_no_warning("from lazy import x")
+ self.check_no_warning("from lazy.sub import x")
+ self.check_no_warning("lazy from . lazy import x")
+ self.check_no_warning("from . import lazy")
+
+ def test_from_lazy_imports_as_error(self):
+ import warnings
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", SyntaxWarning)
+ with self.assertRaisesRegex(
+ SyntaxError,
+ re.escape("did you mean 'lazy from . import'?"),
+ ) as cm:
+ compile("from . lazy import x", "<test>", "exec")
+ self.assertEqual(cm.exception.lineno, 1)
+ self.assertEqual(cm.exception.offset, 8)
+ self.assertEqual(cm.exception.end_offset, 12)
+
class SyntaxErrorTestCase(unittest.TestCase):
@@ -3618,6 +3695,22 @@ def inner():
lazy from collections import deque
""", "lazy from ... import not allowed inside functions")
+ self._check_error("""\
+from os lazy import path
+""", "use 'lazy from ... ' instead of 'from ... lazy import'")
+ self._check_error("""\
+from os.path lazy import join
+""", "use 'lazy from ... ' instead of 'from ... lazy import'")
+ self._check_error("""\
+from .mod lazy import join
+""", "use 'lazy from ... ' instead of 'from ... lazy import'")
+ self._check_error("""\
+from ..mod lazy import join
+""", "use 'lazy from ... ' instead of 'from ... lazy import'")
+ self._check_error("""\
+from ...mod lazy import join
+""", "use 'lazy from ... ' instead of 'from ... lazy import'")
+
def test_lazy_import_valid_cases(self):
"""Test that lazy imports work at module level."""
# These should compile without errors
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst
new file mode 100644
index 000000000000000..a3e3e38ddcd1f43
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-21-14-28.gh-issue-150459.qpsCEl.rst
@@ -0,0 +1,3 @@
+Fix :exc:`SyntaxError` error message for ``from x lazy import y``.
+Raise :exc:`SyntaxWarning` on ``from . lazy import x``
+(with whitespace between the dots and a module named ``lazy``).
diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c
index 381c173589904ba..809f3c0a7b270e8 100644
--- a/Parser/action_helpers.c
+++ b/Parser/action_helpers.c
@@ -2,6 +2,7 @@
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_runtime.h" // _PyRuntime
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()
+#include "pycore_pyerrors.h" // _PyErr_EmitSyntaxWarning()
#include "pegen.h"
#include "string_parser.h" // _PyPegen_decode_string()
@@ -2007,11 +2008,64 @@ _PyPegen_concatenate_strings(Parser *p, asdl_expr_seq
*strings,
col_offset, end_lineno, end_col_offset, arena);
}
+static int
+_warn_relative_import_of_lazy(Parser *p, asdl_seq *dots, expr_ty module)
+{
+ // Warn about `from . lazy import x`: the whitespace between the dots and
+ // the module name is insignificant, so this is parsed exactly like
+ // `from .lazy import x` (an import of the relative module "lazy"), but it
+ // is most likely a transposition of `lazy from . import x` (PEP 810).
+ if (p->call_invalid_rules) {
+ return 0;
+ }
+
+ // Only fire if there is whitespace between the last dot and the name,
+ // i.e. not for the common `from .lazy import x` spelling.
+ Token *last_dot = asdl_seq_GET_UNTYPED(dots, asdl_seq_LEN(dots) - 1);
+ if (
+ last_dot->end_lineno == module->lineno
+ && last_dot->end_col_offset == module->col_offset
+ ) {
+ return 0;
+ }
+
+ int count = _PyPegen_seq_count_dots(dots);
+ char *buf = PyMem_RawMalloc(count + 1);
+ if (buf == NULL) {
+ PyErr_NoMemory();
+ return -1;
+ }
+ memset(buf, '.', count);
+ buf[count] = '\0';
+
+ PyObject *msg = PyUnicode_FromFormat(
+ "'from %s lazy import' is the same as 'from %slazy import'; "
+ "did you mean 'lazy from %s import'?",
+ buf, buf, buf);
+ PyMem_RawFree(buf);
+ if (msg == NULL) {
+ return -1;
+ }
+
+ int res = _PyErr_EmitSyntaxWarning(msg,
+ p->tok->filename,
+ module->lineno,
+ module->col_offset + 1,
+ module->end_lineno,
+ module->end_col_offset + 1,
+ p->tok->module);
+ Py_DECREF(msg);
+ return res;
+}
+
stmt_ty
-_PyPegen_checked_future_import(Parser *p, identifier module, asdl_alias_seq *
names,
- int level, expr_ty lazy_token, int lineno,
- int col_offset, int end_lineno, int
end_col_offset,
- PyArena *arena) {
+_PyPegen_checked_from_import(Parser *p, asdl_seq *dots, expr_ty module_name,
+ asdl_alias_seq *names, expr_ty lazy_token, int
lineno,
+ int col_offset, int end_lineno, int
end_col_offset,
+ PyArena *arena)
+{
+ identifier module = module_name->v.Name.id;
+ int level = _PyPegen_seq_count_dots(dots);
if (level == 0 && PyUnicode_CompareWithASCIIString(module, "__future__")
== 0) {
if (lazy_token) {
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(lazy_token,
@@ -2025,6 +2079,15 @@ _PyPegen_checked_future_import(Parser *p, identifier
module, asdl_alias_seq * na
}
}
}
+ else if (
+ level > 0
+ && lazy_token == NULL
+ && PyUnicode_CompareWithASCIIString(module, "lazy") == 0
+ ) {
+ if (_warn_relative_import_of_lazy(p, dots, module_name) < 0) {
+ return NULL;
+ }
+ }
return _PyAST_ImportFrom(module, names, level, lazy_token ? 1 : 0, lineno,
col_offset, end_lineno, end_col_offset, arena);
}
diff --git a/Parser/parser.c b/Parser/parser.c
index c55c081dfc3d8e2..3be5f3ad8250bd8 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -22,28 +22,28 @@ static KeywordToken *reserved_keywords[] = {
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {{NULL, -1}},
(KeywordToken[]) {
- {"if", 698},
- {"as", 696},
- {"in", 711},
+ {"if", 700},
+ {"as", 698},
+ {"in", 713},
{"or", 589},
{"is", 597},
{NULL, -1},
},
(KeywordToken[]) {
{"del", 634},
- {"def", 715},
- {"for", 710},
- {"try", 672},
+ {"def", 717},
+ {"for", 712},
+ {"try", 674},
{"and", 590},
- {"not", 719},
+ {"not", 721},
{NULL, -1},
},
(KeywordToken[]) {
- {"from", 646},
+ {"from", 650},
{"pass", 527},
- {"with", 663},
- {"elif", 703},
- {"else", 702},
+ {"with", 665},
+ {"elif", 705},
+ {"else", 704},
{"None", 628},
{"True", 627},
{NULL, -1},
@@ -52,24 +52,24 @@ static KeywordToken *reserved_keywords[] = {
{"raise", 632},
{"yield", 588},
{"break", 528},
- {"async", 714},
- {"class", 717},
- {"while", 705},
+ {"async", 716},
+ {"class", 719},
+ {"while", 707},
{"False", 629},
{"await", 598},
{NULL, -1},
},
(KeywordToken[]) {
- {"import", 647},
+ {"import", 651},
{"return", 522},
{"assert", 638},
{"global", 530},
- {"except", 693},
+ {"except", 695},
{"lambda", 622},
{NULL, -1},
},
(KeywordToken[]) {
- {"finally", 689},
+ {"finally", 691},
{NULL, -1},
},
(KeywordToken[]) {
@@ -326,222 +326,223 @@ static char *soft_keywords[] = {
#define invalid_import_type 1237
#define invalid_dotted_as_name_type 1238
#define invalid_import_from_as_name_type 1239
-#define invalid_import_from_targets_type 1240
-#define invalid_with_stmt_type 1241
-#define invalid_with_stmt_indent_type 1242
-#define invalid_try_stmt_type 1243
-#define invalid_except_stmt_type 1244
-#define invalid_except_star_stmt_type 1245
-#define invalid_finally_stmt_type 1246
-#define invalid_except_stmt_indent_type 1247
-#define invalid_except_star_stmt_indent_type 1248
-#define invalid_match_stmt_type 1249
-#define invalid_case_block_type 1250
-#define invalid_as_pattern_type 1251
-#define invalid_class_pattern_type 1252
-#define invalid_mapping_pattern_type 1253
-#define invalid_class_argument_pattern_type 1254
-#define invalid_if_stmt_type 1255
-#define invalid_elif_stmt_type 1256
-#define invalid_else_stmt_type 1257
-#define invalid_while_stmt_type 1258
-#define invalid_for_stmt_type 1259
-#define invalid_def_raw_type 1260
-#define invalid_class_def_raw_type 1261
-#define invalid_double_starred_kvpairs_type 1262
-#define invalid_kvpair_unpacking_type 1263
-#define invalid_kvpair_type 1264
-#define invalid_starred_expression_unpacking_type 1265
-#define invalid_starred_expression_unpacking_sequence_type 1266
-#define invalid_starred_expression_type 1267
-#define invalid_fstring_replacement_field_type 1268
-#define invalid_fstring_conversion_character_type 1269
-#define invalid_tstring_replacement_field_type 1270
-#define invalid_tstring_conversion_character_type 1271
-#define invalid_string_tstring_concat_type 1272
-#define invalid_arithmetic_type 1273
-#define invalid_factor_type 1274
-#define invalid_type_params_type 1275
-#define _loop0_1_type 1276
-#define _loop1_2_type 1277
-#define _loop0_3_type 1278
-#define _gather_4_type 1279
-#define _tmp_5_type 1280
-#define _tmp_6_type 1281
-#define _tmp_7_type 1282
-#define _tmp_8_type 1283
-#define _tmp_9_type 1284
-#define _tmp_10_type 1285
-#define _tmp_11_type 1286
-#define _loop1_12_type 1287
-#define _loop0_13_type 1288
-#define _gather_14_type 1289
-#define _tmp_15_type 1290
-#define _tmp_16_type 1291
-#define _loop0_17_type 1292
-#define _loop1_18_type 1293
-#define _loop0_19_type 1294
-#define _gather_20_type 1295
-#define _tmp_21_type 1296
-#define _loop0_22_type 1297
-#define _gather_23_type 1298
-#define _loop1_24_type 1299
-#define _tmp_25_type 1300
-#define _tmp_26_type 1301
-#define _loop0_27_type 1302
-#define _loop0_28_type 1303
-#define _loop1_29_type 1304
-#define _loop1_30_type 1305
-#define _loop0_31_type 1306
-#define _loop1_32_type 1307
-#define _loop0_33_type 1308
-#define _gather_34_type 1309
-#define _tmp_35_type 1310
-#define _loop1_36_type 1311
-#define _loop1_37_type 1312
-#define _loop1_38_type 1313
-#define _loop0_39_type 1314
-#define _gather_40_type 1315
-#define _tmp_41_type 1316
-#define _tmp_42_type 1317
-#define _tmp_43_type 1318
-#define _loop0_44_type 1319
-#define _gather_45_type 1320
-#define _loop0_46_type 1321
-#define _gather_47_type 1322
-#define _tmp_48_type 1323
-#define _loop0_49_type 1324
-#define _gather_50_type 1325
-#define _loop0_51_type 1326
-#define _gather_52_type 1327
-#define _loop0_53_type 1328
-#define _gather_54_type 1329
-#define _loop1_55_type 1330
-#define _loop1_56_type 1331
-#define _loop0_57_type 1332
-#define _gather_58_type 1333
-#define _loop0_59_type 1334
-#define _gather_60_type 1335
-#define _loop1_61_type 1336
-#define _loop1_62_type 1337
-#define _loop1_63_type 1338
-#define _tmp_64_type 1339
-#define _loop0_65_type 1340
-#define _gather_66_type 1341
-#define _tmp_67_type 1342
-#define _tmp_68_type 1343
-#define _tmp_69_type 1344
-#define _tmp_70_type 1345
-#define _tmp_71_type 1346
-#define _loop0_72_type 1347
-#define _loop0_73_type 1348
-#define _loop1_74_type 1349
-#define _loop1_75_type 1350
-#define _loop0_76_type 1351
-#define _loop1_77_type 1352
-#define _loop0_78_type 1353
-#define _loop0_79_type 1354
-#define _loop0_80_type 1355
-#define _loop0_81_type 1356
-#define _loop1_82_type 1357
-#define _loop1_83_type 1358
-#define _tmp_84_type 1359
-#define _loop0_85_type 1360
-#define _gather_86_type 1361
-#define _loop1_87_type 1362
-#define _loop0_88_type 1363
-#define _tmp_89_type 1364
-#define _loop0_90_type 1365
-#define _gather_91_type 1366
-#define _tmp_92_type 1367
-#define _loop0_93_type 1368
-#define _gather_94_type 1369
-#define _loop0_95_type 1370
-#define _gather_96_type 1371
-#define _loop0_97_type 1372
-#define _loop0_98_type 1373
-#define _gather_99_type 1374
-#define _loop1_100_type 1375
-#define _tmp_101_type 1376
-#define _loop0_102_type 1377
-#define _gather_103_type 1378
-#define _loop0_104_type 1379
-#define _gather_105_type 1380
-#define _tmp_106_type 1381
-#define _tmp_107_type 1382
-#define _loop0_108_type 1383
-#define _gather_109_type 1384
-#define _tmp_110_type 1385
-#define _tmp_111_type 1386
-#define _tmp_112_type 1387
-#define _tmp_113_type 1388
-#define _tmp_114_type 1389
-#define _loop1_115_type 1390
-#define _tmp_116_type 1391
-#define _tmp_117_type 1392
-#define _tmp_118_type 1393
-#define _tmp_119_type 1394
-#define _tmp_120_type 1395
-#define _loop0_121_type 1396
-#define _loop0_122_type 1397
-#define _tmp_123_type 1398
-#define _tmp_124_type 1399
-#define _tmp_125_type 1400
-#define _tmp_126_type 1401
-#define _tmp_127_type 1402
-#define _tmp_128_type 1403
-#define _tmp_129_type 1404
-#define _tmp_130_type 1405
-#define _loop0_131_type 1406
-#define _gather_132_type 1407
-#define _tmp_133_type 1408
-#define _tmp_134_type 1409
-#define _tmp_135_type 1410
-#define _tmp_136_type 1411
-#define _loop0_137_type 1412
-#define _gather_138_type 1413
-#define _tmp_139_type 1414
-#define _loop0_140_type 1415
-#define _gather_141_type 1416
-#define _loop0_142_type 1417
-#define _gather_143_type 1418
-#define _tmp_144_type 1419
-#define _loop0_145_type 1420
-#define _tmp_146_type 1421
-#define _tmp_147_type 1422
-#define _tmp_148_type 1423
-#define _tmp_149_type 1424
-#define _tmp_150_type 1425
-#define _tmp_151_type 1426
-#define _tmp_152_type 1427
-#define _tmp_153_type 1428
-#define _tmp_154_type 1429
-#define _tmp_155_type 1430
-#define _tmp_156_type 1431
-#define _tmp_157_type 1432
-#define _tmp_158_type 1433
-#define _tmp_159_type 1434
-#define _tmp_160_type 1435
-#define _tmp_161_type 1436
-#define _tmp_162_type 1437
-#define _tmp_163_type 1438
-#define _tmp_164_type 1439
-#define _tmp_165_type 1440
-#define _tmp_166_type 1441
-#define _tmp_167_type 1442
-#define _tmp_168_type 1443
-#define _tmp_169_type 1444
-#define _tmp_170_type 1445
-#define _tmp_171_type 1446
-#define _tmp_172_type 1447
-#define _tmp_173_type 1448
-#define _loop0_174_type 1449
-#define _tmp_175_type 1450
-#define _tmp_176_type 1451
-#define _tmp_177_type 1452
-#define _tmp_178_type 1453
-#define _tmp_179_type 1454
-#define _tmp_180_type 1455
+#define invalid_import_from_type 1240
+#define invalid_import_from_targets_type 1241
+#define invalid_with_stmt_type 1242
+#define invalid_with_stmt_indent_type 1243
+#define invalid_try_stmt_type 1244
+#define invalid_except_stmt_type 1245
+#define invalid_except_star_stmt_type 1246
+#define invalid_finally_stmt_type 1247
+#define invalid_except_stmt_indent_type 1248
+#define invalid_except_star_stmt_indent_type 1249
+#define invalid_match_stmt_type 1250
+#define invalid_case_block_type 1251
+#define invalid_as_pattern_type 1252
+#define invalid_class_pattern_type 1253
+#define invalid_mapping_pattern_type 1254
+#define invalid_class_argument_pattern_type 1255
+#define invalid_if_stmt_type 1256
+#define invalid_elif_stmt_type 1257
+#define invalid_else_stmt_type 1258
+#define invalid_while_stmt_type 1259
+#define invalid_for_stmt_type 1260
+#define invalid_def_raw_type 1261
+#define invalid_class_def_raw_type 1262
+#define invalid_double_starred_kvpairs_type 1263
+#define invalid_kvpair_unpacking_type 1264
+#define invalid_kvpair_type 1265
+#define invalid_starred_expression_unpacking_type 1266
+#define invalid_starred_expression_unpacking_sequence_type 1267
+#define invalid_starred_expression_type 1268
+#define invalid_fstring_replacement_field_type 1269
+#define invalid_fstring_conversion_character_type 1270
+#define invalid_tstring_replacement_field_type 1271
+#define invalid_tstring_conversion_character_type 1272
+#define invalid_string_tstring_concat_type 1273
+#define invalid_arithmetic_type 1274
+#define invalid_factor_type 1275
+#define invalid_type_params_type 1276
+#define _loop0_1_type 1277
+#define _loop1_2_type 1278
+#define _loop0_3_type 1279
+#define _gather_4_type 1280
+#define _tmp_5_type 1281
+#define _tmp_6_type 1282
+#define _tmp_7_type 1283
+#define _tmp_8_type 1284
+#define _tmp_9_type 1285
+#define _tmp_10_type 1286
+#define _tmp_11_type 1287
+#define _loop1_12_type 1288
+#define _loop0_13_type 1289
+#define _gather_14_type 1290
+#define _tmp_15_type 1291
+#define _tmp_16_type 1292
+#define _loop0_17_type 1293
+#define _loop1_18_type 1294
+#define _loop0_19_type 1295
+#define _gather_20_type 1296
+#define _tmp_21_type 1297
+#define _loop0_22_type 1298
+#define _gather_23_type 1299
+#define _loop1_24_type 1300
+#define _tmp_25_type 1301
+#define _tmp_26_type 1302
+#define _loop0_27_type 1303
+#define _loop0_28_type 1304
+#define _loop1_29_type 1305
+#define _loop1_30_type 1306
+#define _loop0_31_type 1307
+#define _loop1_32_type 1308
+#define _loop0_33_type 1309
+#define _gather_34_type 1310
+#define _tmp_35_type 1311
+#define _loop1_36_type 1312
+#define _loop1_37_type 1313
+#define _loop1_38_type 1314
+#define _loop0_39_type 1315
+#define _gather_40_type 1316
+#define _tmp_41_type 1317
+#define _tmp_42_type 1318
+#define _tmp_43_type 1319
+#define _loop0_44_type 1320
+#define _gather_45_type 1321
+#define _loop0_46_type 1322
+#define _gather_47_type 1323
+#define _tmp_48_type 1324
+#define _loop0_49_type 1325
+#define _gather_50_type 1326
+#define _loop0_51_type 1327
+#define _gather_52_type 1328
+#define _loop0_53_type 1329
+#define _gather_54_type 1330
+#define _loop1_55_type 1331
+#define _loop1_56_type 1332
+#define _loop0_57_type 1333
+#define _gather_58_type 1334
+#define _loop0_59_type 1335
+#define _gather_60_type 1336
+#define _loop1_61_type 1337
+#define _loop1_62_type 1338
+#define _loop1_63_type 1339
+#define _tmp_64_type 1340
+#define _loop0_65_type 1341
+#define _gather_66_type 1342
+#define _tmp_67_type 1343
+#define _tmp_68_type 1344
+#define _tmp_69_type 1345
+#define _tmp_70_type 1346
+#define _tmp_71_type 1347
+#define _loop0_72_type 1348
+#define _loop0_73_type 1349
+#define _loop1_74_type 1350
+#define _loop1_75_type 1351
+#define _loop0_76_type 1352
+#define _loop1_77_type 1353
+#define _loop0_78_type 1354
+#define _loop0_79_type 1355
+#define _loop0_80_type 1356
+#define _loop0_81_type 1357
+#define _loop1_82_type 1358
+#define _loop1_83_type 1359
+#define _tmp_84_type 1360
+#define _loop0_85_type 1361
+#define _gather_86_type 1362
+#define _loop1_87_type 1363
+#define _loop0_88_type 1364
+#define _tmp_89_type 1365
+#define _loop0_90_type 1366
+#define _gather_91_type 1367
+#define _tmp_92_type 1368
+#define _loop0_93_type 1369
+#define _gather_94_type 1370
+#define _loop0_95_type 1371
+#define _gather_96_type 1372
+#define _loop0_97_type 1373
+#define _loop0_98_type 1374
+#define _gather_99_type 1375
+#define _loop1_100_type 1376
+#define _tmp_101_type 1377
+#define _loop0_102_type 1378
+#define _gather_103_type 1379
+#define _loop0_104_type 1380
+#define _gather_105_type 1381
+#define _tmp_106_type 1382
+#define _tmp_107_type 1383
+#define _loop0_108_type 1384
+#define _gather_109_type 1385
+#define _tmp_110_type 1386
+#define _tmp_111_type 1387
+#define _tmp_112_type 1388
+#define _tmp_113_type 1389
+#define _tmp_114_type 1390
+#define _loop1_115_type 1391
+#define _tmp_116_type 1392
+#define _tmp_117_type 1393
+#define _tmp_118_type 1394
+#define _tmp_119_type 1395
+#define _tmp_120_type 1396
+#define _loop0_121_type 1397
+#define _loop0_122_type 1398
+#define _tmp_123_type 1399
+#define _tmp_124_type 1400
+#define _tmp_125_type 1401
+#define _tmp_126_type 1402
+#define _tmp_127_type 1403
+#define _tmp_128_type 1404
+#define _tmp_129_type 1405
+#define _tmp_130_type 1406
+#define _loop0_131_type 1407
+#define _gather_132_type 1408
+#define _tmp_133_type 1409
+#define _tmp_134_type 1410
+#define _tmp_135_type 1411
+#define _tmp_136_type 1412
+#define _loop0_137_type 1413
+#define _gather_138_type 1414
+#define _tmp_139_type 1415
+#define _loop0_140_type 1416
+#define _gather_141_type 1417
+#define _loop0_142_type 1418
+#define _gather_143_type 1419
+#define _tmp_144_type 1420
+#define _loop0_145_type 1421
+#define _tmp_146_type 1422
+#define _tmp_147_type 1423
+#define _tmp_148_type 1424
+#define _tmp_149_type 1425
+#define _tmp_150_type 1426
+#define _tmp_151_type 1427
+#define _tmp_152_type 1428
+#define _tmp_153_type 1429
+#define _tmp_154_type 1430
+#define _tmp_155_type 1431
+#define _tmp_156_type 1432
+#define _tmp_157_type 1433
+#define _tmp_158_type 1434
+#define _tmp_159_type 1435
+#define _tmp_160_type 1436
+#define _tmp_161_type 1437
+#define _tmp_162_type 1438
+#define _tmp_163_type 1439
+#define _tmp_164_type 1440
+#define _tmp_165_type 1441
+#define _tmp_166_type 1442
+#define _tmp_167_type 1443
+#define _tmp_168_type 1444
+#define _tmp_169_type 1445
+#define _tmp_170_type 1446
+#define _tmp_171_type 1447
+#define _tmp_172_type 1448
+#define _tmp_173_type 1449
+#define _loop0_174_type 1450
+#define _tmp_175_type 1451
+#define _tmp_176_type 1452
+#define _tmp_177_type 1453
+#define _tmp_178_type 1454
+#define _tmp_179_type 1455
+#define _tmp_180_type 1456
static mod_ty file_rule(Parser *p);
static mod_ty interactive_rule(Parser *p);
@@ -783,6 +784,7 @@ static void *invalid_group_rule(Parser *p);
static void *invalid_import_rule(Parser *p);
static void *invalid_dotted_as_name_rule(Parser *p);
static void *invalid_import_from_as_name_rule(Parser *p);
+static void *invalid_import_from_rule(Parser *p);
static void *invalid_import_from_targets_rule(Parser *p);
static void *invalid_with_stmt_rule(Parser *p);
static void *invalid_with_stmt_indent_rule(Parser *p);
@@ -1964,7 +1966,7 @@ compound_stmt_rule(Parser *p)
D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ',
_mark, p->mark, "&'if' if_stmt"));
stmt_ty if_stmt_var;
if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 698) //
token='if'
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 700) //
token='if'
&&
(if_stmt_var = if_stmt_rule(p)) // if_stmt
)
@@ -2048,7 +2050,7 @@ compound_stmt_rule(Parser *p)
D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ',
_mark, p->mark, "&'try' try_stmt"));
stmt_ty try_stmt_var;
if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 672) //
token='try'
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 674) //
token='try'
&&
(try_stmt_var = try_stmt_rule(p)) // try_stmt
)
@@ -2069,7 +2071,7 @@ compound_stmt_rule(Parser *p)
D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ',
_mark, p->mark, "&'while' while_stmt"));
stmt_ty while_stmt_var;
if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 705) //
token='while'
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 707) //
token='while'
&&
(while_stmt_var = while_stmt_rule(p)) // while_stmt
)
@@ -2836,7 +2838,7 @@ raise_stmt_rule(Parser *p)
&&
(a = expression_rule(p)) // expression
&&
- (_keyword_1 = _PyPegen_expect_token(p, 646)) // token='from'
+ (_keyword_1 = _PyPegen_expect_token(p, 650)) // token='from'
&&
(b = expression_rule(p)) // expression
)
@@ -3615,7 +3617,7 @@ import_name_rule(Parser *p)
if (
(lazy = _PyPegen_expect_soft_keyword(p, "lazy"),
!p->error_indicator) // "lazy"?
&&
- (_keyword = _PyPegen_expect_token(p, 647)) // token='import'
+ (_keyword = _PyPegen_expect_token(p, 651)) // token='import'
&&
(a = dotted_as_names_rule(p)) // dotted_as_names
)
@@ -3649,6 +3651,7 @@ import_name_rule(Parser *p)
}
// import_from:
+// | invalid_import_from
// | "lazy"? 'from' (('.' | '...'))* dotted_name 'import'
import_from_targets
// | "lazy"? 'from' (('.' | '...'))+ 'import' import_from_targets
static stmt_ty
@@ -3672,6 +3675,25 @@ import_from_rule(Parser *p)
UNUSED(_start_lineno); // Only used by EXTRA macro
int _start_col_offset = p->tokens[_mark]->col_offset;
UNUSED(_start_col_offset); // Only used by EXTRA macro
+ if (p->call_invalid_rules) { // invalid_import_from
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ',
_mark, p->mark, "invalid_import_from"));
+ void *invalid_import_from_var;
+ if (
+ (invalid_import_from_var = invalid_import_from_rule(p)) //
invalid_import_from
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n",
p->level, ' ', _mark, p->mark, "invalid_import_from"));
+ _res = invalid_import_from_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level,
' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark,
"invalid_import_from"));
+ }
{ // "lazy"? 'from' (('.' | '...'))* dotted_name 'import'
import_from_targets
if (p->error_indicator) {
p->level--;
@@ -3687,13 +3709,13 @@ import_from_rule(Parser *p)
if (
(lazy = _PyPegen_expect_soft_keyword(p, "lazy"),
!p->error_indicator) // "lazy"?
&&
- (_keyword = _PyPegen_expect_token(p, 646)) // token='from'
+ (_keyword = _PyPegen_expect_token(p, 650)) // token='from'
&&
(a = _loop0_17_rule(p)) // (('.' | '...'))*
&&
(b = dotted_name_rule(p)) // dotted_name
&&
- (_keyword_1 = _PyPegen_expect_token(p, 647)) // token='import'
+ (_keyword_1 = _PyPegen_expect_token(p, 651)) // token='import'
&&
(c = import_from_targets_rule(p)) // import_from_targets
)
@@ -3708,7 +3730,7 @@ import_from_rule(Parser *p)
UNUSED(_end_lineno); // Only used by EXTRA macro
int _end_col_offset = _token->end_col_offset;
UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _PyPegen_checked_future_import ( p , b -> v . Name . id , c
, _PyPegen_seq_count_dots ( a ) , lazy , EXTRA );
+ _res = _PyPegen_checked_from_import ( p , a , b , c , lazy , EXTRA
);
if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {
p->error_indicator = 1;
p->level--;
@@ -3734,11 +3756,11 @@ import_from_rule(Parser *p)
if (
(lazy = _PyPegen_expect_soft_keyword(p, "lazy"),
!p->error_indicator) // "lazy"?
&&
- (_keyword = _PyPegen_expect_token(p, 646)) // token='from'
+ (_keyword = _PyPegen_expect_token(p, 650)) // token='from'
&&
(a = _loop1_18_rule(p)) // (('.' | '...'))+
&&
- (_keyword_1 = _PyPegen_expect_token(p, 647)) // token='import'
+ (_keyword_1 = _PyPegen_expect_token(p, 651)) // token='import'
&&
(b = import_from_targets_rule(p)) // import_from_targets
)
@@ -4525,7 +4547,7 @@ class_def_raw_rule(Parser *p)
asdl_stmt_seq* c;
void *t;
if (
- (_keyword = _PyPegen_expect_token(p, 717)) // token='class'
+ (_keyword = _PyPegen_expect_token(p, 719)) // token='class'
&&
(a = _PyPegen_name_token(p)) // NAME
&&
@@ -4692,7 +4714,7 @@ function_def_raw_rule(Parser *p)
void *t;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 715)) // token='def'
+ (_keyword = _PyPegen_expect_token(p, 717)) // token='def'
&&
(n = _PyPegen_name_token(p)) // NAME
&&
@@ -4753,9 +4775,9 @@ function_def_raw_rule(Parser *p)
void *t;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 715)) // token='def'
+ (_keyword_1 = _PyPegen_expect_token(p, 717)) // token='def'
&&
(n = _PyPegen_name_token(p)) // NAME
&&
@@ -6093,7 +6115,7 @@ if_stmt_rule(Parser *p)
asdl_stmt_seq* b;
stmt_ty c;
if (
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(a = named_expression_rule(p)) // named_expression
&&
@@ -6138,7 +6160,7 @@ if_stmt_rule(Parser *p)
asdl_stmt_seq* b;
void *c;
if (
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(a = named_expression_rule(p)) // named_expression
&&
@@ -6233,7 +6255,7 @@ elif_stmt_rule(Parser *p)
asdl_stmt_seq* b;
stmt_ty c;
if (
- (_keyword = _PyPegen_expect_token(p, 703)) // token='elif'
+ (_keyword = _PyPegen_expect_token(p, 705)) // token='elif'
&&
(a = named_expression_rule(p)) // named_expression
&&
@@ -6278,7 +6300,7 @@ elif_stmt_rule(Parser *p)
asdl_stmt_seq* b;
void *c;
if (
- (_keyword = _PyPegen_expect_token(p, 703)) // token='elif'
+ (_keyword = _PyPegen_expect_token(p, 705)) // token='elif'
&&
(a = named_expression_rule(p)) // named_expression
&&
@@ -6359,7 +6381,7 @@ else_block_rule(Parser *p)
Token * _literal;
asdl_stmt_seq* b;
if (
- (_keyword = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword = _PyPegen_expect_token(p, 704)) // token='else'
&&
(_literal = _PyPegen_expect_forced_token(p, 11, ":")) //
forced_token=':'
&&
@@ -6438,7 +6460,7 @@ while_stmt_rule(Parser *p)
asdl_stmt_seq* b;
void *c;
if (
- (_keyword = _PyPegen_expect_token(p, 705)) // token='while'
+ (_keyword = _PyPegen_expect_token(p, 707)) // token='while'
&&
(a = named_expression_rule(p)) // named_expression
&&
@@ -6538,11 +6560,11 @@ for_stmt_rule(Parser *p)
expr_ty t;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword = _PyPegen_expect_token(p, 712)) // token='for'
&&
(t = star_targets_rule(p)) // star_targets
&&
- (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in'
&&
(_cut_var = 1)
&&
@@ -6600,13 +6622,13 @@ for_stmt_rule(Parser *p)
expr_ty t;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='for'
&&
(t = star_targets_rule(p)) // star_targets
&&
- (_keyword_2 = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword_2 = _PyPegen_expect_token(p, 713)) // token='in'
&&
(_cut_var = 1)
&&
@@ -6735,7 +6757,7 @@ with_stmt_rule(Parser *p)
asdl_stmt_seq* b;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
@@ -6786,7 +6808,7 @@ with_stmt_rule(Parser *p)
asdl_stmt_seq* b;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword = _PyPegen_expect_token(p, 665)) // token='with'
&&
(a = (asdl_withitem_seq*)_gather_34_rule(p)) // ','.with_item+
&&
@@ -6835,9 +6857,9 @@ with_stmt_rule(Parser *p)
asdl_withitem_seq* a;
asdl_stmt_seq* b;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword_1 = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
@@ -6887,9 +6909,9 @@ with_stmt_rule(Parser *p)
asdl_stmt_seq* b;
void *tc;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword_1 = _PyPegen_expect_token(p, 665)) // token='with'
&&
(a = (asdl_withitem_seq*)_gather_34_rule(p)) // ','.with_item+
&&
@@ -6975,7 +6997,7 @@ with_item_rule(Parser *p)
if (
(e = expression_rule(p)) // expression
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(t = star_target_rule(p)) // star_target
&&
@@ -7100,7 +7122,7 @@ try_stmt_rule(Parser *p)
asdl_stmt_seq* b;
asdl_stmt_seq* f;
if (
- (_keyword = _PyPegen_expect_token(p, 672)) // token='try'
+ (_keyword = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_forced_token(p, 11, ":")) //
forced_token=':'
&&
@@ -7144,7 +7166,7 @@ try_stmt_rule(Parser *p)
asdl_excepthandler_seq* ex;
void *f;
if (
- (_keyword = _PyPegen_expect_token(p, 672)) // token='try'
+ (_keyword = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_forced_token(p, 11, ":")) //
forced_token=':'
&&
@@ -7192,7 +7214,7 @@ try_stmt_rule(Parser *p)
asdl_excepthandler_seq* ex;
void *f;
if (
- (_keyword = _PyPegen_expect_token(p, 672)) // token='try'
+ (_keyword = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_forced_token(p, 11, ":")) //
forced_token=':'
&&
@@ -7291,7 +7313,7 @@ except_block_rule(Parser *p)
asdl_stmt_seq* b;
expr_ty e;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(e = expression_rule(p)) // expression
&&
@@ -7335,11 +7357,11 @@ except_block_rule(Parser *p)
expr_ty e;
expr_ty t;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(e = expression_rule(p)) // expression
&&
- (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as'
&&
(t = _PyPegen_name_token(p)) // NAME
&&
@@ -7381,7 +7403,7 @@ except_block_rule(Parser *p)
asdl_stmt_seq* b;
expr_ty e;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(e = expressions_rule(p)) // expressions
&&
@@ -7422,7 +7444,7 @@ except_block_rule(Parser *p)
Token * _literal;
asdl_stmt_seq* b;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -7534,7 +7556,7 @@ except_star_block_rule(Parser *p)
asdl_stmt_seq* b;
expr_ty e;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -7581,13 +7603,13 @@ except_star_block_rule(Parser *p)
expr_ty e;
expr_ty t;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
(e = expression_rule(p)) // expression
&&
- (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as'
&&
(t = _PyPegen_name_token(p)) // NAME
&&
@@ -7630,7 +7652,7 @@ except_star_block_rule(Parser *p)
asdl_stmt_seq* b;
expr_ty e;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -7730,7 +7752,7 @@ finally_block_rule(Parser *p)
Token * _literal;
asdl_stmt_seq* a;
if (
- (_keyword = _PyPegen_expect_token(p, 689)) // token='finally'
+ (_keyword = _PyPegen_expect_token(p, 691)) // token='finally'
&&
(_literal = _PyPegen_expect_forced_token(p, 11, ":")) //
forced_token=':'
&&
@@ -8038,7 +8060,7 @@ guard_rule(Parser *p)
Token * _keyword;
expr_ty guard;
if (
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(guard = named_expression_rule(p)) // named_expression
)
@@ -8233,7 +8255,7 @@ as_pattern_rule(Parser *p)
if (
(pattern = or_pattern_rule(p)) // or_pattern
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(target = pattern_capture_target_rule(p)) //
pattern_capture_target
)
@@ -11728,11 +11750,11 @@ if_expression_rule(Parser *p)
if (
(a = disjunction_rule(p)) // disjunction
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
- (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else'
&&
(c = expression_rule(p)) // expression
)
@@ -11799,7 +11821,7 @@ yield_expr_rule(Parser *p)
if (
(_keyword = _PyPegen_expect_token(p, 588)) // token='yield'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 646)) // token='from'
+ (_keyword_1 = _PyPegen_expect_token(p, 650)) // token='from'
&&
(a = expression_rule(p)) // expression
)
@@ -12681,7 +12703,7 @@ inversion_rule(Parser *p)
Token * _keyword;
expr_ty a;
if (
- (_keyword = _PyPegen_expect_token(p, 719)) // token='not'
+ (_keyword = _PyPegen_expect_token(p, 721)) // token='not'
&&
(a = inversion_rule(p)) // inversion
)
@@ -13335,9 +13357,9 @@ notin_bitwise_or_rule(Parser *p)
Token * _keyword_1;
expr_ty a;
if (
- (_keyword = _PyPegen_expect_token(p, 719)) // token='not'
+ (_keyword = _PyPegen_expect_token(p, 721)) // token='not'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in'
&&
(a = bitwise_or_rule(p)) // bitwise_or
)
@@ -13383,7 +13405,7 @@ in_bitwise_or_rule(Parser *p)
Token * _keyword;
expr_ty a;
if (
- (_keyword = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword = _PyPegen_expect_token(p, 713)) // token='in'
&&
(a = bitwise_or_rule(p)) // bitwise_or
)
@@ -13432,7 +13454,7 @@ isnot_bitwise_or_rule(Parser *p)
if (
(_keyword = _PyPegen_expect_token(p, 597)) // token='is'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 719)) // token='not'
+ (_keyword_1 = _PyPegen_expect_token(p, 721)) // token='not'
&&
(a = bitwise_or_rule(p)) // bitwise_or
)
@@ -18091,13 +18113,13 @@ for_if_clause_rule(Parser *p)
expr_ty b;
asdl_expr_seq* c;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
&&
- (_keyword_1 = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='for'
&&
(a = star_targets_rule(p)) // star_targets
&&
- (_keyword_2 = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword_2 = _PyPegen_expect_token(p, 713)) // token='in'
&&
(_cut_var = 1)
&&
@@ -18136,11 +18158,11 @@ for_if_clause_rule(Parser *p)
expr_ty b;
asdl_expr_seq* c;
if (
- (_keyword = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword = _PyPegen_expect_token(p, 712)) // token='for'
&&
(a = star_targets_rule(p)) // star_targets
&&
- (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in'
&&
(_cut_var = 1)
&&
@@ -21467,11 +21489,11 @@ expression_without_invalid_rule(Parser *p)
if (
(a = disjunction_rule(p)) // disjunction
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
- (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else'
&&
(c = expression_rule(p)) // expression
)
@@ -21771,7 +21793,7 @@ invalid_expression_rule(Parser *p)
if (
(a = disjunction_rule(p)) // disjunction
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
@@ -21804,11 +21826,11 @@ invalid_expression_rule(Parser *p)
if (
(a = disjunction_rule(p)) // disjunction
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
- (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else'
&&
_PyPegen_lookahead_for_expr(0, expression_rule, p)
)
@@ -21840,11 +21862,11 @@ invalid_expression_rule(Parser *p)
if (
(a = (stmt_ty)_tmp_118_rule(p)) // pass_stmt | break_stmt |
continue_stmt
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
- (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else'
&&
(c = simple_stmt_rule(p)) // simple_stmt
)
@@ -21963,11 +21985,11 @@ invalid_if_expression_rule(Parser *p)
if (
(disjunction_var = disjunction_rule(p)) // disjunction
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
- (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else'
&&
(a = _PyPegen_expect_token(p, 16)) // token='*'
)
@@ -21999,11 +22021,11 @@ invalid_if_expression_rule(Parser *p)
if (
(disjunction_var = disjunction_rule(p)) // disjunction
&&
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(b = disjunction_rule(p)) // disjunction
&&
- (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='else'
&&
(a = _PyPegen_expect_token(p, 35)) // token='**'
)
@@ -22472,7 +22494,7 @@ invalid_raise_stmt_rule(Parser *p)
if (
(a = _PyPegen_expect_token(p, 632)) // token='raise'
&&
- (b = _PyPegen_expect_token(p, 646)) // token='from'
+ (b = _PyPegen_expect_token(p, 650)) // token='from'
)
{
D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s
succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' 'from'"));
@@ -22502,7 +22524,7 @@ invalid_raise_stmt_rule(Parser *p)
&&
(expression_var = expression_rule(p)) // expression
&&
- (a = _PyPegen_expect_token(p, 646)) // token='from'
+ (a = _PyPegen_expect_token(p, 650)) // token='from'
)
{
D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s
succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression 'from'"));
@@ -24131,7 +24153,7 @@ invalid_with_item_rule(Parser *p)
if (
(expression_var = expression_rule(p)) // expression
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(a = expression_rule(p)) // expression
&&
@@ -24181,13 +24203,13 @@ invalid_for_if_clause_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
void *_tmp_136_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword = _PyPegen_expect_token(p, 712)) // token='for'
&&
(_tmp_136_var = _tmp_136_rule(p)) // bitwise_or ((','
bitwise_or))* ','?
&&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 711) //
token='in'
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 713) //
token='in'
)
{
D(fprintf(stderr, "%*c+ invalid_for_if_clause[%d-%d]: %s
succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' (bitwise_or ((','
bitwise_or))* ','?) !'in'"));
@@ -24233,9 +24255,9 @@ invalid_for_target_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
expr_ty a;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword = _PyPegen_expect_token(p, 712)) // token='for'
&&
(a = star_expressions_rule(p)) // star_expressions
)
@@ -24365,11 +24387,11 @@ invalid_import_rule(Parser *p)
Token * a;
expr_ty dotted_name_var;
if (
- (a = _PyPegen_expect_token(p, 647)) // token='import'
+ (a = _PyPegen_expect_token(p, 651)) // token='import'
&&
(_gather_138_var = _gather_138_rule(p)) // ','.dotted_name+
&&
- (_keyword = _PyPegen_expect_token(p, 646)) // token='from'
+ (_keyword = _PyPegen_expect_token(p, 650)) // token='from'
&&
(dotted_name_var = dotted_name_rule(p)) // dotted_name
)
@@ -24396,7 +24418,7 @@ invalid_import_rule(Parser *p)
Token * _keyword;
Token * token;
if (
- (_keyword = _PyPegen_expect_token(p, 647)) // token='import'
+ (_keyword = _PyPegen_expect_token(p, 651)) // token='import'
&&
(token = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
)
@@ -24445,7 +24467,7 @@ invalid_dotted_as_name_rule(Parser *p)
if (
(dotted_name_var = dotted_name_rule(p)) // dotted_name
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
_PyPegen_lookahead(0, _tmp_139_rule, p)
&&
@@ -24496,7 +24518,7 @@ invalid_import_from_as_name_rule(Parser *p)
if (
(name_var = _PyPegen_name_token(p)) // NAME
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
_PyPegen_lookahead(0, _tmp_139_rule, p)
&&
@@ -24522,6 +24544,65 @@ invalid_import_from_as_name_rule(Parser *p)
return _res;
}
+// invalid_import_from:
+// | 'from' (('.' | '...'))* dotted_name "lazy" 'import'
import_from_targets
+static void *
+invalid_import_from_rule(Parser *p)
+{
+ if (p->level++ == MAXSTACK ||
_Py_ReachedRecursionLimitWithMargin(PyThreadState_Get(), 1)) {
+ _Pypegen_stack_overflow(p);
+ }
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'from' (('.' | '...'))* dotted_name "lazy" 'import'
import_from_targets
+ if (p->error_indicator) {
+ p->level--;
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_import_from[%d-%d]: %s\n", p->level, '
', _mark, p->mark, "'from' (('.' | '...'))* dotted_name \"lazy\" 'import'
import_from_targets"));
+ Token * _keyword;
+ Token * _keyword_1;
+ asdl_seq * _loop0_17_var;
+ expr_ty a;
+ expr_ty dotted_name_var;
+ asdl_alias_seq* import_from_targets_var;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 650)) // token='from'
+ &&
+ (_loop0_17_var = _loop0_17_rule(p)) // (('.' | '...'))*
+ &&
+ (dotted_name_var = dotted_name_rule(p)) // dotted_name
+ &&
+ (a = _PyPegen_expect_soft_keyword(p, "lazy")) //
soft_keyword='"lazy"'
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 651)) // token='import'
+ &&
+ (import_from_targets_var = import_from_targets_rule(p)) //
import_from_targets
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_import_from[%d-%d]: %s
succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))*
dotted_name \"lazy\" 'import' import_from_targets"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "use 'lazy from ...
' instead of 'from ... lazy import'" );
+ if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ p->level--;
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_import_from[%d-%d]: %s failed!\n",
p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'
(('.' | '...'))* dotted_name \"lazy\" 'import' import_from_targets"));
+ }
+ _res = NULL;
+ done:
+ p->level--;
+ return _res;
+}
+
// invalid_import_from_targets: import_from_as_names ',' NEWLINE | NEWLINE
static void *
invalid_import_from_targets_rule(Parser *p)
@@ -24624,9 +24705,9 @@ invalid_with_stmt_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
Token * trailing;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as'
star_target])+
&&
@@ -24660,9 +24741,9 @@ invalid_with_stmt_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
Token * newline_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as'
star_target])+
&&
@@ -24698,9 +24779,9 @@ invalid_with_stmt_rule(Parser *p)
UNUSED(_opt_var_1); // Silence compiler warnings
Token * newline_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
@@ -24760,9 +24841,9 @@ invalid_with_stmt_indent_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (a = _PyPegen_expect_token(p, 663)) // token='with'
+ (a = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as'
star_target])+
&&
@@ -24803,9 +24884,9 @@ invalid_with_stmt_indent_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (a = _PyPegen_expect_token(p, 663)) // token='with'
+ (a = _PyPegen_expect_token(p, 665)) // token='with'
&&
(_literal = _PyPegen_expect_token(p, 7)) // token='('
&&
@@ -24868,7 +24949,7 @@ invalid_try_stmt_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 672)) // token='try'
+ (a = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -24900,7 +24981,7 @@ invalid_try_stmt_rule(Parser *p)
Token * _literal;
asdl_stmt_seq* block_var;
if (
- (_keyword = _PyPegen_expect_token(p, 672)) // token='try'
+ (_keyword = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -24939,7 +25020,7 @@ invalid_try_stmt_rule(Parser *p)
Token * b;
expr_ty expression_var;
if (
- (_keyword = _PyPegen_expect_token(p, 672)) // token='try'
+ (_keyword = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -24947,7 +25028,7 @@ invalid_try_stmt_rule(Parser *p)
&&
(_loop1_36_var = _loop1_36_rule(p)) // except_block+
&&
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(b = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -24986,7 +25067,7 @@ invalid_try_stmt_rule(Parser *p)
UNUSED(_opt_var); // Silence compiler warnings
Token * a;
if (
- (_keyword = _PyPegen_expect_token(p, 672)) // token='try'
+ (_keyword = _PyPegen_expect_token(p, 674)) // token='try'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -24994,7 +25075,7 @@ invalid_try_stmt_rule(Parser *p)
&&
(_loop1_37_var = _loop1_37_rule(p)) // except_star_block+
&&
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_opt_var = _tmp_146_rule(p), !p->error_indicator) // [expression
['as' NAME]]
&&
@@ -25051,7 +25132,7 @@ invalid_except_stmt_rule(Parser *p)
expr_ty expressions_var;
expr_ty name_var;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(a = expression_rule(p)) // expression
&&
@@ -25059,7 +25140,7 @@ invalid_except_stmt_rule(Parser *p)
&&
(expressions_var = expressions_rule(p)) // expressions
&&
- (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as'
&&
(name_var = _PyPegen_name_token(p)) // NAME
&&
@@ -25091,7 +25172,7 @@ invalid_except_stmt_rule(Parser *p)
expr_ty expression_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(expression_var = expression_rule(p)) // expression
&&
@@ -25122,7 +25203,7 @@ invalid_except_stmt_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(newline_var = _PyPegen_expect_token(p, NEWLINE)) //
token='NEWLINE'
)
@@ -25153,11 +25234,11 @@ invalid_except_stmt_rule(Parser *p)
asdl_stmt_seq* block_var;
expr_ty expression_var;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(expression_var = expression_rule(p)) // expression
&&
- (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as'
&&
(a = expression_rule(p)) // expression
&&
@@ -25217,7 +25298,7 @@ invalid_except_star_stmt_rule(Parser *p)
expr_ty expressions_var;
expr_ty name_var;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -25227,7 +25308,7 @@ invalid_except_star_stmt_rule(Parser *p)
&&
(expressions_var = expressions_rule(p)) // expressions
&&
- (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as'
&&
(name_var = _PyPegen_name_token(p)) // NAME
&&
@@ -25260,7 +25341,7 @@ invalid_except_star_stmt_rule(Parser *p)
expr_ty expression_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -25294,7 +25375,7 @@ invalid_except_star_stmt_rule(Parser *p)
void *_tmp_147_var;
Token * a;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -25328,13 +25409,13 @@ invalid_except_star_stmt_rule(Parser *p)
asdl_stmt_seq* block_var;
expr_ty expression_var;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
(expression_var = expression_rule(p)) // expression
&&
- (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword_1 = _PyPegen_expect_token(p, 698)) // token='as'
&&
(a = expression_rule(p)) // expression
&&
@@ -25385,7 +25466,7 @@ invalid_finally_stmt_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 689)) // token='finally'
+ (a = _PyPegen_expect_token(p, 691)) // token='finally'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -25441,7 +25522,7 @@ invalid_except_stmt_indent_rule(Parser *p)
expr_ty expression_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(expression_var = expression_rule(p)) // expression
&&
@@ -25477,7 +25558,7 @@ invalid_except_stmt_indent_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -25533,7 +25614,7 @@ invalid_except_star_stmt_indent_rule(Parser *p)
expr_ty expression_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 693)) // token='except'
+ (a = _PyPegen_expect_token(p, 695)) // token='except'
&&
(_literal = _PyPegen_expect_token(p, 16)) // token='*'
&&
@@ -25810,7 +25891,7 @@ invalid_as_pattern_rule(Parser *p)
if (
(or_pattern_var = or_pattern_rule(p)) // or_pattern
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(a = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"'
)
@@ -25840,7 +25921,7 @@ invalid_as_pattern_rule(Parser *p)
if (
(or_pattern_var = or_pattern_rule(p)) // or_pattern
&&
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(a = expression_rule(p)) // expression
)
@@ -26056,7 +26137,7 @@ invalid_if_stmt_rule(Parser *p)
expr_ty named_expression_var;
Token * newline_var;
if (
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(named_expression_var = named_expression_rule(p)) //
named_expression
&&
@@ -26087,7 +26168,7 @@ invalid_if_stmt_rule(Parser *p)
expr_ty a_1;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 698)) // token='if'
+ (a = _PyPegen_expect_token(p, 700)) // token='if'
&&
(a_1 = named_expression_rule(p)) // named_expression
&&
@@ -26142,7 +26223,7 @@ invalid_elif_stmt_rule(Parser *p)
expr_ty named_expression_var;
Token * newline_var;
if (
- (_keyword = _PyPegen_expect_token(p, 703)) // token='elif'
+ (_keyword = _PyPegen_expect_token(p, 705)) // token='elif'
&&
(named_expression_var = named_expression_rule(p)) //
named_expression
&&
@@ -26173,7 +26254,7 @@ invalid_elif_stmt_rule(Parser *p)
expr_ty named_expression_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 703)) // token='elif'
+ (a = _PyPegen_expect_token(p, 705)) // token='elif'
&&
(named_expression_var = named_expression_rule(p)) //
named_expression
&&
@@ -26226,7 +26307,7 @@ invalid_else_stmt_rule(Parser *p)
Token * a;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 702)) // token='else'
+ (a = _PyPegen_expect_token(p, 704)) // token='else'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
@@ -26259,13 +26340,13 @@ invalid_else_stmt_rule(Parser *p)
Token * _literal;
asdl_stmt_seq* block_var;
if (
- (_keyword = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword = _PyPegen_expect_token(p, 704)) // token='else'
&&
(_literal = _PyPegen_expect_token(p, 11)) // token=':'
&&
(block_var = block_rule(p)) // block
&&
- (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='elif'
+ (_keyword_1 = _PyPegen_expect_token(p, 705)) // token='elif'
)
{
D(fprintf(stderr, "%*c+ invalid_else_stmt[%d-%d]: %s
succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block 'elif'"));
@@ -26312,7 +26393,7 @@ invalid_while_stmt_rule(Parser *p)
expr_ty named_expression_var;
Token * newline_var;
if (
- (_keyword = _PyPegen_expect_token(p, 705)) // token='while'
+ (_keyword = _PyPegen_expect_token(p, 707)) // token='while'
&&
(named_expression_var = named_expression_rule(p)) //
named_expression
&&
@@ -26343,7 +26424,7 @@ invalid_while_stmt_rule(Parser *p)
expr_ty named_expression_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 705)) // token='while'
+ (a = _PyPegen_expect_token(p, 707)) // token='while'
&&
(named_expression_var = named_expression_rule(p)) //
named_expression
&&
@@ -26402,13 +26483,13 @@ invalid_for_stmt_rule(Parser *p)
expr_ty star_expressions_var;
expr_ty star_targets_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword = _PyPegen_expect_token(p, 712)) // token='for'
&&
(star_targets_var = star_targets_rule(p)) // star_targets
&&
- (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword_1 = _PyPegen_expect_token(p, 713)) // token='in'
&&
(star_expressions_var = star_expressions_rule(p)) //
star_expressions
&&
@@ -26443,13 +26524,13 @@ invalid_for_stmt_rule(Parser *p)
expr_ty star_expressions_var;
expr_ty star_targets_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (a = _PyPegen_expect_token(p, 710)) // token='for'
+ (a = _PyPegen_expect_token(p, 712)) // token='for'
&&
(star_targets_var = star_targets_rule(p)) // star_targets
&&
- (_keyword = _PyPegen_expect_token(p, 711)) // token='in'
+ (_keyword = _PyPegen_expect_token(p, 713)) // token='in'
&&
(star_expressions_var = star_expressions_rule(p)) //
star_expressions
&&
@@ -26515,9 +26596,9 @@ invalid_def_raw_rule(Parser *p)
expr_ty name_var;
Token * newline_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (a = _PyPegen_expect_token(p, 715)) // token='def'
+ (a = _PyPegen_expect_token(p, 717)) // token='def'
&&
(name_var = _PyPegen_name_token(p)) // NAME
&&
@@ -26574,9 +26655,9 @@ invalid_def_raw_rule(Parser *p)
asdl_stmt_seq* block_var;
expr_ty name_var;
if (
- (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator)
// 'async'?
+ (_opt_var = _PyPegen_expect_token(p, 716), !p->error_indicator)
// 'async'?
&&
- (_keyword = _PyPegen_expect_token(p, 715)) // token='def'
+ (_keyword = _PyPegen_expect_token(p, 717)) // token='def'
&&
(name_var = _PyPegen_name_token(p)) // NAME
&&
@@ -26640,7 +26721,7 @@ invalid_class_def_raw_rule(Parser *p)
expr_ty name_var;
Token * newline_var;
if (
- (_keyword = _PyPegen_expect_token(p, 717)) // token='class'
+ (_keyword = _PyPegen_expect_token(p, 719)) // token='class'
&&
(name_var = _PyPegen_name_token(p)) // NAME
&&
@@ -26679,7 +26760,7 @@ invalid_class_def_raw_rule(Parser *p)
expr_ty name_var;
Token * newline_var;
if (
- (a = _PyPegen_expect_token(p, 717)) // token='class'
+ (a = _PyPegen_expect_token(p, 719)) // token='class'
&&
(name_var = _PyPegen_name_token(p)) // NAME
&&
@@ -28315,7 +28396,7 @@ invalid_arithmetic_rule(Parser *p)
&&
(_tmp_157_var = _tmp_157_rule(p)) // '+' | '-' | '*' | '/' | '%'
| '//' | '@'
&&
- (a = _PyPegen_expect_token(p, 719)) // token='not'
+ (a = _PyPegen_expect_token(p, 721)) // token='not'
&&
(b = inversion_rule(p)) // inversion
)
@@ -28364,7 +28445,7 @@ invalid_factor_rule(Parser *p)
if (
(_tmp_158_var = _tmp_158_rule(p)) // '+' | '-' | '~'
&&
- (a = _PyPegen_expect_token(p, 719)) // token='not'
+ (a = _PyPegen_expect_token(p, 721)) // token='not'
&&
(b = factor_rule(p)) // factor
)
@@ -28711,7 +28792,7 @@ _tmp_5_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'import'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 647)) // token='import'
+ (_keyword = _PyPegen_expect_token(p, 651)) // token='import'
)
{
D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'import'"));
@@ -28730,7 +28811,7 @@ _tmp_5_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'from'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 646)) // token='from'
+ (_keyword = _PyPegen_expect_token(p, 650)) // token='from'
)
{
D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'from'"));
@@ -28787,7 +28868,7 @@ _tmp_6_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'def'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 715)) // token='def'
+ (_keyword = _PyPegen_expect_token(p, 717)) // token='def'
)
{
D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'def'"));
@@ -28825,7 +28906,7 @@ _tmp_6_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'async'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
)
{
D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'async'"));
@@ -28863,7 +28944,7 @@ _tmp_7_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_7[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'class'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 717)) // token='class'
+ (_keyword = _PyPegen_expect_token(p, 719)) // token='class'
)
{
D(fprintf(stderr, "%*c+ _tmp_7[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'class'"));
@@ -28920,7 +29001,7 @@ _tmp_8_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'with'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 663)) // token='with'
+ (_keyword = _PyPegen_expect_token(p, 665)) // token='with'
)
{
D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'with'"));
@@ -28939,7 +29020,7 @@ _tmp_8_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'async'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
)
{
D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'async'"));
@@ -28977,7 +29058,7 @@ _tmp_9_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'for'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 710)) // token='for'
+ (_keyword = _PyPegen_expect_token(p, 712)) // token='for'
)
{
D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'for'"));
@@ -28996,7 +29077,7 @@ _tmp_9_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'async'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 714)) // token='async'
+ (_keyword = _PyPegen_expect_token(p, 716)) // token='async'
)
{
D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level,
' ', _mark, p->mark, "'async'"));
@@ -29697,7 +29778,7 @@ _tmp_21_rule(Parser *p)
Token * _keyword;
expr_ty z;
if (
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(z = _PyPegen_name_token(p)) // NAME
)
@@ -35669,7 +35750,7 @@ _tmp_117_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'else'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 702)) // token='else'
+ (_keyword = _PyPegen_expect_token(p, 704)) // token='else'
)
{
D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n",
p->level, ' ', _mark, p->mark, "'else'"));
@@ -37332,7 +37413,7 @@ _tmp_144_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'except'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 693)) // token='except'
+ (_keyword = _PyPegen_expect_token(p, 695)) // token='except'
)
{
D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n",
p->level, ' ', _mark, p->mark, "'except'"));
@@ -37351,7 +37432,7 @@ _tmp_144_rule(Parser *p)
D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark,
p->mark, "'finally'"));
Token * _keyword;
if (
- (_keyword = _PyPegen_expect_token(p, 689)) // token='finally'
+ (_keyword = _PyPegen_expect_token(p, 691)) // token='finally'
)
{
D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n",
p->level, ' ', _mark, p->mark, "'finally'"));
@@ -38653,7 +38734,7 @@ _tmp_166_rule(Parser *p)
Token * _keyword;
expr_ty z;
if (
- (_keyword = _PyPegen_expect_token(p, 698)) // token='if'
+ (_keyword = _PyPegen_expect_token(p, 700)) // token='if'
&&
(z = disjunction_rule(p)) // disjunction
)
@@ -39389,7 +39470,7 @@ _tmp_180_rule(Parser *p)
Token * _keyword;
expr_ty star_target_var;
if (
- (_keyword = _PyPegen_expect_token(p, 696)) // token='as'
+ (_keyword = _PyPegen_expect_token(p, 698)) // token='as'
&&
(star_target_var = star_target_rule(p)) // star_target
)
diff --git a/Parser/pegen.h b/Parser/pegen.h
index 5c461e82a7f0fa7..2b9b1fed8452c8d 100644
--- a/Parser/pegen.h
+++ b/Parser/pegen.h
@@ -365,8 +365,10 @@ mod_ty _PyPegen_make_module(Parser *, asdl_stmt_seq *);
void *_PyPegen_arguments_parsing_error(Parser *, expr_ty);
expr_ty _PyPegen_get_last_comprehension_item(comprehension_ty comprehension);
void *_PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args,
asdl_comprehension_seq *comprehensions);
-stmt_ty _PyPegen_checked_future_import(Parser *p, identifier module,
asdl_alias_seq *,
- int, expr_ty, int, int, int, int,
PyArena *);
+stmt_ty _PyPegen_checked_from_import(Parser *p, asdl_seq *dots, expr_ty
module_name,
+ asdl_alias_seq *names, expr_ty
lazy_token, int lineno,
+ int col_offset, int end_lineno, int
end_col_offset,
+ PyArena *arena);
asdl_stmt_seq* _PyPegen_register_stmts(Parser *p, asdl_stmt_seq* stmts);
stmt_ty _PyPegen_register_stmt(Parser *p, stmt_ty s);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]