From 60dafbb1f35de14840b3d439f5ef1dfd6cde44e6 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Thu, 12 Feb 2026 00:33:47 +0000 Subject: [PATCH] gh-142349: Fix build errors from PEP 810 The PEP 810 commit added an is_lazy parameter to _PyAST_ImportFrom but did not update the test_peg_generator test that calls this function directly from a custom grammar. It also introduced a trailing comma in the PyImport_LazyImportsMode enum which is invalid under C++03 with -pedantic-errors, breaking test_cppext. Pass 0 for the new is_lazy argument in the test grammar's _PyAST_ImportFrom calls, and remove the trailing comma from the enum definition to restore C++03 compatibility. --- Include/import.h | 2 +- Lib/test/test_peg_generator/test_c_parser.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Include/import.h b/Include/import.h index cc7ad71f2676a2..6f1c13787b8569 100644 --- a/Include/import.h +++ b/Include/import.h @@ -91,7 +91,7 @@ PyAPI_FUNC(int) PyImport_AppendInittab( typedef enum { PyImport_LAZY_NORMAL, PyImport_LAZY_ALL, - PyImport_LAZY_NONE, + PyImport_LAZY_NONE } PyImport_LazyImportsMode; #ifndef Py_LIMITED_API diff --git a/Lib/test/test_peg_generator/test_c_parser.py b/Lib/test/test_peg_generator/test_c_parser.py index 395f15b9a62cdf..3500f229b1b386 100644 --- a/Lib/test/test_peg_generator/test_c_parser.py +++ b/Lib/test/test_peg_generator/test_c_parser.py @@ -356,9 +356,9 @@ def test_same_name_different_types(self) -> None: grammar_source = """ start[mod_ty]: a[asdl_stmt_seq*]=import_from+ NEWLINE ENDMARKER { _PyAST_Module(a, NULL, p->arena)} import_from[stmt_ty]: ( a='from' !'import' c=simple_name 'import' d=import_as_names_from { - _PyAST_ImportFrom(c->v.Name.id, d, 0, EXTRA) } + _PyAST_ImportFrom(c->v.Name.id, d, 0, 0, EXTRA) } | a='from' '.' 'import' c=import_as_names_from { - _PyAST_ImportFrom(NULL, c, 1, EXTRA) } + _PyAST_ImportFrom(NULL, c, 1, 0, EXTRA) } ) simple_name[expr_ty]: NAME import_as_names_from[asdl_alias_seq*]: a[asdl_alias_seq*]=','.import_as_name_from+ { a }