https://github.com/python/cpython/commit/f37f57dfe683163f390ef589301e4dd4608c4288
commit: f37f57dfe683163f390ef589301e4dd4608c4288
branch: main
author: Samuel <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-12-29T13:43:09+02:00
summary:

gh-131421: Fix ASDL kw_defaults being `expr*` instead of `expr?*` (GH-133773)

Also fix docs ASDL highlighting.

files:
M Doc/tools/extensions/lexers/asdl_lexer.py
M Parser/Python.asdl
M Python/Python-ast.c

diff --git a/Doc/tools/extensions/lexers/asdl_lexer.py 
b/Doc/tools/extensions/lexers/asdl_lexer.py
index 3a74174a1f7dfb..548ce1271a1db8 100644
--- a/Doc/tools/extensions/lexers/asdl_lexer.py
+++ b/Doc/tools/extensions/lexers/asdl_lexer.py
@@ -22,7 +22,7 @@ class ASDLLexer(RegexLexer):
                 bygroups(Keyword, Text, Name.Tag),
             ),
             (
-                r"(\w+)(\*\s|\?\s|\s)(\w+)",
+                r"(\w+)([\?\*]*\s)(\w+)",
                 bygroups(Name.Builtin.Pseudo, Operator, Name),
             ),
             # Keep in line with ``builtin_types`` from Parser/asdl.py.
diff --git a/Parser/Python.asdl b/Parser/Python.asdl
index 96f3914b029d4c..9c7529c479916d 100644
--- a/Parser/Python.asdl
+++ b/Parser/Python.asdl
@@ -114,7 +114,7 @@ module Python
                     attributes (int lineno, int col_offset, int? end_lineno, 
int? end_col_offset)
 
     arguments = (arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs,
-                 expr* kw_defaults, arg? kwarg, expr* defaults)
+                 expr?* kw_defaults, arg? kwarg, expr* defaults)
 
     arg = (identifier arg, expr? annotation, string? type_comment)
            attributes (int lineno, int col_offset, int? end_lineno, int? 
end_col_offset)
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index aac24ed7d3c0c5..79608dee9bfac2 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -6813,7 +6813,7 @@ init_types(void *arg)
         return -1;
     state->arguments_type = make_type(state, "arguments", state->AST_type,
                                       arguments_fields, 7,
-        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, 
expr* kw_defaults, arg? kwarg, expr* defaults)");
+        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, 
expr?* kw_defaults, arg? kwarg, expr* defaults)");
     if (!state->arguments_type) return -1;
     if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
     if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)

_______________________________________________
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]

Reply via email to