From e46c7e2cd437ff03b99c92c87d466f68b5d9175d Mon Sep 17 00:00:00 2001 From: Demonstrandum Date: Fri, 9 May 2025 16:23:34 +0100 Subject: [PATCH 1/2] gh-131421: Fix ASDL `arguments` `expr* kw_defaults` to `expr?* kw_defaults` According to the docs: > (https://docs.python.org/3.15/library/ast.html#ast.arguments) > kw_defaults is a list of default values for keyword-only arguments. If one is None, the corresponding argument is required. However, ASDL's description of `kw_defaults` is that it simply a `expr*`, and not a `expr?*` as stated by the docs. --- Parser/Python.asdl | 2 +- Python/Python-ast.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 df035568f84be1..27dce51f8e3305 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -6787,7 +6787,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) From 41094ebd31b9ee5288cd5419ddd9dcf0db2b939f Mon Sep 17 00:00:00 2001 From: Demonstrandum Date: Fri, 9 May 2025 16:27:23 +0100 Subject: [PATCH 2/2] gh-131421: Fix bad syntax highlighting for new ASDL chained quantifiers. --- Doc/tools/extensions/lexers/asdl_lexer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.