From 9c8cd718ef20bc0ba4ee303f5bc08821ff0bfeb1 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 8 Apr 2023 18:04:11 -0700 Subject: [PATCH 001/200] Moved portions of earlier prototype into latest main CPython branch. This commit includes: 1. Parser updates 2. AST updates 3. typing.py updates 4. Unit tests It does not include the following: 5. Symtable updates 6. Compiler updates 7. C implementations of TypeVar, TypeVarTuple, ParamSpec, Generic --- Grammar/python.gram | 34 +- Include/cpython/funcobject.h | 1 + Include/internal/pycore_ast.h | 97 +- Include/internal/pycore_ast_state.h | 7 + .../pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + .../internal/pycore_runtime_init_generated.h | 1 + .../internal/pycore_unicodeobject_generated.h | 3 + Lib/ast.py | 25 + Lib/keyword.py | 3 +- Lib/test/test_ast.py | 82 +- Lib/test/test_sys.py | 2 +- Lib/test/test_type_aliases.py | 99 + Lib/test/test_type_params.py | 437 ++ Lib/typing.py | 51 +- Objects/funcobject.c | 17 + Objects/typeobject.c | 16 + Parser/Python.asdl | 11 +- Parser/action_helpers.c | 11 +- Parser/parser.c | 4012 ++++++++++------- Python/Python-ast.c | 767 +++- Python/ast.c | 3 + Python/ast_opt.c | 3 + 23 files changed, 3827 insertions(+), 1857 deletions(-) create mode 100644 Lib/test/test_type_aliases.py create mode 100644 Lib/test/test_type_params.py diff --git a/Grammar/python.gram b/Grammar/python.gram index 2498251293e80e..1169ddbb7b5122 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -112,6 +112,7 @@ simple_stmts[asdl_stmt_seq*]: # will throw a SyntaxError. simple_stmt[stmt_ty] (memo): | assignment + | type_alias | e=star_expressions { _PyAST_Expr(e, EXTRA) } | &'return' return_stmt | &('import' | 'from') import_stmt @@ -252,8 +253,8 @@ class_def[stmt_ty]: class_def_raw[stmt_ty]: | invalid_class_def_raw - | 'class' a=NAME b=['(' z=[arguments] ')' { z }] ':' c=block { - _PyAST_ClassDef(a->v.Name.id, + | 'class' a=NAME t=[type_params] b=['(' z=[arguments] ')' { z }] ':' c=block { + _PyAST_ClassDef(a->v.Name.id, t, (b) ? ((expr_ty) b)->v.Call.args : NULL, (b) ? ((expr_ty) b)->v.Call.keywords : NULL, c, NULL, EXTRA) } @@ -267,16 +268,16 @@ function_def[stmt_ty]: function_def_raw[stmt_ty]: | invalid_def_raw - | 'def' n=NAME &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { - _PyAST_FunctionDef(n->v.Name.id, + | 'def' n=NAME t=[type_params] &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { + _PyAST_FunctionDef(n->v.Name.id, t, (params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)), b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA) } - | ASYNC 'def' n=NAME &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { + | ASYNC 'def' n=NAME t=[type_params] &&'(' params=[params] ')' a=['->' z=expression { z }] &&':' tc=[func_type_comment] b=block { CHECK_VERSION( stmt_ty, 5, "Async functions are", - _PyAST_AsyncFunctionDef(n->v.Name.id, + _PyAST_AsyncFunctionDef(n->v.Name.id, t, (params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)), b, NULL, a, NEW_TYPE_COMMENT(p, tc), EXTRA) ) } @@ -628,6 +629,27 @@ keyword_patterns[asdl_seq*]: keyword_pattern[KeyPatternPair*]: | arg=NAME '=' value=pattern { _PyPegen_key_pattern_pair(p, arg, value) } +# Type statement +# --------------- + +type_alias[stmt_ty]: + | "type" n=NAME t=[type_params] '=' b=expression { + CHECK_VERSION(stmt_ty, 12, "Type statement is", _PyAST_TypeAlias(n->v.Name.id, t, b, EXTRA)) } + +# Type parameter declaration +# -------------------------- + +type_params[asdl_typeparam_seq*]: '[' t=type_param_seq ']' { t } + +type_param_seq[asdl_typeparam_seq*]: a[asdl_typeparam_seq*]=','.type_param+ [','] { a } + +type_param[typeparam_ty] (memo): + | a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) } + | '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) } + | '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) } + +type_param_bound[expr_ty]: ":" e=expression { e } + # EXPRESSIONS # ----------- diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index c716330cc3fbab..84cb40a7f551f6 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -41,6 +41,7 @@ typedef struct { PyObject *func_weakreflist; /* List of weak references */ PyObject *func_module; /* The __module__ attribute, can be anything */ PyObject *func_annotations; /* Annotations, a dict or NULL */ + PyObject *func_typevars; /* Tuple of active type variables or NULL */ vectorcallfunc vectorcall; /* Version number for use by specializer. * Can set to non-zero when we want to specialize. diff --git a/Include/internal/pycore_ast.h b/Include/internal/pycore_ast.h index 36277efe9c5ca5..caba84650e1eb9 100644 --- a/Include/internal/pycore_ast.h +++ b/Include/internal/pycore_ast.h @@ -51,6 +51,8 @@ typedef struct _pattern *pattern_ty; typedef struct _type_ignore *type_ignore_ty; +typedef struct _typeparam *typeparam_ty; + typedef struct { _ASDL_SEQ_HEAD @@ -147,6 +149,13 @@ typedef struct { asdl_type_ignore_seq *_Py_asdl_type_ignore_seq_new(Py_ssize_t size, PyArena *arena); +typedef struct { + _ASDL_SEQ_HEAD + typeparam_ty typed_elements[1]; +} asdl_typeparam_seq; + +asdl_typeparam_seq *_Py_asdl_typeparam_seq_new(Py_ssize_t size, PyArena *arena); + enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3, FunctionType_kind=4}; @@ -176,17 +185,19 @@ struct _mod { enum _stmt_kind {FunctionDef_kind=1, AsyncFunctionDef_kind=2, ClassDef_kind=3, Return_kind=4, Delete_kind=5, Assign_kind=6, - AugAssign_kind=7, AnnAssign_kind=8, For_kind=9, - AsyncFor_kind=10, While_kind=11, If_kind=12, With_kind=13, - AsyncWith_kind=14, Match_kind=15, Raise_kind=16, Try_kind=17, - TryStar_kind=18, Assert_kind=19, Import_kind=20, - ImportFrom_kind=21, Global_kind=22, Nonlocal_kind=23, - Expr_kind=24, Pass_kind=25, Break_kind=26, Continue_kind=27}; + TypeAlias_kind=7, AugAssign_kind=8, AnnAssign_kind=9, + For_kind=10, AsyncFor_kind=11, While_kind=12, If_kind=13, + With_kind=14, AsyncWith_kind=15, Match_kind=16, + Raise_kind=17, Try_kind=18, TryStar_kind=19, Assert_kind=20, + Import_kind=21, ImportFrom_kind=22, Global_kind=23, + Nonlocal_kind=24, Expr_kind=25, Pass_kind=26, Break_kind=27, + Continue_kind=28}; struct _stmt { enum _stmt_kind kind; union { struct { identifier name; + asdl_typeparam_seq *typeparams; arguments_ty args; asdl_stmt_seq *body; asdl_expr_seq *decorator_list; @@ -196,6 +207,7 @@ struct _stmt { struct { identifier name; + asdl_typeparam_seq *typeparams; arguments_ty args; asdl_stmt_seq *body; asdl_expr_seq *decorator_list; @@ -205,6 +217,7 @@ struct _stmt { struct { identifier name; + asdl_typeparam_seq *typeparams; asdl_expr_seq *bases; asdl_keyword_seq *keywords; asdl_stmt_seq *body; @@ -225,6 +238,12 @@ struct _stmt { string type_comment; } Assign; + struct { + identifier name; + asdl_typeparam_seq *typeparams; + expr_ty value; + } TypeAlias; + struct { expr_ty target; operator_ty op; @@ -630,6 +649,30 @@ struct _type_ignore { } v; }; +enum _typeparam_kind {TypeVar_kind=1, ParamSpec_kind=2, TypeVarTuple_kind=3}; +struct _typeparam { + enum _typeparam_kind kind; + union { + struct { + identifier name; + expr_ty bound; + } TypeVar; + + struct { + identifier name; + } ParamSpec; + + struct { + identifier name; + } TypeVarTuple; + + } v; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; +}; + // Note: these macros affect function definitions, not only call sites. mod_ty _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores, @@ -638,21 +681,22 @@ mod_ty _PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena); mod_ty _PyAST_Expression(expr_ty body, PyArena *arena); mod_ty _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena); -stmt_ty _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * - body, asdl_expr_seq * decorator_list, expr_ty - returns, string type_comment, int lineno, int - col_offset, int end_lineno, int end_col_offset, - PyArena *arena); -stmt_ty _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, - asdl_stmt_seq * body, asdl_expr_seq * - decorator_list, expr_ty returns, string - type_comment, int lineno, int col_offset, int - end_lineno, int end_col_offset, PyArena *arena); -stmt_ty _PyAST_ClassDef(identifier name, asdl_expr_seq * bases, - asdl_keyword_seq * keywords, asdl_stmt_seq * body, - asdl_expr_seq * decorator_list, int lineno, int - col_offset, int end_lineno, int end_col_offset, PyArena - *arena); +stmt_ty _PyAST_FunctionDef(identifier name, asdl_typeparam_seq * typeparams, + arguments_ty args, asdl_stmt_seq * body, + asdl_expr_seq * decorator_list, expr_ty returns, + string type_comment, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_AsyncFunctionDef(identifier name, asdl_typeparam_seq * + typeparams, arguments_ty args, asdl_stmt_seq * + body, asdl_expr_seq * decorator_list, expr_ty + returns, string type_comment, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +stmt_ty _PyAST_ClassDef(identifier name, asdl_typeparam_seq * typeparams, + asdl_expr_seq * bases, asdl_keyword_seq * keywords, + asdl_stmt_seq * body, asdl_expr_seq * decorator_list, + int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); stmt_ty _PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); stmt_ty _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int @@ -660,6 +704,9 @@ stmt_ty _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int stmt_ty _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_TypeAlias(identifier name, asdl_typeparam_seq * typeparams, + expr_ty value, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); stmt_ty _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); @@ -844,6 +891,14 @@ pattern_ty _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); type_ignore_ty _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena); +typeparam_ty _PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int + col_offset, int end_lineno, int end_col_offset, + PyArena *arena); +typeparam_ty _PyAST_ParamSpec(identifier name, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); +typeparam_ty _PyAST_TypeVarTuple(identifier name, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena + *arena); PyObject* PyAST_mod2obj(mod_ty t); diff --git a/Include/internal/pycore_ast_state.h b/Include/internal/pycore_ast_state.h index f15b4905eed14b..e723ead577b888 100644 --- a/Include/internal/pycore_ast_state.h +++ b/Include/internal/pycore_ast_state.h @@ -118,6 +118,7 @@ struct ast_state { PyObject *Not_type; PyObject *Or_singleton; PyObject *Or_type; + PyObject *ParamSpec_type; PyObject *Pass_type; PyObject *Pow_singleton; PyObject *Pow_type; @@ -137,7 +138,10 @@ struct ast_state { PyObject *TryStar_type; PyObject *Try_type; PyObject *Tuple_type; + PyObject *TypeAlias_type; PyObject *TypeIgnore_type; + PyObject *TypeVarTuple_type; + PyObject *TypeVar_type; PyObject *UAdd_singleton; PyObject *UAdd_type; PyObject *USub_singleton; @@ -166,6 +170,7 @@ struct ast_state { PyObject *bases; PyObject *body; PyObject *boolop_type; + PyObject *bound; PyObject *cases; PyObject *cause; PyObject *cls; @@ -243,6 +248,8 @@ struct ast_state { PyObject *type_comment; PyObject *type_ignore_type; PyObject *type_ignores; + PyObject *typeparam_type; + PyObject *typeparams; PyObject *unaryop_type; PyObject *upper; PyObject *value; diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 14dfd9ea5823ed..6c974c253ceaca 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -724,6 +724,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__subclasshook__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__truediv__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__trunc__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__type_variables__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_is_unpacked_typevartuple__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_prepare_subst__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_subst__)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 6f430bb25eb8d3..6b862ca17dd33e 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -210,6 +210,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(__subclasshook__) STRUCT_FOR_ID(__truediv__) STRUCT_FOR_ID(__trunc__) + STRUCT_FOR_ID(__type_variables__) STRUCT_FOR_ID(__typing_is_unpacked_typevartuple__) STRUCT_FOR_ID(__typing_prepare_subst__) STRUCT_FOR_ID(__typing_subst__) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 0452c4c61551de..ef76de1b320571 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -716,6 +716,7 @@ extern "C" { INIT_ID(__subclasshook__), \ INIT_ID(__truediv__), \ INIT_ID(__trunc__), \ + INIT_ID(__type_variables__), \ INIT_ID(__typing_is_unpacked_typevartuple__), \ INIT_ID(__typing_prepare_subst__), \ INIT_ID(__typing_subst__), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 7114a5416f2515..01b3cb7606f767 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -483,6 +483,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(__trunc__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(__type_variables__); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(__typing_is_unpacked_typevartuple__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Lib/ast.py b/Lib/ast.py index 2cbc80a9835aa5..34122f04267a2c 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1011,6 +1011,7 @@ def visit_ClassDef(self, node): self.fill("@") self.traverse(deco) self.fill("class " + node.name) + self._typeparams_helper(node.typeparams) with self.delimit_if("(", ")", condition = node.bases or node.keywords): comma = False for e in node.bases: @@ -1042,6 +1043,7 @@ def _function_helper(self, node, fill_suffix): self.traverse(deco) def_str = fill_suffix + " " + node.name self.fill(def_str) + self._typeparams_helper(node.typeparams) with self.delimit("(", ")"): self.traverse(node.args) if node.returns: @@ -1050,6 +1052,29 @@ def _function_helper(self, node, fill_suffix): with self.block(extra=self.get_type_comment(node)): self._write_docstring_and_traverse_body(node) + def _typeparams_helper(self, typeparams): + if typeparams is not None and len(typeparams) > 0: + with self.delimit("[", "]"): + self.interleave(lambda: self.write(", "), self.traverse, typeparams) + + def visit_TypeVar(self, node): + self.write(node.name) + if node.bound: + self.write(": ") + self.traverse(node.bound) + + def visit_TypeVarTuple(self, node): + self.write("*" + node.name) + + def visit_ParamSpec(self, node): + self.write("**" + node.name) + + def visit_TypeAlias(self, node): + self.fill("type " + node.name) + self._typeparams_helper(node.typeparams) + self.write(" = ") + self.traverse(node.value) + def visit_For(self, node): self._for_helper("for ", node) diff --git a/Lib/keyword.py b/Lib/keyword.py index cc2b46b7229d53..e22c837835e740 100644 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -56,7 +56,8 @@ softkwlist = [ '_', 'case', - 'match' + 'match', + 'type' ] iskeyword = frozenset(kwlist).__contains__ diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 6c932e1305e1dd..1e6d0a07f694db 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -1337,16 +1337,16 @@ def arguments(args=None, posonlyargs=None, vararg=None, def test_funcdef(self): a = ast.arguments([], [], None, [], [], None, []) - f = ast.FunctionDef("x", a, [], [], None) + f = ast.FunctionDef("x", [], a, [], [], None) self.stmt(f, "empty body on FunctionDef") - f = ast.FunctionDef("x", a, [ast.Pass()], [ast.Name("x", ast.Store())], + f = ast.FunctionDef("x", [], a, [ast.Pass()], [ast.Name("x", ast.Store())], None) self.stmt(f, "must have Load context") - f = ast.FunctionDef("x", a, [ast.Pass()], [], + f = ast.FunctionDef("x", [], a, [ast.Pass()], [], ast.Name("x", ast.Store())) self.stmt(f, "must have Load context") def fac(args): - return ast.FunctionDef("x", args, [ast.Pass()], [], None) + return ast.FunctionDef("x", [], args, [ast.Pass()], [], None) self._check_arguments(fac, self.stmt) def test_classdef(self): @@ -1359,7 +1359,7 @@ def cls(bases=None, keywords=None, body=None, decorator_list=None): body = [ast.Pass()] if decorator_list is None: decorator_list = [] - return ast.ClassDef("myclass", bases, keywords, + return ast.ClassDef("myclass", [], bases, keywords, body, decorator_list) self.stmt(cls(bases=[ast.Name("x", ast.Store())]), "must have Load context") @@ -2603,23 +2603,23 @@ def main(): exec_results = [ ('Module', [('Expr', (1, 0, 1, 4), ('Constant', (1, 0, 1, 4), None, None))], []), ('Module', [('Expr', (1, 0, 1, 18), ('Constant', (1, 0, 1, 18), 'module docstring', None))], []), -('Module', [('FunctionDef', (1, 0, 1, 13), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 9, 1, 13))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 29), 'f', ('arguments', [], [], None, [], [], None, []), [('Expr', (1, 9, 1, 29), ('Constant', (1, 9, 1, 29), 'function docstring', None))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 14), 'f', ('arguments', [], [('arg', (1, 6, 1, 7), 'a', None, None)], None, [], [], None, []), [('Pass', (1, 10, 1, 14))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 16), 'f', ('arguments', [], [('arg', (1, 6, 1, 7), 'a', None, None)], None, [], [], None, [('Constant', (1, 8, 1, 9), 0, None)]), [('Pass', (1, 12, 1, 16))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 18), 'f', ('arguments', [], [], ('arg', (1, 7, 1, 11), 'args', None, None), [], [], None, []), [('Pass', (1, 14, 1, 18))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 23), 'f', ('arguments', [], [], ('arg', (1, 7, 1, 16), 'args', ('Starred', (1, 13, 1, 16), ('Name', (1, 14, 1, 16), 'Ts', ('Load',)), ('Load',)), None), [], [], None, []), [('Pass', (1, 19, 1, 23))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 36), 'f', ('arguments', [], [], ('arg', (1, 7, 1, 29), 'args', ('Starred', (1, 13, 1, 29), ('Subscript', (1, 14, 1, 29), ('Name', (1, 14, 1, 19), 'tuple', ('Load',)), ('Tuple', (1, 20, 1, 28), [('Name', (1, 20, 1, 23), 'int', ('Load',)), ('Constant', (1, 25, 1, 28), Ellipsis, None)], ('Load',)), ('Load',)), ('Load',)), None), [], [], None, []), [('Pass', (1, 32, 1, 36))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 36), 'f', ('arguments', [], [], ('arg', (1, 7, 1, 29), 'args', ('Starred', (1, 13, 1, 29), ('Subscript', (1, 14, 1, 29), ('Name', (1, 14, 1, 19), 'tuple', ('Load',)), ('Tuple', (1, 20, 1, 28), [('Name', (1, 20, 1, 23), 'int', ('Load',)), ('Starred', (1, 25, 1, 28), ('Name', (1, 26, 1, 28), 'Ts', ('Load',)), ('Load',))], ('Load',)), ('Load',)), ('Load',)), None), [], [], None, []), [('Pass', (1, 32, 1, 36))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 21), 'f', ('arguments', [], [], None, [], [], ('arg', (1, 8, 1, 14), 'kwargs', None, None), []), [('Pass', (1, 17, 1, 21))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 71), 'f', ('arguments', [], [('arg', (1, 6, 1, 7), 'a', None, None), ('arg', (1, 9, 1, 10), 'b', None, None), ('arg', (1, 14, 1, 15), 'c', None, None), ('arg', (1, 22, 1, 23), 'd', None, None), ('arg', (1, 28, 1, 29), 'e', None, None)], ('arg', (1, 35, 1, 39), 'args', None, None), [('arg', (1, 41, 1, 42), 'f', None, None)], [('Constant', (1, 43, 1, 45), 42, None)], ('arg', (1, 49, 1, 55), 'kwargs', None, None), [('Constant', (1, 11, 1, 12), 1, None), ('Constant', (1, 16, 1, 20), None, None), ('List', (1, 24, 1, 26), [], ('Load',)), ('Dict', (1, 30, 1, 32), [], [])]), [('Expr', (1, 58, 1, 71), ('Constant', (1, 58, 1, 71), 'doc for f()', None))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 27), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 23, 1, 27))], [], ('Subscript', (1, 11, 1, 21), ('Name', (1, 11, 1, 16), 'tuple', ('Load',)), ('Tuple', (1, 17, 1, 20), [('Starred', (1, 17, 1, 20), ('Name', (1, 18, 1, 20), 'Ts', ('Load',)), ('Load',))], ('Load',)), ('Load',)), None)], []), -('Module', [('FunctionDef', (1, 0, 1, 32), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 28, 1, 32))], [], ('Subscript', (1, 11, 1, 26), ('Name', (1, 11, 1, 16), 'tuple', ('Load',)), ('Tuple', (1, 17, 1, 25), [('Name', (1, 17, 1, 20), 'int', ('Load',)), ('Starred', (1, 22, 1, 25), ('Name', (1, 23, 1, 25), 'Ts', ('Load',)), ('Load',))], ('Load',)), ('Load',)), None)], []), -('Module', [('FunctionDef', (1, 0, 1, 45), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 41, 1, 45))], [], ('Subscript', (1, 11, 1, 39), ('Name', (1, 11, 1, 16), 'tuple', ('Load',)), ('Tuple', (1, 17, 1, 38), [('Name', (1, 17, 1, 20), 'int', ('Load',)), ('Starred', (1, 22, 1, 38), ('Subscript', (1, 23, 1, 38), ('Name', (1, 23, 1, 28), 'tuple', ('Load',)), ('Tuple', (1, 29, 1, 37), [('Name', (1, 29, 1, 32), 'int', ('Load',)), ('Constant', (1, 34, 1, 37), Ellipsis, None)], ('Load',)), ('Load',)), ('Load',))], ('Load',)), ('Load',)), None)], []), -('Module', [('ClassDef', (1, 0, 1, 12), 'C', [], [], [('Pass', (1, 8, 1, 12))], [])], []), -('Module', [('ClassDef', (1, 0, 1, 32), 'C', [], [], [('Expr', (1, 9, 1, 32), ('Constant', (1, 9, 1, 32), 'docstring for class C', None))], [])], []), -('Module', [('ClassDef', (1, 0, 1, 21), 'C', [('Name', (1, 8, 1, 14), 'object', ('Load',))], [], [('Pass', (1, 17, 1, 21))], [])], []), -('Module', [('FunctionDef', (1, 0, 1, 16), 'f', ('arguments', [], [], None, [], [], None, []), [('Return', (1, 8, 1, 16), ('Constant', (1, 15, 1, 16), 1, None))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 13), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 9, 1, 13))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 29), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Expr', (1, 9, 1, 29), ('Constant', (1, 9, 1, 29), 'function docstring', None))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 14), 'f', [], ('arguments', [], [('arg', (1, 6, 1, 7), 'a', None, None)], None, [], [], None, []), [('Pass', (1, 10, 1, 14))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 16), 'f', [], ('arguments', [], [('arg', (1, 6, 1, 7), 'a', None, None)], None, [], [], None, [('Constant', (1, 8, 1, 9), 0, None)]), [('Pass', (1, 12, 1, 16))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 18), 'f', [], ('arguments', [], [], ('arg', (1, 7, 1, 11), 'args', None, None), [], [], None, []), [('Pass', (1, 14, 1, 18))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 23), 'f', [], ('arguments', [], [], ('arg', (1, 7, 1, 16), 'args', ('Starred', (1, 13, 1, 16), ('Name', (1, 14, 1, 16), 'Ts', ('Load',)), ('Load',)), None), [], [], None, []), [('Pass', (1, 19, 1, 23))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 36), 'f', [], ('arguments', [], [], ('arg', (1, 7, 1, 29), 'args', ('Starred', (1, 13, 1, 29), ('Subscript', (1, 14, 1, 29), ('Name', (1, 14, 1, 19), 'tuple', ('Load',)), ('Tuple', (1, 20, 1, 28), [('Name', (1, 20, 1, 23), 'int', ('Load',)), ('Constant', (1, 25, 1, 28), Ellipsis, None)], ('Load',)), ('Load',)), ('Load',)), None), [], [], None, []), [('Pass', (1, 32, 1, 36))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 36), 'f', [], ('arguments', [], [], ('arg', (1, 7, 1, 29), 'args', ('Starred', (1, 13, 1, 29), ('Subscript', (1, 14, 1, 29), ('Name', (1, 14, 1, 19), 'tuple', ('Load',)), ('Tuple', (1, 20, 1, 28), [('Name', (1, 20, 1, 23), 'int', ('Load',)), ('Starred', (1, 25, 1, 28), ('Name', (1, 26, 1, 28), 'Ts', ('Load',)), ('Load',))], ('Load',)), ('Load',)), ('Load',)), None), [], [], None, []), [('Pass', (1, 32, 1, 36))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 21), 'f', [], ('arguments', [], [], None, [], [], ('arg', (1, 8, 1, 14), 'kwargs', None, None), []), [('Pass', (1, 17, 1, 21))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 71), 'f', [], ('arguments', [], [('arg', (1, 6, 1, 7), 'a', None, None), ('arg', (1, 9, 1, 10), 'b', None, None), ('arg', (1, 14, 1, 15), 'c', None, None), ('arg', (1, 22, 1, 23), 'd', None, None), ('arg', (1, 28, 1, 29), 'e', None, None)], ('arg', (1, 35, 1, 39), 'args', None, None), [('arg', (1, 41, 1, 42), 'f', None, None)], [('Constant', (1, 43, 1, 45), 42, None)], ('arg', (1, 49, 1, 55), 'kwargs', None, None), [('Constant', (1, 11, 1, 12), 1, None), ('Constant', (1, 16, 1, 20), None, None), ('List', (1, 24, 1, 26), [], ('Load',)), ('Dict', (1, 30, 1, 32), [], [])]), [('Expr', (1, 58, 1, 71), ('Constant', (1, 58, 1, 71), 'doc for f()', None))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 27), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 23, 1, 27))], [], ('Subscript', (1, 11, 1, 21), ('Name', (1, 11, 1, 16), 'tuple', ('Load',)), ('Tuple', (1, 17, 1, 20), [('Starred', (1, 17, 1, 20), ('Name', (1, 18, 1, 20), 'Ts', ('Load',)), ('Load',))], ('Load',)), ('Load',)), None)], []), +('Module', [('FunctionDef', (1, 0, 1, 32), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 28, 1, 32))], [], ('Subscript', (1, 11, 1, 26), ('Name', (1, 11, 1, 16), 'tuple', ('Load',)), ('Tuple', (1, 17, 1, 25), [('Name', (1, 17, 1, 20), 'int', ('Load',)), ('Starred', (1, 22, 1, 25), ('Name', (1, 23, 1, 25), 'Ts', ('Load',)), ('Load',))], ('Load',)), ('Load',)), None)], []), +('Module', [('FunctionDef', (1, 0, 1, 45), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 41, 1, 45))], [], ('Subscript', (1, 11, 1, 39), ('Name', (1, 11, 1, 16), 'tuple', ('Load',)), ('Tuple', (1, 17, 1, 38), [('Name', (1, 17, 1, 20), 'int', ('Load',)), ('Starred', (1, 22, 1, 38), ('Subscript', (1, 23, 1, 38), ('Name', (1, 23, 1, 28), 'tuple', ('Load',)), ('Tuple', (1, 29, 1, 37), [('Name', (1, 29, 1, 32), 'int', ('Load',)), ('Constant', (1, 34, 1, 37), Ellipsis, None)], ('Load',)), ('Load',)), ('Load',))], ('Load',)), ('Load',)), None)], []), +('Module', [('ClassDef', (1, 0, 1, 12), 'C', [], [], [], [('Pass', (1, 8, 1, 12))], [])], []), +('Module', [('ClassDef', (1, 0, 1, 32), 'C', [], [], [], [('Expr', (1, 9, 1, 32), ('Constant', (1, 9, 1, 32), 'docstring for class C', None))], [])], []), +('Module', [('ClassDef', (1, 0, 1, 21), 'C', [], [('Name', (1, 8, 1, 14), 'object', ('Load',))], [], [('Pass', (1, 17, 1, 21))], [])], []), +('Module', [('FunctionDef', (1, 0, 1, 16), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Return', (1, 8, 1, 16), ('Constant', (1, 15, 1, 16), 1, None))], [], None, None)], []), ('Module', [('Delete', (1, 0, 1, 5), [('Name', (1, 4, 1, 5), 'v', ('Del',))])], []), ('Module', [('Assign', (1, 0, 1, 5), [('Name', (1, 0, 1, 1), 'v', ('Store',))], ('Constant', (1, 4, 1, 5), 1, None), None)], []), ('Module', [('Assign', (1, 0, 1, 7), [('Tuple', (1, 0, 1, 3), [('Name', (1, 0, 1, 1), 'a', ('Store',)), ('Name', (1, 2, 1, 3), 'b', ('Store',))], ('Store',))], ('Name', (1, 6, 1, 7), 'c', ('Load',)), None)], []), @@ -2656,28 +2656,28 @@ def main(): ('Module', [('Expr', (1, 0, 1, 20), ('DictComp', (1, 0, 1, 20), ('Name', (1, 1, 1, 2), 'a', ('Load',)), ('Name', (1, 5, 1, 6), 'b', ('Load',)), [('comprehension', ('Tuple', (1, 11, 1, 14), [('Name', (1, 11, 1, 12), 'v', ('Store',)), ('Name', (1, 13, 1, 14), 'w', ('Store',))], ('Store',)), ('Name', (1, 18, 1, 19), 'x', ('Load',)), [], 0)]))], []), ('Module', [('Expr', (1, 0, 1, 19), ('SetComp', (1, 0, 1, 19), ('Name', (1, 1, 1, 2), 'r', ('Load',)), [('comprehension', ('Name', (1, 7, 1, 8), 'l', ('Store',)), ('Name', (1, 12, 1, 13), 'x', ('Load',)), [('Name', (1, 17, 1, 18), 'g', ('Load',))], 0)]))], []), ('Module', [('Expr', (1, 0, 1, 16), ('SetComp', (1, 0, 1, 16), ('Name', (1, 1, 1, 2), 'r', ('Load',)), [('comprehension', ('Tuple', (1, 7, 1, 10), [('Name', (1, 7, 1, 8), 'l', ('Store',)), ('Name', (1, 9, 1, 10), 'm', ('Store',))], ('Store',)), ('Name', (1, 14, 1, 15), 'x', ('Load',)), [], 0)]))], []), -('Module', [('AsyncFunctionDef', (1, 0, 3, 18), 'f', ('arguments', [], [], None, [], [], None, []), [('Expr', (2, 1, 2, 17), ('Constant', (2, 1, 2, 17), 'async function', None)), ('Expr', (3, 1, 3, 18), ('Await', (3, 1, 3, 18), ('Call', (3, 7, 3, 18), ('Name', (3, 7, 3, 16), 'something', ('Load',)), [], [])))], [], None, None)], []), -('Module', [('AsyncFunctionDef', (1, 0, 3, 8), 'f', ('arguments', [], [], None, [], [], None, []), [('AsyncFor', (2, 1, 3, 8), ('Name', (2, 11, 2, 12), 'e', ('Store',)), ('Name', (2, 16, 2, 17), 'i', ('Load',)), [('Expr', (2, 19, 2, 20), ('Constant', (2, 19, 2, 20), 1, None))], [('Expr', (3, 7, 3, 8), ('Constant', (3, 7, 3, 8), 2, None))], None)], [], None, None)], []), -('Module', [('AsyncFunctionDef', (1, 0, 2, 21), 'f', ('arguments', [], [], None, [], [], None, []), [('AsyncWith', (2, 1, 2, 21), [('withitem', ('Name', (2, 12, 2, 13), 'a', ('Load',)), ('Name', (2, 17, 2, 18), 'b', ('Store',)))], [('Expr', (2, 20, 2, 21), ('Constant', (2, 20, 2, 21), 1, None))], None)], [], None, None)], []), +('Module', [('AsyncFunctionDef', (1, 0, 3, 18), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Expr', (2, 1, 2, 17), ('Constant', (2, 1, 2, 17), 'async function', None)), ('Expr', (3, 1, 3, 18), ('Await', (3, 1, 3, 18), ('Call', (3, 7, 3, 18), ('Name', (3, 7, 3, 16), 'something', ('Load',)), [], [])))], [], None, None)], []), +('Module', [('AsyncFunctionDef', (1, 0, 3, 8), 'f', [], ('arguments', [], [], None, [], [], None, []), [('AsyncFor', (2, 1, 3, 8), ('Name', (2, 11, 2, 12), 'e', ('Store',)), ('Name', (2, 16, 2, 17), 'i', ('Load',)), [('Expr', (2, 19, 2, 20), ('Constant', (2, 19, 2, 20), 1, None))], [('Expr', (3, 7, 3, 8), ('Constant', (3, 7, 3, 8), 2, None))], None)], [], None, None)], []), +('Module', [('AsyncFunctionDef', (1, 0, 2, 21), 'f', [], ('arguments', [], [], None, [], [], None, []), [('AsyncWith', (2, 1, 2, 21), [('withitem', ('Name', (2, 12, 2, 13), 'a', ('Load',)), ('Name', (2, 17, 2, 18), 'b', ('Store',)))], [('Expr', (2, 20, 2, 21), ('Constant', (2, 20, 2, 21), 1, None))], None)], [], None, None)], []), ('Module', [('Expr', (1, 0, 1, 14), ('Dict', (1, 0, 1, 14), [None, ('Constant', (1, 10, 1, 11), 2, None)], [('Dict', (1, 3, 1, 8), [('Constant', (1, 4, 1, 5), 1, None)], [('Constant', (1, 6, 1, 7), 2, None)]), ('Constant', (1, 12, 1, 13), 3, None)]))], []), ('Module', [('Expr', (1, 0, 1, 12), ('Set', (1, 0, 1, 12), [('Starred', (1, 1, 1, 8), ('Set', (1, 2, 1, 8), [('Constant', (1, 3, 1, 4), 1, None), ('Constant', (1, 6, 1, 7), 2, None)]), ('Load',)), ('Constant', (1, 10, 1, 11), 3, None)]))], []), -('Module', [('AsyncFunctionDef', (1, 0, 2, 21), 'f', ('arguments', [], [], None, [], [], None, []), [('Expr', (2, 1, 2, 21), ('ListComp', (2, 1, 2, 21), ('Name', (2, 2, 2, 3), 'i', ('Load',)), [('comprehension', ('Name', (2, 14, 2, 15), 'b', ('Store',)), ('Name', (2, 19, 2, 20), 'c', ('Load',)), [], 1)]))], [], None, None)], []), -('Module', [('FunctionDef', (4, 0, 4, 13), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (4, 9, 4, 13))], [('Name', (1, 1, 1, 6), 'deco1', ('Load',)), ('Call', (2, 1, 2, 8), ('Name', (2, 1, 2, 6), 'deco2', ('Load',)), [], []), ('Call', (3, 1, 3, 9), ('Name', (3, 1, 3, 6), 'deco3', ('Load',)), [('Constant', (3, 7, 3, 8), 1, None)], [])], None, None)], []), -('Module', [('AsyncFunctionDef', (4, 0, 4, 19), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (4, 15, 4, 19))], [('Name', (1, 1, 1, 6), 'deco1', ('Load',)), ('Call', (2, 1, 2, 8), ('Name', (2, 1, 2, 6), 'deco2', ('Load',)), [], []), ('Call', (3, 1, 3, 9), ('Name', (3, 1, 3, 6), 'deco3', ('Load',)), [('Constant', (3, 7, 3, 8), 1, None)], [])], None, None)], []), -('Module', [('ClassDef', (4, 0, 4, 13), 'C', [], [], [('Pass', (4, 9, 4, 13))], [('Name', (1, 1, 1, 6), 'deco1', ('Load',)), ('Call', (2, 1, 2, 8), ('Name', (2, 1, 2, 6), 'deco2', ('Load',)), [], []), ('Call', (3, 1, 3, 9), ('Name', (3, 1, 3, 6), 'deco3', ('Load',)), [('Constant', (3, 7, 3, 8), 1, None)], [])])], []), -('Module', [('FunctionDef', (2, 0, 2, 13), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (2, 9, 2, 13))], [('Call', (1, 1, 1, 19), ('Name', (1, 1, 1, 5), 'deco', ('Load',)), [('GeneratorExp', (1, 5, 1, 19), ('Name', (1, 6, 1, 7), 'a', ('Load',)), [('comprehension', ('Name', (1, 12, 1, 13), 'a', ('Store',)), ('Name', (1, 17, 1, 18), 'b', ('Load',)), [], 0)])], [])], None, None)], []), -('Module', [('FunctionDef', (2, 0, 2, 13), 'f', ('arguments', [], [], None, [], [], None, []), [('Pass', (2, 9, 2, 13))], [('Attribute', (1, 1, 1, 6), ('Attribute', (1, 1, 1, 4), ('Name', (1, 1, 1, 2), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',))], None, None)], []), +('Module', [('AsyncFunctionDef', (1, 0, 2, 21), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Expr', (2, 1, 2, 21), ('ListComp', (2, 1, 2, 21), ('Name', (2, 2, 2, 3), 'i', ('Load',)), [('comprehension', ('Name', (2, 14, 2, 15), 'b', ('Store',)), ('Name', (2, 19, 2, 20), 'c', ('Load',)), [], 1)]))], [], None, None)], []), +('Module', [('FunctionDef', (4, 0, 4, 13), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (4, 9, 4, 13))], [('Name', (1, 1, 1, 6), 'deco1', ('Load',)), ('Call', (2, 1, 2, 8), ('Name', (2, 1, 2, 6), 'deco2', ('Load',)), [], []), ('Call', (3, 1, 3, 9), ('Name', (3, 1, 3, 6), 'deco3', ('Load',)), [('Constant', (3, 7, 3, 8), 1, None)], [])], None, None)], []), +('Module', [('AsyncFunctionDef', (4, 0, 4, 19), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (4, 15, 4, 19))], [('Name', (1, 1, 1, 6), 'deco1', ('Load',)), ('Call', (2, 1, 2, 8), ('Name', (2, 1, 2, 6), 'deco2', ('Load',)), [], []), ('Call', (3, 1, 3, 9), ('Name', (3, 1, 3, 6), 'deco3', ('Load',)), [('Constant', (3, 7, 3, 8), 1, None)], [])], None, None)], []), +('Module', [('ClassDef', (4, 0, 4, 13), 'C', [], [], [], [('Pass', (4, 9, 4, 13))], [('Name', (1, 1, 1, 6), 'deco1', ('Load',)), ('Call', (2, 1, 2, 8), ('Name', (2, 1, 2, 6), 'deco2', ('Load',)), [], []), ('Call', (3, 1, 3, 9), ('Name', (3, 1, 3, 6), 'deco3', ('Load',)), [('Constant', (3, 7, 3, 8), 1, None)], [])])], []), +('Module', [('FunctionDef', (2, 0, 2, 13), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (2, 9, 2, 13))], [('Call', (1, 1, 1, 19), ('Name', (1, 1, 1, 5), 'deco', ('Load',)), [('GeneratorExp', (1, 5, 1, 19), ('Name', (1, 6, 1, 7), 'a', ('Load',)), [('comprehension', ('Name', (1, 12, 1, 13), 'a', ('Store',)), ('Name', (1, 17, 1, 18), 'b', ('Load',)), [], 0)])], [])], None, None)], []), +('Module', [('FunctionDef', (2, 0, 2, 13), 'f', [], ('arguments', [], [], None, [], [], None, []), [('Pass', (2, 9, 2, 13))], [('Attribute', (1, 1, 1, 6), ('Attribute', (1, 1, 1, 4), ('Name', (1, 1, 1, 2), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',))], None, None)], []), ('Module', [('Expr', (1, 0, 1, 8), ('NamedExpr', (1, 1, 1, 7), ('Name', (1, 1, 1, 2), 'a', ('Store',)), ('Constant', (1, 6, 1, 7), 1, None)))], []), -('Module', [('FunctionDef', (1, 0, 1, 18), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [], None, [], [], None, []), [('Pass', (1, 14, 1, 18))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 26), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 12, 1, 13), 'c', None, None), ('arg', (1, 15, 1, 16), 'd', None, None), ('arg', (1, 18, 1, 19), 'e', None, None)], None, [], [], None, []), [('Pass', (1, 22, 1, 26))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 29), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 12, 1, 13), 'c', None, None)], None, [('arg', (1, 18, 1, 19), 'd', None, None), ('arg', (1, 21, 1, 22), 'e', None, None)], [None, None], None, []), [('Pass', (1, 25, 1, 29))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 39), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 12, 1, 13), 'c', None, None)], None, [('arg', (1, 18, 1, 19), 'd', None, None), ('arg', (1, 21, 1, 22), 'e', None, None)], [None, None], ('arg', (1, 26, 1, 32), 'kwargs', None, None), []), [('Pass', (1, 35, 1, 39))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 20), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [], None, [], [], None, [('Constant', (1, 8, 1, 9), 1, None)]), [('Pass', (1, 16, 1, 20))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 29), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None), ('arg', (1, 19, 1, 20), 'c', None, None)], None, [], [], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None), ('Constant', (1, 21, 1, 22), 4, None)]), [('Pass', (1, 25, 1, 29))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 32), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [('Constant', (1, 24, 1, 25), 4, None)], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 28, 1, 32))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 30), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [None], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 26, 1, 30))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 42), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [('Constant', (1, 24, 1, 25), 4, None)], ('arg', (1, 29, 1, 35), 'kwargs', None, None), [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 38, 1, 42))], [], None, None)], []), -('Module', [('FunctionDef', (1, 0, 1, 40), 'f', ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [None], ('arg', (1, 27, 1, 33), 'kwargs', None, None), [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 36, 1, 40))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 18), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [], None, [], [], None, []), [('Pass', (1, 14, 1, 18))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 26), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 12, 1, 13), 'c', None, None), ('arg', (1, 15, 1, 16), 'd', None, None), ('arg', (1, 18, 1, 19), 'e', None, None)], None, [], [], None, []), [('Pass', (1, 22, 1, 26))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 29), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 12, 1, 13), 'c', None, None)], None, [('arg', (1, 18, 1, 19), 'd', None, None), ('arg', (1, 21, 1, 22), 'e', None, None)], [None, None], None, []), [('Pass', (1, 25, 1, 29))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 39), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 12, 1, 13), 'c', None, None)], None, [('arg', (1, 18, 1, 19), 'd', None, None), ('arg', (1, 21, 1, 22), 'e', None, None)], [None, None], ('arg', (1, 26, 1, 32), 'kwargs', None, None), []), [('Pass', (1, 35, 1, 39))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 20), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [], None, [], [], None, [('Constant', (1, 8, 1, 9), 1, None)]), [('Pass', (1, 16, 1, 20))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 29), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None), ('arg', (1, 19, 1, 20), 'c', None, None)], None, [], [], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None), ('Constant', (1, 21, 1, 22), 4, None)]), [('Pass', (1, 25, 1, 29))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 32), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [('Constant', (1, 24, 1, 25), 4, None)], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 28, 1, 32))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 30), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [None], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 26, 1, 30))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 42), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [('Constant', (1, 24, 1, 25), 4, None)], ('arg', (1, 29, 1, 35), 'kwargs', None, None), [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 38, 1, 42))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 40), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [None], ('arg', (1, 27, 1, 33), 'kwargs', None, None), [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 36, 1, 40))], [], None, None)], []), ] single_results = [ ('Interactive', [('Expr', (1, 0, 1, 3), ('BinOp', (1, 0, 1, 3), ('Constant', (1, 0, 1, 1), 1, None), ('Add',), ('Constant', (1, 2, 1, 3), 2, None)))]), diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index d7456d6d9480b2..4d172b742b934a 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1448,7 +1448,7 @@ def func(): check(x, size('3Pi3c7P2ic??2P')) # function def func(): pass - check(func, size('14Pi')) + check(func, size('15Pi')) class c(): @staticmethod def foo(): diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py new file mode 100644 index 00000000000000..a7f77d69fb0e5f --- /dev/null +++ b/Lib/test/test_type_aliases.py @@ -0,0 +1,99 @@ +import textwrap +import unittest + +from typing import TypeAliasType + +class TypeParamsInvalidTest(unittest.TestCase): + def test_name_collision_01(self): + code = """type TA1[A, A] = None""" + + with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): + exec(code, {}, {}) + + def test_name_collision_02(self): + code = """type TA1[A] = lambda A: None""" + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'A'"): + exec(code, {}, {}) + + def test_name_collision_03(self): + code = textwrap.dedent("""\ + class Outer[A]: + type TA1[A] = None + """ + ) + + with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): + exec(code, {}, {}) + + +class TypeParamsAccessTest(unittest.TestCase): + def test_alias_access_01(self): + code = textwrap.dedent("""\ + type TA1[A, B] = dict[A, B] + """ + ) + + exec(code, {}, {}) + + def test_alias_access_02(self): + code = textwrap.dedent("""\ + type TA1[A, B] = TA1[A, B] | int + """ + ) + + exec(code, {}, {}) + + def test_alias_access_03(self): + code = textwrap.dedent("""\ + class Outer[A]: + def inner[B](self): + type TA1[C] = TA1[A, B] | int + """ + ) + + exec(code, {}, {}) + + +class TypeParamsAliasValueTest(unittest.TestCase): + def test_alias_value_01(self): + type TA1 = int + + self.assertIsInstance(TA1, TypeAliasType) + self.assertEqual(TA1.__value__, int) + self.assertEqual(TA1.__parameters__, ()) + self.assertEqual(TA1.__type_variables__, ()) + + type TA2 = TA1 | str + + self.assertIsInstance(TA2, TypeAliasType) + a, b = TA2.__value__.__args__ + self.assertEqual(a, TA1) + self.assertEqual(b, str) + self.assertEqual(TA2.__parameters__, ()) + self.assertEqual(TA2.__type_variables__, ()) + + def test_alias_access_02(self): + class Parent[A]: + type TA1[B] = dict[A, B] + + self.assertIsInstance(Parent.TA1, TypeAliasType) + self.assertEqual(len(Parent.TA1.__parameters__), 1) + self.assertEqual(len(Parent.__parameters__), 1) + a = Parent.__parameters__[0] + b = Parent.TA1.__parameters__[0] + self.assertEqual(Parent.TA1.__type_variables__, (a, b)) + + def test_alias_access_02(self): + def outer[A](): + type TA1[B] = dict[A, B] + return TA1 + + o = outer() + self.assertIsInstance(o, TypeAliasType) + self.assertEqual(len(o.__parameters__), 1) + self.assertEqual(len(outer.__type_variables__), 1) + a = outer.__type_variables__[0] + b = o.__parameters__[0] + self.assertEqual(o.__type_variables__, (a, b)) + diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py new file mode 100644 index 00000000000000..03a2f652b1343d --- /dev/null +++ b/Lib/test/test_type_params.py @@ -0,0 +1,437 @@ +import asyncio +import textwrap +import unittest + +from typing import TypeVar, TypeVarTuple, ParamSpec + +class TypeParamsInvalidTest(unittest.TestCase): + def test_name_collision_01(self): + code = """def func[A, A](): ...""" + + with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): + exec(code, {}, {}) + + def test_name_collision_02(self): + code = """def func[A](A): ...""" + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'A'"): + exec(code, {}, {}) + + def test_name_collision_03(self): + code = """def func[A](*A): ...""" + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'A'"): + exec(code, {}, {}) + + def test_name_collision_04(self): + # Mangled names should not cause a conflict. + code = textwrap.dedent("""\ + class ClassA: + def func[__A](self, __A): ... + """ + ) + + exec(code, {}, {}) + + def test_name_collision_05(self): + code = textwrap.dedent("""\ + class ClassA: + def func[_ClassA__A](self, __A): ... + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter '__A'"): + exec(code, {}, {}) + + def test_name_collision_06(self): + code = textwrap.dedent("""\ + class ClassA[X]: + def func(self, X): ... + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_07(self): + code = textwrap.dedent("""\ + class ClassA[X]: + def func(self): + X = 1 + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_08(self): + code = textwrap.dedent("""\ + class ClassA[X]: + def func(self): + a = [X for X in []] + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_09(self): + code = textwrap.dedent("""\ + class ClassA[X]: + def func(self): + a = lambda X: None + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_10(self): + code = textwrap.dedent("""\ + class ClassA[X]: + def func[X](self): + ... + """ + ) + + with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_11(self): + code = textwrap.dedent("""\ + class ClassA[X]: + X: int + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_12(self): + code = textwrap.dedent("""\ + def outer(): + X = 1 + def inner[X](): + nonlocal X + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + def test_name_collision_13(self): + code = textwrap.dedent("""\ + X = 1 + def outer(): + def inner[X](): + global X + """ + ) + + with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): + exec(code, {}, {}) + + +class TypeParamsAccessTest(unittest.TestCase): + def test_class_access_01(self): + code = textwrap.dedent("""\ + class ClassA[A, B](dict[A, B]): + ... + """ + ) + + exec(code, {}, {}) + + def test_class_access_02(self): + code = textwrap.dedent("""\ + class MyMeta[A, B](type): ... + class ClassA[A, B](metaclass=MyMeta[A, B]): + ... + """ + ) + + exec(code, {}, {}) + + def test_class_access_03(self): + code = textwrap.dedent("""\ + def my_decorator(a): + ... + @my_decorator(A) + class ClassA[A, B](): + ... + """ + ) + + with self.assertRaisesRegex(NameError, "name 'A' is not defined"): + exec(code, {}, {}) + + def test_function_access_01(self): + code = textwrap.dedent("""\ + def func[A, B](a: dict[A, B]): + ... + """ + ) + + exec(code, {}, {}) + + def test_function_access_02(self): + code = textwrap.dedent("""\ + def func[A](a = list[A]()): + ... + """ + ) + + with self.assertRaisesRegex(NameError, "name 'A' is not defined"): + exec(code, {}, {}) + + def test_function_access_03(self): + code = textwrap.dedent("""\ + def my_decorator(a): + ... + @my_decorator(A) + def func[A](): + ... + """ + ) + + with self.assertRaisesRegex(NameError, "name 'A' is not defined"): + exec(code, {}, {}) + + def test_nested_access_01(self): + code = textwrap.dedent("""\ + class ClassA[A]: + def funcB[B](self): + class ClassC[C]: + def funcD[D](self): + lambda : (A, B, C, D) + """ + ) + + exec(code, {}, {}) + + def test_out_of_scope_01(self): + code = textwrap.dedent("""\ + class ClassA[T]: ... + x = T + """ + ) + + with self.assertRaisesRegex(NameError, "name 'T' is not defined"): + exec(code, {}, {}) + + def test_out_of_scope_02(self): + code = textwrap.dedent("""\ + class ClassA[A]: + def funcB[B](self): ... + + x = B + """ + ) + + with self.assertRaisesRegex(NameError, "name 'B' is not defined"): + exec(code, {}, {}) + + +class TypeParamsTraditionalTypeVars(unittest.TestCase): + def test_traditional_01(self): + code = textwrap.dedent("""\ + from typing import Generic + class ClassA[T](Generic[T]): ... + """ + ) + + with self.assertRaisesRegex(TypeError, r"Cannot inherit from Generic\[...\] multiple types."): + exec(code, {}, {}) + + def test_traditional_02(self): + code = textwrap.dedent("""\ + from typing import TypeVar + S = TypeVar("S") + class ClassA[T](dict[T, S]): ... + """ + ) + + with self.assertRaisesRegex(TypeError, r"Some type variables \(~S\) are not listed in Generic\[T\]"): + exec(code, {}, {}) + + def test_traditional_03(self): + code = textwrap.dedent("""\ + from typing import TypeVar + S = TypeVar("S") + def func[T](a: T, b: S) -> T | S: + return a + """ + ) + + # This does not generate a runtime error, but it should be + # flagged as an error by type checkers. + exec(code, {}, {}) + + + +class TypeParamsTypeVarTest(unittest.TestCase): + def test_typevar_01(self): + def func1[A: str, B: str | int, C: (int, str)](): + return (A, B, C) + + a, b, c = func1() + + self.assertIsInstance(a, TypeVar) + self.assertEqual(a.__bound__, str) + self.assertTrue(a.__autovariance__) + self.assertFalse(a.__covariant__) + self.assertFalse(a.__contravariant__) + + self.assertIsInstance(b, TypeVar) + self.assertEqual(b.__bound__, str | int) + self.assertTrue(b.__autovariance__) + self.assertFalse(b.__covariant__) + self.assertFalse(b.__contravariant__) + + self.assertIsInstance(c, TypeVar) + self.assertEqual(c.__bound__, None) + self.assertEqual(c.__constraints__, (int, str)) + self.assertTrue(c.__autovariance__) + self.assertFalse(c.__covariant__) + self.assertFalse(c.__contravariant__) + + def test_typevar_generator(self): + def get_generator[A](): + def generator1[C](): + yield C + + def generator2[B](): + yield A + yield B + yield from generator1() + return generator2 + + gen = get_generator() + + a, b, c = [x for x in gen()] + + self.assertIsInstance(a, TypeVar) + self.assertEqual(a.__name__, "A") + self.assertIsInstance(b, TypeVar) + self.assertEqual(b.__name__, "B") + self.assertIsInstance(c, TypeVar) + self.assertEqual(c.__name__, "C") + + def test_typevar_coroutine(self): + def get_coroutine[A](): + async def coroutine[B](): + return (A, B) + return coroutine + + co = get_coroutine() + + a, b = asyncio.run(co()) + + self.assertIsInstance(a, TypeVar) + self.assertEqual(a.__name__, "A") + self.assertIsInstance(b, TypeVar) + self.assertEqual(b.__name__, "B") + + +class TypeParamsTypeVarTupleTest(unittest.TestCase): + def test_typevartuple_01(self): + code = textwrap.dedent("""\ + def func1[*A: str](): + return (A, B, C) + """ + ) + + with self.assertRaisesRegex(SyntaxError, r"expected '\('"): + exec(code, {}, {}) + + def test_typevartuple_02(self): + def func1[*A](): + return A + + a = func1() + self.assertIsInstance(a, TypeVarTuple) + + +class TypeParamsTypeVarParamSpec(unittest.TestCase): + def test_paramspec_01(self): + code = textwrap.dedent("""\ + def func1[**A: str](): + return (A, B, C) + """ + ) + + with self.assertRaisesRegex(SyntaxError, r"expected '\('"): + exec(code, {}, {}) + + def test_paramspec_02(self): + def func1[**A](): + return A + + a = func1() + self.assertIsInstance(a, ParamSpec) + self.assertTrue(a.__autovariance__) + self.assertFalse(a.__covariant__) + self.assertFalse(a.__contravariant__) + + + +class TypeParamsTypeParamsDunder(unittest.TestCase): + def test_typeparams_dunder_class_01(self): + class Outer[A, B]: + class Inner[C, D]: + @staticmethod + def get_typeparams(): + return A, B, C, D + + a, b, c, d = Outer.Inner.get_typeparams() + self.assertEqual(Outer.__type_variables__, (a, b)) + self.assertEqual(Outer.Inner.__type_variables__, (a, b, c, d)) + + self.assertEqual(Outer.__parameters__, (a, b)) + self.assertEqual(Outer.Inner.__parameters__, (c, d)) + + def test_typeparams_dunder_class_02(self): + class ClassA: + pass + + self.assertEqual(ClassA.__type_variables__, ()) + + def test_typeparams_dunder_class_03(self): + code = textwrap.dedent("""\ + class ClassA[A](): + pass + ClassA.__type_variables__ = () + """ + ) + + with self.assertRaisesRegex(AttributeError, "attribute '__type_variables__' of 'type' objects is not writable"): + exec(code, {}, {}) + + def test_typeparams_dunder_function_01(self): + def outer[A, B](): + def inner[C, D](): + return A, B, C, D + + return inner + + inner = outer() + a, b, c, d = inner() + self.assertEqual(outer.__type_variables__, (a, b)) + self.assertEqual(inner.__type_variables__, (a, b, c, d)) + + def test_typeparams_dunder_function_02(self): + def func1(): + pass + + self.assertEqual(func1.__type_variables__, ()) + + def test_typeparams_dunder_function_03(self): + code = textwrap.dedent("""\ + def func[A](): + pass + func.__type_variables__ = () + """ + ) + + with self.assertRaisesRegex(AttributeError, "attribute '__type_variables__' of 'function' objects is not writable"): + exec(code, {}, {}) diff --git a/Lib/typing.py b/Lib/typing.py index 1f1c4ffa2566ab..e4877a35952aac 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -149,6 +149,7 @@ def _idfunc(_, x): 'TYPE_CHECKING', 'TypeAlias', 'TypeGuard', + 'TypeAliasType', 'Unpack', ] @@ -935,14 +936,17 @@ class _BoundVarianceMixin: specified type) and type 'variance' (determining subtype relations between generic types). """ - def __init__(self, bound, covariant, contravariant): - """Used to setup TypeVars and ParamSpec's bound, covariant and - contravariant attributes. + def __init__(self, bound, covariant, contravariant, autovariance): + """Used to setup TypeVars and ParamSpec's bound, covariant, + contravariant, and autovariance attributes. """ if covariant and contravariant: raise ValueError("Bivariant types are not supported.") + if autovariance and (covariant or contravariant): + raise ValueError("Variance cannot be specified with autovariance.") self.__covariant__ = bool(covariant) self.__contravariant__ = bool(contravariant) + self.__autovariance__ = bool(autovariance) if bound: self.__bound__ = _type_check(bound, "Bound must be a type.") else: @@ -959,6 +963,8 @@ def __repr__(self): prefix = '+' elif self.__contravariant__: prefix = '-' + elif self.__autovariance__: + prefix = '' else: prefix = '~' return prefix + self.__name__ @@ -967,6 +973,36 @@ def __mro_entries__(self, bases): raise TypeError(f"Cannot subclass an instance of {type(self).__name__}") +class TypeAliasType(_Final, _Immutable, _PickleUsingNameMixin, _root=True): + """Type alias allocated through the use of a "type" statement. + """ + def __init__(self, name, parameters): + self.__value__ = None + self.__name__ = name + self.__parameters__ = parameters + self.__arguments__ = None + + @_tp_cache + def __getitem__(self, args): + if len(self.__parameters__) == 0: + raise TypeError(f"Type alias is not generic") + if self.__arguments__: + raise TypeError(f"Cannot subscript already-subscripted type alias") + copy = TypeAliasType(self.__name__, self.__parameters__) + copy.__value__ = self.__value__ + copy.__arguments__ = args + return copy + + def __repr__(self): + return self.__name__ + + def __or__(self, right): + return Union[self, right] + + def __ror__(self, left): + return Union[left, self] + + class TypeVar(_Final, _Immutable, _BoundVarianceMixin, _PickleUsingNameMixin, _root=True): """Type variable. @@ -1013,9 +1049,9 @@ def longest(x: A, y: A) -> A: """ def __init__(self, name, *constraints, bound=None, - covariant=False, contravariant=False): + covariant=False, contravariant=False, autovariance=False): self.__name__ = name - super().__init__(bound, covariant, contravariant) + super().__init__(bound, covariant, contravariant, autovariance) if constraints and bound is not None: raise TypeError("Constraints cannot be combined with bound=...") if constraints and len(constraints) == 1: @@ -1226,9 +1262,10 @@ def args(self): def kwargs(self): return ParamSpecKwargs(self) - def __init__(self, name, *, bound=None, covariant=False, contravariant=False): + def __init__(self, name, *, bound=None, + covariant=False, contravariant=False, autovariance=False): self.__name__ = name - super().__init__(bound, covariant, contravariant) + super().__init__(bound, covariant, contravariant, autovariance) def_mod = _caller() if def_mod != 'typing': self.__module__ = def_mod diff --git a/Objects/funcobject.c b/Objects/funcobject.c index ce5d7bda32c032..3047ec8884cd32 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -127,6 +127,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) PyErr_Clear(); } op->func_annotations = NULL; + op->func_typevars = NULL; op->vectorcall = _PyFunction_Vectorcall; op->func_version = 0; _PyObject_GC_TRACK(op); @@ -202,6 +203,7 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname op->func_weakreflist = NULL; op->func_module = module; op->func_annotations = NULL; + op->func_typevars = NULL; op->vectorcall = _PyFunction_Vectorcall; op->func_version = 0; _PyObject_GC_TRACK(op); @@ -652,6 +654,18 @@ func_set_annotations(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(igno return 0; } +static PyObject * +func_get_type_variables(PyFunctionObject *op, void *Py_UNUSED(ignored)) +{ + if (op->func_typevars == NULL) { + return PyTuple_New(0); + } + + assert(PyTuple_Check(op->func_typevars)); + Py_XINCREF(op->func_typevars); + return op->func_typevars; +} + static PyGetSetDef func_getsetlist[] = { {"__code__", (getter)func_get_code, (setter)func_set_code}, {"__defaults__", (getter)func_get_defaults, @@ -663,6 +677,7 @@ static PyGetSetDef func_getsetlist[] = { {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, {"__name__", (getter)func_get_name, (setter)func_set_name}, {"__qualname__", (getter)func_get_qualname, (setter)func_set_qualname}, + {"__type_variables__", (getter)func_get_type_variables, NULL}, {NULL} /* Sentinel */ }; @@ -783,6 +798,7 @@ func_clear(PyFunctionObject *op) Py_CLEAR(op->func_dict); Py_CLEAR(op->func_closure); Py_CLEAR(op->func_annotations); + Py_CLEAR(op->func_typevars); // Don't Py_CLEAR(op->func_code), since code is always required // to be non-NULL. Similarly, name and qualname shouldn't be NULL. // However, name and qualname could be str subclasses, so they @@ -837,6 +853,7 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) Py_VISIT(f->func_dict); Py_VISIT(f->func_closure); Py_VISIT(f->func_annotations); + Py_VISIT(f->func_typevars); Py_VISIT(f->func_qualname); return 0; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 995547e7915f77..fc5394dc8a6785 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1137,6 +1137,21 @@ type_get_annotations(PyTypeObject *type, void *context) return annotations; } +static PyObject * +type_get_type_variables(PyTypeObject *type, void *context) +{ + PyObject *params; + + params = PyDict_GetItem(type->tp_dict, &_Py_ID(__type_variables__)); + + if (params) { + Py_INCREF(params); + return params; + } + + return PyTuple_New(0); +} + static int type_set_annotations(PyTypeObject *type, PyObject *value, void *context) { @@ -1211,6 +1226,7 @@ static PyGetSetDef type_getsets[] = { {"__doc__", (getter)type_get_doc, (setter)type_set_doc, NULL}, {"__text_signature__", (getter)type_get_text_signature, NULL, NULL}, {"__annotations__", (getter)type_get_annotations, (setter)type_set_annotations, NULL}, + {"__type_variables__", (getter)type_get_type_variables, NULL, NULL}, {0} }; diff --git a/Parser/Python.asdl b/Parser/Python.asdl index e9423a7c984f21..db0f12a5f46ebe 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -8,14 +8,15 @@ module Python | Expression(expr body) | FunctionType(expr* argtypes, expr returns) - stmt = FunctionDef(identifier name, arguments args, + stmt = FunctionDef(identifier name, typeparam* typeparams, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment) - | AsyncFunctionDef(identifier name, arguments args, + | AsyncFunctionDef(identifier name, typeparam* typeparams, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment) | ClassDef(identifier name, + typeparam* typeparams, expr* bases, keyword* keywords, stmt* body, @@ -24,6 +25,7 @@ module Python | Delete(expr* targets) | Assign(expr* targets, expr value, string? type_comment) + | TypeAlias(identifier name, typeparam* typeparams, expr value) | AugAssign(expr target, operator op, expr value) -- 'simple' indicates that we annotate simple name without parens | AnnAssign(expr target, expr annotation, expr? value, int simple) @@ -142,4 +144,9 @@ module Python attributes (int lineno, int col_offset, int end_lineno, int end_col_offset) type_ignore = TypeIgnore(int lineno, string tag) + + typeparam = TypeVar(identifier name, expr? bound) + | ParamSpec(identifier name) + | TypeVarTuple(identifier name) + attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) } diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c index 46390966892d16..682daaca991d4f 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -751,7 +751,8 @@ _PyPegen_function_def_decorators(Parser *p, asdl_expr_seq *decorators, stmt_ty f assert(function_def != NULL); if (function_def->kind == AsyncFunctionDef_kind) { return _PyAST_AsyncFunctionDef( - function_def->v.FunctionDef.name, function_def->v.FunctionDef.args, + function_def->v.FunctionDef.name, function_def->v.FunctionDef.typeparams, + function_def->v.FunctionDef.args, function_def->v.FunctionDef.body, decorators, function_def->v.FunctionDef.returns, function_def->v.FunctionDef.type_comment, function_def->lineno, function_def->col_offset, function_def->end_lineno, function_def->end_col_offset, @@ -759,7 +760,8 @@ _PyPegen_function_def_decorators(Parser *p, asdl_expr_seq *decorators, stmt_ty f } return _PyAST_FunctionDef( - function_def->v.FunctionDef.name, function_def->v.FunctionDef.args, + function_def->v.FunctionDef.name, function_def->v.FunctionDef.typeparams, + function_def->v.FunctionDef.args, function_def->v.FunctionDef.body, decorators, function_def->v.FunctionDef.returns, function_def->v.FunctionDef.type_comment, function_def->lineno, @@ -773,8 +775,9 @@ _PyPegen_class_def_decorators(Parser *p, asdl_expr_seq *decorators, stmt_ty clas { assert(class_def != NULL); return _PyAST_ClassDef( - class_def->v.ClassDef.name, class_def->v.ClassDef.bases, - class_def->v.ClassDef.keywords, class_def->v.ClassDef.body, decorators, + class_def->v.ClassDef.name, class_def->v.ClassDef.typeparams, + class_def->v.ClassDef.bases, class_def->v.ClassDef.keywords, + class_def->v.ClassDef.body, decorators, class_def->lineno, class_def->col_offset, class_def->end_lineno, class_def->end_col_offset, p->arena); } diff --git a/Parser/parser.c b/Parser/parser.c index e0a88a9cc72c8b..091b12c11c094e 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -75,6 +75,7 @@ static char *soft_keywords[] = { "_", "case", "match", + "type", NULL, }; #define file_type 1000 @@ -175,390 +176,397 @@ static char *soft_keywords[] = { #define positional_patterns_type 1095 #define keyword_patterns_type 1096 #define keyword_pattern_type 1097 -#define expressions_type 1098 -#define expression_type 1099 -#define yield_expr_type 1100 -#define star_expressions_type 1101 -#define star_expression_type 1102 -#define star_named_expressions_type 1103 -#define star_named_expression_type 1104 -#define assignment_expression_type 1105 -#define named_expression_type 1106 -#define disjunction_type 1107 -#define conjunction_type 1108 -#define inversion_type 1109 -#define comparison_type 1110 -#define compare_op_bitwise_or_pair_type 1111 -#define eq_bitwise_or_type 1112 -#define noteq_bitwise_or_type 1113 -#define lte_bitwise_or_type 1114 -#define lt_bitwise_or_type 1115 -#define gte_bitwise_or_type 1116 -#define gt_bitwise_or_type 1117 -#define notin_bitwise_or_type 1118 -#define in_bitwise_or_type 1119 -#define isnot_bitwise_or_type 1120 -#define is_bitwise_or_type 1121 -#define bitwise_or_type 1122 // Left-recursive -#define bitwise_xor_type 1123 // Left-recursive -#define bitwise_and_type 1124 // Left-recursive -#define shift_expr_type 1125 // Left-recursive -#define sum_type 1126 // Left-recursive -#define term_type 1127 // Left-recursive -#define factor_type 1128 -#define power_type 1129 -#define await_primary_type 1130 -#define primary_type 1131 // Left-recursive -#define slices_type 1132 -#define slice_type 1133 -#define atom_type 1134 -#define group_type 1135 -#define lambdef_type 1136 -#define lambda_params_type 1137 -#define lambda_parameters_type 1138 -#define lambda_slash_no_default_type 1139 -#define lambda_slash_with_default_type 1140 -#define lambda_star_etc_type 1141 -#define lambda_kwds_type 1142 -#define lambda_param_no_default_type 1143 -#define lambda_param_with_default_type 1144 -#define lambda_param_maybe_default_type 1145 -#define lambda_param_type 1146 -#define strings_type 1147 -#define list_type 1148 -#define tuple_type 1149 -#define set_type 1150 -#define dict_type 1151 -#define double_starred_kvpairs_type 1152 -#define double_starred_kvpair_type 1153 -#define kvpair_type 1154 -#define for_if_clauses_type 1155 -#define for_if_clause_type 1156 -#define listcomp_type 1157 -#define setcomp_type 1158 -#define genexp_type 1159 -#define dictcomp_type 1160 -#define arguments_type 1161 -#define args_type 1162 -#define kwargs_type 1163 -#define starred_expression_type 1164 -#define kwarg_or_starred_type 1165 -#define kwarg_or_double_starred_type 1166 -#define star_targets_type 1167 -#define star_targets_list_seq_type 1168 -#define star_targets_tuple_seq_type 1169 -#define star_target_type 1170 -#define target_with_star_atom_type 1171 -#define star_atom_type 1172 -#define single_target_type 1173 -#define single_subscript_attribute_target_type 1174 -#define t_primary_type 1175 // Left-recursive -#define t_lookahead_type 1176 -#define del_targets_type 1177 -#define del_target_type 1178 -#define del_t_atom_type 1179 -#define type_expressions_type 1180 -#define func_type_comment_type 1181 -#define invalid_arguments_type 1182 -#define invalid_kwarg_type 1183 -#define expression_without_invalid_type 1184 -#define invalid_legacy_expression_type 1185 -#define invalid_expression_type 1186 -#define invalid_named_expression_type 1187 -#define invalid_assignment_type 1188 -#define invalid_ann_assign_target_type 1189 -#define invalid_del_stmt_type 1190 -#define invalid_block_type 1191 -#define invalid_comprehension_type 1192 -#define invalid_dict_comprehension_type 1193 -#define invalid_parameters_type 1194 -#define invalid_default_type 1195 -#define invalid_star_etc_type 1196 -#define invalid_kwds_type 1197 -#define invalid_parameters_helper_type 1198 -#define invalid_lambda_parameters_type 1199 -#define invalid_lambda_parameters_helper_type 1200 -#define invalid_lambda_star_etc_type 1201 -#define invalid_lambda_kwds_type 1202 -#define invalid_double_type_comments_type 1203 -#define invalid_with_item_type 1204 -#define invalid_for_target_type 1205 -#define invalid_group_type 1206 -#define invalid_import_type 1207 -#define invalid_import_from_targets_type 1208 -#define invalid_with_stmt_type 1209 -#define invalid_with_stmt_indent_type 1210 -#define invalid_try_stmt_type 1211 -#define invalid_except_stmt_type 1212 -#define invalid_finally_stmt_type 1213 -#define invalid_except_stmt_indent_type 1214 -#define invalid_except_star_stmt_indent_type 1215 -#define invalid_match_stmt_type 1216 -#define invalid_case_block_type 1217 -#define invalid_as_pattern_type 1218 -#define invalid_class_pattern_type 1219 -#define invalid_class_argument_pattern_type 1220 -#define invalid_if_stmt_type 1221 -#define invalid_elif_stmt_type 1222 -#define invalid_else_stmt_type 1223 -#define invalid_while_stmt_type 1224 -#define invalid_for_stmt_type 1225 -#define invalid_def_raw_type 1226 -#define invalid_class_def_raw_type 1227 -#define invalid_double_starred_kvpairs_type 1228 -#define invalid_kvpair_type 1229 -#define invalid_starred_expression_type 1230 -#define _loop0_1_type 1231 -#define _loop0_2_type 1232 -#define _loop1_3_type 1233 -#define _loop0_5_type 1234 -#define _gather_4_type 1235 -#define _tmp_6_type 1236 -#define _tmp_7_type 1237 -#define _tmp_8_type 1238 -#define _tmp_9_type 1239 -#define _tmp_10_type 1240 -#define _tmp_11_type 1241 -#define _tmp_12_type 1242 -#define _tmp_13_type 1243 -#define _loop1_14_type 1244 -#define _tmp_15_type 1245 -#define _tmp_16_type 1246 -#define _tmp_17_type 1247 -#define _loop0_19_type 1248 -#define _gather_18_type 1249 -#define _loop0_21_type 1250 -#define _gather_20_type 1251 -#define _tmp_22_type 1252 -#define _tmp_23_type 1253 -#define _loop0_24_type 1254 -#define _loop1_25_type 1255 -#define _loop0_27_type 1256 -#define _gather_26_type 1257 -#define _tmp_28_type 1258 -#define _loop0_30_type 1259 -#define _gather_29_type 1260 -#define _tmp_31_type 1261 -#define _loop1_32_type 1262 -#define _tmp_33_type 1263 -#define _tmp_34_type 1264 -#define _tmp_35_type 1265 -#define _loop0_36_type 1266 -#define _loop0_37_type 1267 -#define _loop0_38_type 1268 -#define _loop1_39_type 1269 -#define _loop0_40_type 1270 -#define _loop1_41_type 1271 -#define _loop1_42_type 1272 -#define _loop1_43_type 1273 -#define _loop0_44_type 1274 -#define _loop1_45_type 1275 -#define _loop0_46_type 1276 -#define _loop1_47_type 1277 -#define _loop0_48_type 1278 -#define _loop0_49_type 1279 -#define _loop1_50_type 1280 -#define _loop0_52_type 1281 -#define _gather_51_type 1282 -#define _loop0_54_type 1283 -#define _gather_53_type 1284 -#define _loop0_56_type 1285 -#define _gather_55_type 1286 -#define _loop0_58_type 1287 -#define _gather_57_type 1288 -#define _tmp_59_type 1289 -#define _loop1_60_type 1290 -#define _loop1_61_type 1291 -#define _tmp_62_type 1292 -#define _tmp_63_type 1293 -#define _loop1_64_type 1294 -#define _loop0_66_type 1295 -#define _gather_65_type 1296 -#define _tmp_67_type 1297 -#define _tmp_68_type 1298 -#define _tmp_69_type 1299 -#define _tmp_70_type 1300 -#define _loop0_72_type 1301 -#define _gather_71_type 1302 -#define _loop0_74_type 1303 -#define _gather_73_type 1304 -#define _tmp_75_type 1305 -#define _loop0_77_type 1306 -#define _gather_76_type 1307 -#define _loop0_79_type 1308 -#define _gather_78_type 1309 -#define _loop1_80_type 1310 -#define _loop1_81_type 1311 -#define _loop0_83_type 1312 -#define _gather_82_type 1313 -#define _loop1_84_type 1314 -#define _loop1_85_type 1315 -#define _loop1_86_type 1316 -#define _tmp_87_type 1317 -#define _loop0_89_type 1318 -#define _gather_88_type 1319 -#define _tmp_90_type 1320 -#define _tmp_91_type 1321 -#define _tmp_92_type 1322 -#define _tmp_93_type 1323 -#define _tmp_94_type 1324 -#define _loop0_95_type 1325 -#define _loop0_96_type 1326 -#define _loop0_97_type 1327 -#define _loop1_98_type 1328 -#define _loop0_99_type 1329 -#define _loop1_100_type 1330 -#define _loop1_101_type 1331 -#define _loop1_102_type 1332 -#define _loop0_103_type 1333 -#define _loop1_104_type 1334 -#define _loop0_105_type 1335 -#define _loop1_106_type 1336 -#define _loop0_107_type 1337 -#define _loop1_108_type 1338 -#define _loop1_109_type 1339 -#define _tmp_110_type 1340 -#define _loop0_112_type 1341 -#define _gather_111_type 1342 -#define _loop1_113_type 1343 -#define _loop0_114_type 1344 -#define _loop0_115_type 1345 -#define _tmp_116_type 1346 -#define _loop0_118_type 1347 -#define _gather_117_type 1348 -#define _tmp_119_type 1349 -#define _loop0_121_type 1350 -#define _gather_120_type 1351 -#define _loop0_123_type 1352 -#define _gather_122_type 1353 -#define _loop0_125_type 1354 -#define _gather_124_type 1355 -#define _loop0_127_type 1356 -#define _gather_126_type 1357 -#define _loop0_128_type 1358 -#define _loop0_130_type 1359 -#define _gather_129_type 1360 -#define _loop1_131_type 1361 -#define _tmp_132_type 1362 -#define _loop0_134_type 1363 -#define _gather_133_type 1364 -#define _loop0_136_type 1365 -#define _gather_135_type 1366 -#define _loop0_138_type 1367 -#define _gather_137_type 1368 -#define _loop0_140_type 1369 -#define _gather_139_type 1370 -#define _loop0_142_type 1371 -#define _gather_141_type 1372 -#define _tmp_143_type 1373 -#define _tmp_144_type 1374 -#define _tmp_145_type 1375 -#define _tmp_146_type 1376 -#define _tmp_147_type 1377 -#define _tmp_148_type 1378 -#define _tmp_149_type 1379 -#define _tmp_150_type 1380 -#define _tmp_151_type 1381 -#define _tmp_152_type 1382 -#define _tmp_153_type 1383 -#define _loop0_154_type 1384 -#define _loop0_155_type 1385 -#define _loop0_156_type 1386 -#define _tmp_157_type 1387 -#define _tmp_158_type 1388 -#define _tmp_159_type 1389 -#define _tmp_160_type 1390 -#define _tmp_161_type 1391 -#define _loop0_162_type 1392 -#define _loop0_163_type 1393 -#define _loop0_164_type 1394 -#define _loop1_165_type 1395 -#define _tmp_166_type 1396 -#define _loop0_167_type 1397 -#define _tmp_168_type 1398 -#define _loop0_169_type 1399 -#define _loop1_170_type 1400 -#define _tmp_171_type 1401 -#define _tmp_172_type 1402 -#define _tmp_173_type 1403 -#define _loop0_174_type 1404 -#define _tmp_175_type 1405 -#define _tmp_176_type 1406 -#define _loop1_177_type 1407 -#define _tmp_178_type 1408 -#define _loop0_179_type 1409 -#define _loop0_180_type 1410 -#define _loop0_181_type 1411 -#define _loop0_183_type 1412 -#define _gather_182_type 1413 -#define _tmp_184_type 1414 -#define _loop0_185_type 1415 -#define _tmp_186_type 1416 -#define _loop0_187_type 1417 -#define _loop1_188_type 1418 -#define _loop1_189_type 1419 -#define _tmp_190_type 1420 -#define _tmp_191_type 1421 -#define _loop0_192_type 1422 -#define _tmp_193_type 1423 -#define _tmp_194_type 1424 -#define _tmp_195_type 1425 -#define _loop0_197_type 1426 -#define _gather_196_type 1427 -#define _loop0_199_type 1428 -#define _gather_198_type 1429 -#define _loop0_201_type 1430 -#define _gather_200_type 1431 -#define _loop0_203_type 1432 -#define _gather_202_type 1433 -#define _tmp_204_type 1434 -#define _loop0_205_type 1435 -#define _loop1_206_type 1436 -#define _tmp_207_type 1437 -#define _loop0_208_type 1438 -#define _loop1_209_type 1439 -#define _tmp_210_type 1440 -#define _tmp_211_type 1441 -#define _tmp_212_type 1442 -#define _tmp_213_type 1443 -#define _tmp_214_type 1444 -#define _tmp_215_type 1445 -#define _tmp_216_type 1446 -#define _tmp_217_type 1447 -#define _tmp_218_type 1448 -#define _tmp_219_type 1449 -#define _loop0_221_type 1450 -#define _gather_220_type 1451 -#define _tmp_222_type 1452 -#define _tmp_223_type 1453 -#define _tmp_224_type 1454 -#define _tmp_225_type 1455 -#define _tmp_226_type 1456 -#define _tmp_227_type 1457 -#define _tmp_228_type 1458 -#define _tmp_229_type 1459 -#define _tmp_230_type 1460 -#define _tmp_231_type 1461 -#define _tmp_232_type 1462 -#define _tmp_233_type 1463 -#define _tmp_234_type 1464 -#define _tmp_235_type 1465 -#define _tmp_236_type 1466 -#define _tmp_237_type 1467 -#define _tmp_238_type 1468 -#define _tmp_239_type 1469 -#define _tmp_240_type 1470 -#define _tmp_241_type 1471 -#define _tmp_242_type 1472 -#define _tmp_243_type 1473 -#define _tmp_244_type 1474 -#define _tmp_245_type 1475 -#define _tmp_246_type 1476 -#define _tmp_247_type 1477 -#define _tmp_248_type 1478 -#define _tmp_249_type 1479 -#define _tmp_250_type 1480 -#define _tmp_251_type 1481 +#define type_alias_type 1098 +#define type_params_type 1099 +#define type_param_seq_type 1100 +#define type_param_type 1101 +#define type_param_bound_type 1102 +#define expressions_type 1103 +#define expression_type 1104 +#define yield_expr_type 1105 +#define star_expressions_type 1106 +#define star_expression_type 1107 +#define star_named_expressions_type 1108 +#define star_named_expression_type 1109 +#define assignment_expression_type 1110 +#define named_expression_type 1111 +#define disjunction_type 1112 +#define conjunction_type 1113 +#define inversion_type 1114 +#define comparison_type 1115 +#define compare_op_bitwise_or_pair_type 1116 +#define eq_bitwise_or_type 1117 +#define noteq_bitwise_or_type 1118 +#define lte_bitwise_or_type 1119 +#define lt_bitwise_or_type 1120 +#define gte_bitwise_or_type 1121 +#define gt_bitwise_or_type 1122 +#define notin_bitwise_or_type 1123 +#define in_bitwise_or_type 1124 +#define isnot_bitwise_or_type 1125 +#define is_bitwise_or_type 1126 +#define bitwise_or_type 1127 // Left-recursive +#define bitwise_xor_type 1128 // Left-recursive +#define bitwise_and_type 1129 // Left-recursive +#define shift_expr_type 1130 // Left-recursive +#define sum_type 1131 // Left-recursive +#define term_type 1132 // Left-recursive +#define factor_type 1133 +#define power_type 1134 +#define await_primary_type 1135 +#define primary_type 1136 // Left-recursive +#define slices_type 1137 +#define slice_type 1138 +#define atom_type 1139 +#define group_type 1140 +#define lambdef_type 1141 +#define lambda_params_type 1142 +#define lambda_parameters_type 1143 +#define lambda_slash_no_default_type 1144 +#define lambda_slash_with_default_type 1145 +#define lambda_star_etc_type 1146 +#define lambda_kwds_type 1147 +#define lambda_param_no_default_type 1148 +#define lambda_param_with_default_type 1149 +#define lambda_param_maybe_default_type 1150 +#define lambda_param_type 1151 +#define strings_type 1152 +#define list_type 1153 +#define tuple_type 1154 +#define set_type 1155 +#define dict_type 1156 +#define double_starred_kvpairs_type 1157 +#define double_starred_kvpair_type 1158 +#define kvpair_type 1159 +#define for_if_clauses_type 1160 +#define for_if_clause_type 1161 +#define listcomp_type 1162 +#define setcomp_type 1163 +#define genexp_type 1164 +#define dictcomp_type 1165 +#define arguments_type 1166 +#define args_type 1167 +#define kwargs_type 1168 +#define starred_expression_type 1169 +#define kwarg_or_starred_type 1170 +#define kwarg_or_double_starred_type 1171 +#define star_targets_type 1172 +#define star_targets_list_seq_type 1173 +#define star_targets_tuple_seq_type 1174 +#define star_target_type 1175 +#define target_with_star_atom_type 1176 +#define star_atom_type 1177 +#define single_target_type 1178 +#define single_subscript_attribute_target_type 1179 +#define t_primary_type 1180 // Left-recursive +#define t_lookahead_type 1181 +#define del_targets_type 1182 +#define del_target_type 1183 +#define del_t_atom_type 1184 +#define type_expressions_type 1185 +#define func_type_comment_type 1186 +#define invalid_arguments_type 1187 +#define invalid_kwarg_type 1188 +#define expression_without_invalid_type 1189 +#define invalid_legacy_expression_type 1190 +#define invalid_expression_type 1191 +#define invalid_named_expression_type 1192 +#define invalid_assignment_type 1193 +#define invalid_ann_assign_target_type 1194 +#define invalid_del_stmt_type 1195 +#define invalid_block_type 1196 +#define invalid_comprehension_type 1197 +#define invalid_dict_comprehension_type 1198 +#define invalid_parameters_type 1199 +#define invalid_default_type 1200 +#define invalid_star_etc_type 1201 +#define invalid_kwds_type 1202 +#define invalid_parameters_helper_type 1203 +#define invalid_lambda_parameters_type 1204 +#define invalid_lambda_parameters_helper_type 1205 +#define invalid_lambda_star_etc_type 1206 +#define invalid_lambda_kwds_type 1207 +#define invalid_double_type_comments_type 1208 +#define invalid_with_item_type 1209 +#define invalid_for_target_type 1210 +#define invalid_group_type 1211 +#define invalid_import_type 1212 +#define invalid_import_from_targets_type 1213 +#define invalid_with_stmt_type 1214 +#define invalid_with_stmt_indent_type 1215 +#define invalid_try_stmt_type 1216 +#define invalid_except_stmt_type 1217 +#define invalid_finally_stmt_type 1218 +#define invalid_except_stmt_indent_type 1219 +#define invalid_except_star_stmt_indent_type 1220 +#define invalid_match_stmt_type 1221 +#define invalid_case_block_type 1222 +#define invalid_as_pattern_type 1223 +#define invalid_class_pattern_type 1224 +#define invalid_class_argument_pattern_type 1225 +#define invalid_if_stmt_type 1226 +#define invalid_elif_stmt_type 1227 +#define invalid_else_stmt_type 1228 +#define invalid_while_stmt_type 1229 +#define invalid_for_stmt_type 1230 +#define invalid_def_raw_type 1231 +#define invalid_class_def_raw_type 1232 +#define invalid_double_starred_kvpairs_type 1233 +#define invalid_kvpair_type 1234 +#define invalid_starred_expression_type 1235 +#define _loop0_1_type 1236 +#define _loop0_2_type 1237 +#define _loop1_3_type 1238 +#define _loop0_5_type 1239 +#define _gather_4_type 1240 +#define _tmp_6_type 1241 +#define _tmp_7_type 1242 +#define _tmp_8_type 1243 +#define _tmp_9_type 1244 +#define _tmp_10_type 1245 +#define _tmp_11_type 1246 +#define _tmp_12_type 1247 +#define _tmp_13_type 1248 +#define _loop1_14_type 1249 +#define _tmp_15_type 1250 +#define _tmp_16_type 1251 +#define _tmp_17_type 1252 +#define _loop0_19_type 1253 +#define _gather_18_type 1254 +#define _loop0_21_type 1255 +#define _gather_20_type 1256 +#define _tmp_22_type 1257 +#define _tmp_23_type 1258 +#define _loop0_24_type 1259 +#define _loop1_25_type 1260 +#define _loop0_27_type 1261 +#define _gather_26_type 1262 +#define _tmp_28_type 1263 +#define _loop0_30_type 1264 +#define _gather_29_type 1265 +#define _tmp_31_type 1266 +#define _loop1_32_type 1267 +#define _tmp_33_type 1268 +#define _tmp_34_type 1269 +#define _tmp_35_type 1270 +#define _loop0_36_type 1271 +#define _loop0_37_type 1272 +#define _loop0_38_type 1273 +#define _loop1_39_type 1274 +#define _loop0_40_type 1275 +#define _loop1_41_type 1276 +#define _loop1_42_type 1277 +#define _loop1_43_type 1278 +#define _loop0_44_type 1279 +#define _loop1_45_type 1280 +#define _loop0_46_type 1281 +#define _loop1_47_type 1282 +#define _loop0_48_type 1283 +#define _loop0_49_type 1284 +#define _loop1_50_type 1285 +#define _loop0_52_type 1286 +#define _gather_51_type 1287 +#define _loop0_54_type 1288 +#define _gather_53_type 1289 +#define _loop0_56_type 1290 +#define _gather_55_type 1291 +#define _loop0_58_type 1292 +#define _gather_57_type 1293 +#define _tmp_59_type 1294 +#define _loop1_60_type 1295 +#define _loop1_61_type 1296 +#define _tmp_62_type 1297 +#define _tmp_63_type 1298 +#define _loop1_64_type 1299 +#define _loop0_66_type 1300 +#define _gather_65_type 1301 +#define _tmp_67_type 1302 +#define _tmp_68_type 1303 +#define _tmp_69_type 1304 +#define _tmp_70_type 1305 +#define _loop0_72_type 1306 +#define _gather_71_type 1307 +#define _loop0_74_type 1308 +#define _gather_73_type 1309 +#define _tmp_75_type 1310 +#define _loop0_77_type 1311 +#define _gather_76_type 1312 +#define _loop0_79_type 1313 +#define _gather_78_type 1314 +#define _loop0_81_type 1315 +#define _gather_80_type 1316 +#define _loop1_82_type 1317 +#define _loop1_83_type 1318 +#define _loop0_85_type 1319 +#define _gather_84_type 1320 +#define _loop1_86_type 1321 +#define _loop1_87_type 1322 +#define _loop1_88_type 1323 +#define _tmp_89_type 1324 +#define _loop0_91_type 1325 +#define _gather_90_type 1326 +#define _tmp_92_type 1327 +#define _tmp_93_type 1328 +#define _tmp_94_type 1329 +#define _tmp_95_type 1330 +#define _tmp_96_type 1331 +#define _loop0_97_type 1332 +#define _loop0_98_type 1333 +#define _loop0_99_type 1334 +#define _loop1_100_type 1335 +#define _loop0_101_type 1336 +#define _loop1_102_type 1337 +#define _loop1_103_type 1338 +#define _loop1_104_type 1339 +#define _loop0_105_type 1340 +#define _loop1_106_type 1341 +#define _loop0_107_type 1342 +#define _loop1_108_type 1343 +#define _loop0_109_type 1344 +#define _loop1_110_type 1345 +#define _loop1_111_type 1346 +#define _tmp_112_type 1347 +#define _loop0_114_type 1348 +#define _gather_113_type 1349 +#define _loop1_115_type 1350 +#define _loop0_116_type 1351 +#define _loop0_117_type 1352 +#define _tmp_118_type 1353 +#define _loop0_120_type 1354 +#define _gather_119_type 1355 +#define _tmp_121_type 1356 +#define _loop0_123_type 1357 +#define _gather_122_type 1358 +#define _loop0_125_type 1359 +#define _gather_124_type 1360 +#define _loop0_127_type 1361 +#define _gather_126_type 1362 +#define _loop0_129_type 1363 +#define _gather_128_type 1364 +#define _loop0_130_type 1365 +#define _loop0_132_type 1366 +#define _gather_131_type 1367 +#define _loop1_133_type 1368 +#define _tmp_134_type 1369 +#define _loop0_136_type 1370 +#define _gather_135_type 1371 +#define _loop0_138_type 1372 +#define _gather_137_type 1373 +#define _loop0_140_type 1374 +#define _gather_139_type 1375 +#define _loop0_142_type 1376 +#define _gather_141_type 1377 +#define _loop0_144_type 1378 +#define _gather_143_type 1379 +#define _tmp_145_type 1380 +#define _tmp_146_type 1381 +#define _tmp_147_type 1382 +#define _tmp_148_type 1383 +#define _tmp_149_type 1384 +#define _tmp_150_type 1385 +#define _tmp_151_type 1386 +#define _tmp_152_type 1387 +#define _tmp_153_type 1388 +#define _tmp_154_type 1389 +#define _tmp_155_type 1390 +#define _loop0_156_type 1391 +#define _loop0_157_type 1392 +#define _loop0_158_type 1393 +#define _tmp_159_type 1394 +#define _tmp_160_type 1395 +#define _tmp_161_type 1396 +#define _tmp_162_type 1397 +#define _tmp_163_type 1398 +#define _loop0_164_type 1399 +#define _loop0_165_type 1400 +#define _loop0_166_type 1401 +#define _loop1_167_type 1402 +#define _tmp_168_type 1403 +#define _loop0_169_type 1404 +#define _tmp_170_type 1405 +#define _loop0_171_type 1406 +#define _loop1_172_type 1407 +#define _tmp_173_type 1408 +#define _tmp_174_type 1409 +#define _tmp_175_type 1410 +#define _loop0_176_type 1411 +#define _tmp_177_type 1412 +#define _tmp_178_type 1413 +#define _loop1_179_type 1414 +#define _tmp_180_type 1415 +#define _loop0_181_type 1416 +#define _loop0_182_type 1417 +#define _loop0_183_type 1418 +#define _loop0_185_type 1419 +#define _gather_184_type 1420 +#define _tmp_186_type 1421 +#define _loop0_187_type 1422 +#define _tmp_188_type 1423 +#define _loop0_189_type 1424 +#define _loop1_190_type 1425 +#define _loop1_191_type 1426 +#define _tmp_192_type 1427 +#define _tmp_193_type 1428 +#define _loop0_194_type 1429 +#define _tmp_195_type 1430 +#define _tmp_196_type 1431 +#define _tmp_197_type 1432 +#define _loop0_199_type 1433 +#define _gather_198_type 1434 +#define _loop0_201_type 1435 +#define _gather_200_type 1436 +#define _loop0_203_type 1437 +#define _gather_202_type 1438 +#define _loop0_205_type 1439 +#define _gather_204_type 1440 +#define _tmp_206_type 1441 +#define _loop0_207_type 1442 +#define _loop1_208_type 1443 +#define _tmp_209_type 1444 +#define _loop0_210_type 1445 +#define _loop1_211_type 1446 +#define _tmp_212_type 1447 +#define _tmp_213_type 1448 +#define _tmp_214_type 1449 +#define _tmp_215_type 1450 +#define _tmp_216_type 1451 +#define _tmp_217_type 1452 +#define _tmp_218_type 1453 +#define _tmp_219_type 1454 +#define _tmp_220_type 1455 +#define _tmp_221_type 1456 +#define _loop0_223_type 1457 +#define _gather_222_type 1458 +#define _tmp_224_type 1459 +#define _tmp_225_type 1460 +#define _tmp_226_type 1461 +#define _tmp_227_type 1462 +#define _tmp_228_type 1463 +#define _tmp_229_type 1464 +#define _tmp_230_type 1465 +#define _tmp_231_type 1466 +#define _tmp_232_type 1467 +#define _tmp_233_type 1468 +#define _tmp_234_type 1469 +#define _tmp_235_type 1470 +#define _tmp_236_type 1471 +#define _tmp_237_type 1472 +#define _tmp_238_type 1473 +#define _tmp_239_type 1474 +#define _tmp_240_type 1475 +#define _tmp_241_type 1476 +#define _tmp_242_type 1477 +#define _tmp_243_type 1478 +#define _tmp_244_type 1479 +#define _tmp_245_type 1480 +#define _tmp_246_type 1481 +#define _tmp_247_type 1482 +#define _tmp_248_type 1483 +#define _tmp_249_type 1484 +#define _tmp_250_type 1485 +#define _tmp_251_type 1486 +#define _tmp_252_type 1487 +#define _tmp_253_type 1488 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -658,6 +666,11 @@ static pattern_ty class_pattern_rule(Parser *p); static asdl_pattern_seq* positional_patterns_rule(Parser *p); static asdl_seq* keyword_patterns_rule(Parser *p); static KeyPatternPair* keyword_pattern_rule(Parser *p); +static stmt_ty type_alias_rule(Parser *p); +static asdl_typeparam_seq* type_params_rule(Parser *p); +static asdl_typeparam_seq* type_param_seq_rule(Parser *p); +static typeparam_ty type_param_rule(Parser *p); +static expr_ty type_param_bound_rule(Parser *p); static expr_ty expressions_rule(Parser *p); static expr_ty expression_rule(Parser *p); static expr_ty yield_expr_rule(Parser *p); @@ -870,61 +883,61 @@ static asdl_seq *_loop0_77_rule(Parser *p); static asdl_seq *_gather_76_rule(Parser *p); static asdl_seq *_loop0_79_rule(Parser *p); static asdl_seq *_gather_78_rule(Parser *p); -static asdl_seq *_loop1_80_rule(Parser *p); -static asdl_seq *_loop1_81_rule(Parser *p); -static asdl_seq *_loop0_83_rule(Parser *p); -static asdl_seq *_gather_82_rule(Parser *p); -static asdl_seq *_loop1_84_rule(Parser *p); -static asdl_seq *_loop1_85_rule(Parser *p); +static asdl_seq *_loop0_81_rule(Parser *p); +static asdl_seq *_gather_80_rule(Parser *p); +static asdl_seq *_loop1_82_rule(Parser *p); +static asdl_seq *_loop1_83_rule(Parser *p); +static asdl_seq *_loop0_85_rule(Parser *p); +static asdl_seq *_gather_84_rule(Parser *p); static asdl_seq *_loop1_86_rule(Parser *p); -static void *_tmp_87_rule(Parser *p); -static asdl_seq *_loop0_89_rule(Parser *p); -static asdl_seq *_gather_88_rule(Parser *p); -static void *_tmp_90_rule(Parser *p); -static void *_tmp_91_rule(Parser *p); +static asdl_seq *_loop1_87_rule(Parser *p); +static asdl_seq *_loop1_88_rule(Parser *p); +static void *_tmp_89_rule(Parser *p); +static asdl_seq *_loop0_91_rule(Parser *p); +static asdl_seq *_gather_90_rule(Parser *p); static void *_tmp_92_rule(Parser *p); static void *_tmp_93_rule(Parser *p); static void *_tmp_94_rule(Parser *p); -static asdl_seq *_loop0_95_rule(Parser *p); -static asdl_seq *_loop0_96_rule(Parser *p); +static void *_tmp_95_rule(Parser *p); +static void *_tmp_96_rule(Parser *p); static asdl_seq *_loop0_97_rule(Parser *p); -static asdl_seq *_loop1_98_rule(Parser *p); +static asdl_seq *_loop0_98_rule(Parser *p); static asdl_seq *_loop0_99_rule(Parser *p); static asdl_seq *_loop1_100_rule(Parser *p); -static asdl_seq *_loop1_101_rule(Parser *p); +static asdl_seq *_loop0_101_rule(Parser *p); static asdl_seq *_loop1_102_rule(Parser *p); -static asdl_seq *_loop0_103_rule(Parser *p); +static asdl_seq *_loop1_103_rule(Parser *p); static asdl_seq *_loop1_104_rule(Parser *p); static asdl_seq *_loop0_105_rule(Parser *p); static asdl_seq *_loop1_106_rule(Parser *p); static asdl_seq *_loop0_107_rule(Parser *p); static asdl_seq *_loop1_108_rule(Parser *p); -static asdl_seq *_loop1_109_rule(Parser *p); -static void *_tmp_110_rule(Parser *p); -static asdl_seq *_loop0_112_rule(Parser *p); -static asdl_seq *_gather_111_rule(Parser *p); -static asdl_seq *_loop1_113_rule(Parser *p); +static asdl_seq *_loop0_109_rule(Parser *p); +static asdl_seq *_loop1_110_rule(Parser *p); +static asdl_seq *_loop1_111_rule(Parser *p); +static void *_tmp_112_rule(Parser *p); static asdl_seq *_loop0_114_rule(Parser *p); -static asdl_seq *_loop0_115_rule(Parser *p); -static void *_tmp_116_rule(Parser *p); -static asdl_seq *_loop0_118_rule(Parser *p); -static asdl_seq *_gather_117_rule(Parser *p); -static void *_tmp_119_rule(Parser *p); -static asdl_seq *_loop0_121_rule(Parser *p); -static asdl_seq *_gather_120_rule(Parser *p); +static asdl_seq *_gather_113_rule(Parser *p); +static asdl_seq *_loop1_115_rule(Parser *p); +static asdl_seq *_loop0_116_rule(Parser *p); +static asdl_seq *_loop0_117_rule(Parser *p); +static void *_tmp_118_rule(Parser *p); +static asdl_seq *_loop0_120_rule(Parser *p); +static asdl_seq *_gather_119_rule(Parser *p); +static void *_tmp_121_rule(Parser *p); static asdl_seq *_loop0_123_rule(Parser *p); static asdl_seq *_gather_122_rule(Parser *p); static asdl_seq *_loop0_125_rule(Parser *p); static asdl_seq *_gather_124_rule(Parser *p); static asdl_seq *_loop0_127_rule(Parser *p); static asdl_seq *_gather_126_rule(Parser *p); -static asdl_seq *_loop0_128_rule(Parser *p); +static asdl_seq *_loop0_129_rule(Parser *p); +static asdl_seq *_gather_128_rule(Parser *p); static asdl_seq *_loop0_130_rule(Parser *p); -static asdl_seq *_gather_129_rule(Parser *p); -static asdl_seq *_loop1_131_rule(Parser *p); -static void *_tmp_132_rule(Parser *p); -static asdl_seq *_loop0_134_rule(Parser *p); -static asdl_seq *_gather_133_rule(Parser *p); +static asdl_seq *_loop0_132_rule(Parser *p); +static asdl_seq *_gather_131_rule(Parser *p); +static asdl_seq *_loop1_133_rule(Parser *p); +static void *_tmp_134_rule(Parser *p); static asdl_seq *_loop0_136_rule(Parser *p); static asdl_seq *_gather_135_rule(Parser *p); static asdl_seq *_loop0_138_rule(Parser *p); @@ -933,8 +946,8 @@ static asdl_seq *_loop0_140_rule(Parser *p); static asdl_seq *_gather_139_rule(Parser *p); static asdl_seq *_loop0_142_rule(Parser *p); static asdl_seq *_gather_141_rule(Parser *p); -static void *_tmp_143_rule(Parser *p); -static void *_tmp_144_rule(Parser *p); +static asdl_seq *_loop0_144_rule(Parser *p); +static asdl_seq *_gather_143_rule(Parser *p); static void *_tmp_145_rule(Parser *p); static void *_tmp_146_rule(Parser *p); static void *_tmp_147_rule(Parser *p); @@ -944,64 +957,64 @@ static void *_tmp_150_rule(Parser *p); static void *_tmp_151_rule(Parser *p); static void *_tmp_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); -static asdl_seq *_loop0_154_rule(Parser *p); -static asdl_seq *_loop0_155_rule(Parser *p); +static void *_tmp_154_rule(Parser *p); +static void *_tmp_155_rule(Parser *p); static asdl_seq *_loop0_156_rule(Parser *p); -static void *_tmp_157_rule(Parser *p); -static void *_tmp_158_rule(Parser *p); +static asdl_seq *_loop0_157_rule(Parser *p); +static asdl_seq *_loop0_158_rule(Parser *p); static void *_tmp_159_rule(Parser *p); static void *_tmp_160_rule(Parser *p); static void *_tmp_161_rule(Parser *p); -static asdl_seq *_loop0_162_rule(Parser *p); -static asdl_seq *_loop0_163_rule(Parser *p); +static void *_tmp_162_rule(Parser *p); +static void *_tmp_163_rule(Parser *p); static asdl_seq *_loop0_164_rule(Parser *p); -static asdl_seq *_loop1_165_rule(Parser *p); -static void *_tmp_166_rule(Parser *p); -static asdl_seq *_loop0_167_rule(Parser *p); +static asdl_seq *_loop0_165_rule(Parser *p); +static asdl_seq *_loop0_166_rule(Parser *p); +static asdl_seq *_loop1_167_rule(Parser *p); static void *_tmp_168_rule(Parser *p); static asdl_seq *_loop0_169_rule(Parser *p); -static asdl_seq *_loop1_170_rule(Parser *p); -static void *_tmp_171_rule(Parser *p); -static void *_tmp_172_rule(Parser *p); +static void *_tmp_170_rule(Parser *p); +static asdl_seq *_loop0_171_rule(Parser *p); +static asdl_seq *_loop1_172_rule(Parser *p); static void *_tmp_173_rule(Parser *p); -static asdl_seq *_loop0_174_rule(Parser *p); +static void *_tmp_174_rule(Parser *p); static void *_tmp_175_rule(Parser *p); -static void *_tmp_176_rule(Parser *p); -static asdl_seq *_loop1_177_rule(Parser *p); +static asdl_seq *_loop0_176_rule(Parser *p); +static void *_tmp_177_rule(Parser *p); static void *_tmp_178_rule(Parser *p); -static asdl_seq *_loop0_179_rule(Parser *p); -static asdl_seq *_loop0_180_rule(Parser *p); +static asdl_seq *_loop1_179_rule(Parser *p); +static void *_tmp_180_rule(Parser *p); static asdl_seq *_loop0_181_rule(Parser *p); +static asdl_seq *_loop0_182_rule(Parser *p); static asdl_seq *_loop0_183_rule(Parser *p); -static asdl_seq *_gather_182_rule(Parser *p); -static void *_tmp_184_rule(Parser *p); static asdl_seq *_loop0_185_rule(Parser *p); +static asdl_seq *_gather_184_rule(Parser *p); static void *_tmp_186_rule(Parser *p); static asdl_seq *_loop0_187_rule(Parser *p); -static asdl_seq *_loop1_188_rule(Parser *p); -static asdl_seq *_loop1_189_rule(Parser *p); -static void *_tmp_190_rule(Parser *p); -static void *_tmp_191_rule(Parser *p); -static asdl_seq *_loop0_192_rule(Parser *p); +static void *_tmp_188_rule(Parser *p); +static asdl_seq *_loop0_189_rule(Parser *p); +static asdl_seq *_loop1_190_rule(Parser *p); +static asdl_seq *_loop1_191_rule(Parser *p); +static void *_tmp_192_rule(Parser *p); static void *_tmp_193_rule(Parser *p); -static void *_tmp_194_rule(Parser *p); +static asdl_seq *_loop0_194_rule(Parser *p); static void *_tmp_195_rule(Parser *p); -static asdl_seq *_loop0_197_rule(Parser *p); -static asdl_seq *_gather_196_rule(Parser *p); +static void *_tmp_196_rule(Parser *p); +static void *_tmp_197_rule(Parser *p); static asdl_seq *_loop0_199_rule(Parser *p); static asdl_seq *_gather_198_rule(Parser *p); static asdl_seq *_loop0_201_rule(Parser *p); static asdl_seq *_gather_200_rule(Parser *p); static asdl_seq *_loop0_203_rule(Parser *p); static asdl_seq *_gather_202_rule(Parser *p); -static void *_tmp_204_rule(Parser *p); static asdl_seq *_loop0_205_rule(Parser *p); -static asdl_seq *_loop1_206_rule(Parser *p); -static void *_tmp_207_rule(Parser *p); -static asdl_seq *_loop0_208_rule(Parser *p); -static asdl_seq *_loop1_209_rule(Parser *p); -static void *_tmp_210_rule(Parser *p); -static void *_tmp_211_rule(Parser *p); +static asdl_seq *_gather_204_rule(Parser *p); +static void *_tmp_206_rule(Parser *p); +static asdl_seq *_loop0_207_rule(Parser *p); +static asdl_seq *_loop1_208_rule(Parser *p); +static void *_tmp_209_rule(Parser *p); +static asdl_seq *_loop0_210_rule(Parser *p); +static asdl_seq *_loop1_211_rule(Parser *p); static void *_tmp_212_rule(Parser *p); static void *_tmp_213_rule(Parser *p); static void *_tmp_214_rule(Parser *p); @@ -1010,10 +1023,10 @@ static void *_tmp_216_rule(Parser *p); static void *_tmp_217_rule(Parser *p); static void *_tmp_218_rule(Parser *p); static void *_tmp_219_rule(Parser *p); -static asdl_seq *_loop0_221_rule(Parser *p); -static asdl_seq *_gather_220_rule(Parser *p); -static void *_tmp_222_rule(Parser *p); -static void *_tmp_223_rule(Parser *p); +static void *_tmp_220_rule(Parser *p); +static void *_tmp_221_rule(Parser *p); +static asdl_seq *_loop0_223_rule(Parser *p); +static asdl_seq *_gather_222_rule(Parser *p); static void *_tmp_224_rule(Parser *p); static void *_tmp_225_rule(Parser *p); static void *_tmp_226_rule(Parser *p); @@ -1042,6 +1055,8 @@ static void *_tmp_248_rule(Parser *p); static void *_tmp_249_rule(Parser *p); static void *_tmp_250_rule(Parser *p); static void *_tmp_251_rule(Parser *p); +static void *_tmp_252_rule(Parser *p); +static void *_tmp_253_rule(Parser *p); // file: statements? $ @@ -1612,6 +1627,7 @@ simple_stmts_rule(Parser *p) // simple_stmt: // | assignment +// | type_alias // | star_expressions // | &'return' return_stmt // | &('import' | 'from') import_stmt @@ -1669,6 +1685,25 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment")); } + { // type_alias + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_alias")); + stmt_ty type_alias_var; + if ( + (type_alias_var = type_alias_rule(p)) // type_alias + ) + { + D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_alias")); + _res = type_alias_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_alias")); + } { // star_expressions if (p->error_indicator) { p->level--; @@ -4239,7 +4274,9 @@ class_def_rule(Parser *p) return _res; } -// class_def_raw: invalid_class_def_raw | 'class' NAME ['(' arguments? ')'] ':' block +// class_def_raw: +// | invalid_class_def_raw +// | 'class' NAME type_params? ['(' arguments? ')'] ':' block static stmt_ty class_def_raw_rule(Parser *p) { @@ -4281,22 +4318,25 @@ class_def_raw_rule(Parser *p) D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_class_def_raw")); } - { // 'class' NAME ['(' arguments? ')'] ':' block + { // 'class' NAME type_params? ['(' arguments? ')'] ':' block if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' block")); Token * _keyword; Token * _literal; expr_ty a; void *b; asdl_stmt_seq* c; + void *t; if ( (_keyword = _PyPegen_expect_token(p, 653)) // token='class' && (a = _PyPegen_name_token(p)) // NAME && + (t = type_params_rule(p), !p->error_indicator) // type_params? + && (b = _tmp_33_rule(p), !p->error_indicator) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' @@ -4304,7 +4344,7 @@ class_def_raw_rule(Parser *p) (c = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' block")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -4314,7 +4354,7 @@ class_def_raw_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 = _PyAST_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA ); + _res = _PyAST_ClassDef ( a -> v . Name . id , t , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -4324,7 +4364,7 @@ class_def_raw_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME type_params? ['(' arguments? ')'] ':' block")); } _res = NULL; done: @@ -4400,8 +4440,8 @@ function_def_rule(Parser *p) // function_def_raw: // | invalid_def_raw -// | 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block -// | ASYNC 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block +// | 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block +// | ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block static stmt_ty function_def_raw_rule(Parser *p) { @@ -4443,12 +4483,12 @@ function_def_raw_rule(Parser *p) D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_def_raw")); } - { // 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block + { // 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); Token * _keyword; Token * _literal; Token * _literal_1; @@ -4457,12 +4497,15 @@ function_def_raw_rule(Parser *p) asdl_stmt_seq* b; expr_ty n; void *params; + void *t; void *tc; if ( (_keyword = _PyPegen_expect_token(p, 651)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && + (t = type_params_rule(p), !p->error_indicator) // type_params? + && (_literal = _PyPegen_expect_forced_token(p, 7, "(")) // forced_token='(' && (params = params_rule(p), !p->error_indicator) // params? @@ -4478,7 +4521,7 @@ function_def_raw_rule(Parser *p) (b = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -4488,7 +4531,7 @@ function_def_raw_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 = _PyAST_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); + _res = _PyAST_FunctionDef ( n -> v . Name . id , t , ( params ) ? params : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -4498,14 +4541,14 @@ function_def_raw_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); } - { // ASYNC 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block + { // ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); Token * _keyword; Token * _literal; Token * _literal_1; @@ -4515,6 +4558,7 @@ function_def_raw_rule(Parser *p) asdl_stmt_seq* b; expr_ty n; void *params; + void *t; void *tc; if ( (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' @@ -4523,6 +4567,8 @@ function_def_raw_rule(Parser *p) && (n = _PyPegen_name_token(p)) // NAME && + (t = type_params_rule(p), !p->error_indicator) // type_params? + && (_literal = _PyPegen_expect_forced_token(p, 7, "(")) // forced_token='(' && (params = params_rule(p), !p->error_indicator) // params? @@ -4538,7 +4584,7 @@ function_def_raw_rule(Parser *p) (b = block_rule(p)) // block ) { - D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); if (_token == NULL) { p->level--; @@ -4548,7 +4594,7 @@ function_def_raw_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 = CHECK_VERSION ( stmt_ty , 5 , "Async functions are" , _PyAST_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); + _res = CHECK_VERSION ( stmt_ty , 5 , "Async functions are" , _PyAST_AsyncFunctionDef ( n -> v . Name . id , t , ( params ) ? params : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -4558,7 +4604,7 @@ function_def_raw_rule(Parser *p) } p->mark = _mark; D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME type_params? &&'(' params? ')' ['->' expression] &&':' func_type_comment? block")); } _res = NULL; done: @@ -10461,6 +10507,367 @@ keyword_pattern_rule(Parser *p) return _res; } +// type_alias: "type" NAME type_params? '=' expression +static stmt_ty +type_alias_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + stmt_ty _res = NULL; + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + p->level--; + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + 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 + { // "type" NAME type_params? '=' expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_alias[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"type\" NAME type_params? '=' expression")); + expr_ty _keyword; + Token * _literal; + expr_ty b; + expr_ty n; + void *t; + if ( + (_keyword = _PyPegen_expect_soft_keyword(p, "type")) // soft_keyword='"type"' + && + (n = _PyPegen_name_token(p)) // NAME + && + (t = type_params_rule(p), !p->error_indicator) // type_params? + && + (_literal = _PyPegen_expect_token(p, 22)) // token='=' + && + (b = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ type_alias[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"type\" NAME type_params? '=' expression")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + 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 = CHECK_VERSION ( stmt_ty , 12 , "Type statement is" , _PyAST_TypeAlias ( n -> v . Name . id , t , b , EXTRA ) ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_alias[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"type\" NAME type_params? '=' expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// type_params: '[' type_param_seq ']' +static asdl_typeparam_seq* +type_params_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_typeparam_seq* _res = NULL; + int _mark = p->mark; + { // '[' type_param_seq ']' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' type_param_seq ']'")); + Token * _literal; + Token * _literal_1; + asdl_typeparam_seq* t; + if ( + (_literal = _PyPegen_expect_token(p, 9)) // token='[' + && + (t = type_param_seq_rule(p)) // type_param_seq + && + (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' + ) + { + D(fprintf(stderr, "%*c+ type_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' type_param_seq ']'")); + _res = t; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_params[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' type_param_seq ']'")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// type_param_seq: ','.type_param+ ','? +static asdl_typeparam_seq* +type_param_seq_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_typeparam_seq* _res = NULL; + int _mark = p->mark; + { // ','.type_param+ ','? + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.type_param+ ','?")); + void *_opt_var; + UNUSED(_opt_var); // Silence compiler warnings + asdl_typeparam_seq* a; + if ( + (a = (asdl_typeparam_seq*)_gather_80_rule(p)) // ','.type_param+ + && + (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? + ) + { + D(fprintf(stderr, "%*c+ type_param_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.type_param+ ','?")); + _res = a; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param_seq[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.type_param+ ','?")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// type_param: NAME type_param_bound? | '*' NAME | '**' NAME +static typeparam_ty +type_param_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + typeparam_ty _res = NULL; + if (_PyPegen_is_memoized(p, type_param_type, &_res)) { + p->level--; + return _res; + } + int _mark = p->mark; + if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { + p->error_indicator = 1; + p->level--; + return NULL; + } + int _start_lineno = p->tokens[_mark]->lineno; + 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 + { // NAME type_param_bound? + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME type_param_bound?")); + expr_ty a; + void *b; + if ( + (a = _PyPegen_name_token(p)) // NAME + && + (b = type_param_bound_rule(p), !p->error_indicator) // type_param_bound? + ) + { + D(fprintf(stderr, "%*c+ type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME type_param_bound?")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + 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 = _PyAST_TypeVar ( a -> v . Name . id , b , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME type_param_bound?")); + } + { // '*' NAME + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' NAME")); + Token * _literal; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (a = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' NAME")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + 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 = _PyAST_TypeVarTuple ( a -> v . Name . id , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME")); + } + { // '**' NAME + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' NAME")); + Token * _literal; + expr_ty a; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (a = _PyPegen_name_token(p)) // NAME + ) + { + D(fprintf(stderr, "%*c+ type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' NAME")); + Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); + if (_token == NULL) { + p->level--; + return NULL; + } + int _end_lineno = _token->end_lineno; + 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 = _PyAST_ParamSpec ( a -> v . Name . id , EXTRA ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' NAME")); + } + _res = NULL; + done: + _PyPegen_insert_memo(p, _mark, type_param_type, _res); + p->level--; + return _res; +} + +// type_param_bound: ":" expression +static expr_ty +type_param_bound_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + expr_ty _res = NULL; + int _mark = p->mark; + { // ":" expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param_bound[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\":\" expression")); + Token * _literal; + expr_ty e; + if ( + (_literal = _PyPegen_expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ type_param_bound[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\":\" expression")); + _res = e; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param_bound[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\":\" expression")); + } + _res = NULL; + done: + p->level--; + return _res; +} + // expressions: expression ((',' expression))+ ','? | expression ',' | expression static expr_ty expressions_rule(Parser *p) @@ -10497,7 +10904,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && - (b = _loop1_80_rule(p)) // ((',' expression))+ + (b = _loop1_82_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -10888,7 +11295,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && - (b = _loop1_81_rule(p)) // ((',' star_expression))+ + (b = _loop1_83_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -11089,7 +11496,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_82_rule(p)) // ','.star_named_expression+ + (a = (asdl_expr_seq*)_gather_84_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -11389,7 +11796,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && - (b = _loop1_84_rule(p)) // (('or' conjunction))+ + (b = _loop1_86_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -11478,7 +11885,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && - (b = _loop1_85_rule(p)) // (('and' inversion))+ + (b = _loop1_87_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -11652,7 +12059,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && - (b = _loop1_86_rule(p)) // compare_op_bitwise_or_pair+ + (b = _loop1_88_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -11989,10 +12396,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); - void *_tmp_87_var; + void *_tmp_89_var; expr_ty a; if ( - (_tmp_87_var = _tmp_87_rule(p)) // '!=' + (_tmp_89_var = _tmp_89_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -14027,7 +14434,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_88_rule(p)) // ','.(slice | starred_expression)+ + (a = (asdl_expr_seq*)_gather_90_rule(p)) // ','.(slice | starred_expression)+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -14100,7 +14507,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), !p->error_indicator) // expression? && - (c = _tmp_90_rule(p), !p->error_indicator) // [':' expression?] + (c = _tmp_92_rule(p), !p->error_indicator) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -14352,15 +14759,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_91_var; + void *_tmp_93_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_91_var = _tmp_91_rule(p)) // tuple | group | genexp + (_tmp_93_var = _tmp_93_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_91_var; + _res = _tmp_93_var; goto done; } p->mark = _mark; @@ -14373,15 +14780,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_92_var; + void *_tmp_94_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_92_var = _tmp_92_rule(p)) // list | listcomp + (_tmp_94_var = _tmp_94_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_92_var; + _res = _tmp_94_var; goto done; } p->mark = _mark; @@ -14394,15 +14801,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_93_var; + void *_tmp_95_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_93_var = _tmp_93_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_95_var = _tmp_95_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_93_var; + _res = _tmp_95_var; goto done; } p->mark = _mark; @@ -14474,7 +14881,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_94_rule(p)) // yield_expr | named_expression + (a = _tmp_96_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -14678,9 +15085,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = (asdl_arg_seq*)_loop0_95_rule(p)) // lambda_param_no_default* + (b = (asdl_arg_seq*)_loop0_97_rule(p)) // lambda_param_no_default* && - (c = _loop0_96_rule(p)) // lambda_param_with_default* + (c = _loop0_98_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -14710,7 +15117,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_97_rule(p)) // lambda_param_with_default* + (b = _loop0_99_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -14738,9 +15145,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_98_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_100_rule(p)) // lambda_param_no_default+ && - (b = _loop0_99_rule(p)) // lambda_param_with_default* + (b = _loop0_101_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -14767,7 +15174,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_100_rule(p)) // lambda_param_with_default+ + (a = _loop1_102_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -14841,7 +15248,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_101_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_103_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -14870,7 +15277,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_102_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_104_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -14923,9 +15330,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_103_rule(p)) // lambda_param_no_default* + (a = _loop0_105_rule(p)) // lambda_param_no_default* && - (b = _loop1_104_rule(p)) // lambda_param_with_default+ + (b = _loop1_106_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -14955,9 +15362,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_105_rule(p)) // lambda_param_no_default* + (a = _loop0_107_rule(p)) // lambda_param_no_default* && - (b = _loop1_106_rule(p)) // lambda_param_with_default+ + (b = _loop1_108_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -15035,7 +15442,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_107_rule(p)) // lambda_param_maybe_default* + (b = _loop0_109_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), !p->error_indicator) // lambda_kwds? ) @@ -15068,7 +15475,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_108_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_110_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), !p->error_indicator) // lambda_kwds? ) @@ -15501,7 +15908,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); asdl_seq * a; if ( - (a = _loop1_109_rule(p)) // STRING+ + (a = _loop1_111_rule(p)) // STRING+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); @@ -15627,7 +16034,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_110_rule(p), !p->error_indicator) // [star_named_expression ',' star_named_expressions?] + (a = _tmp_112_rule(p), !p->error_indicator) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -15845,7 +16252,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( - (a = _gather_111_rule(p)) // ','.double_starred_kvpair+ + (a = _gather_113_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -16007,7 +16414,7 @@ for_if_clauses_rule(Parser *p) D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); asdl_comprehension_seq* a; if ( - (a = (asdl_comprehension_seq*)_loop1_113_rule(p)) // for_if_clause+ + (a = (asdl_comprehension_seq*)_loop1_115_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); @@ -16072,7 +16479,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = (asdl_expr_seq*)_loop0_114_rule(p)) // (('if' disjunction))* + (c = (asdl_expr_seq*)_loop0_116_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -16115,7 +16522,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - (c = (asdl_expr_seq*)_loop0_115_rule(p)) // (('if' disjunction))* + (c = (asdl_expr_seq*)_loop0_117_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -16378,7 +16785,7 @@ genexp_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_116_rule(p)) // assignment_expression | expression !':=' + (a = _tmp_118_rule(p)) // assignment_expression | expression !':=' && (b = for_if_clauses_rule(p)) // for_if_clauses && @@ -16630,9 +17037,9 @@ args_rule(Parser *p) asdl_expr_seq* a; void *b; if ( - (a = (asdl_expr_seq*)_gather_117_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ + (a = (asdl_expr_seq*)_gather_119_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ && - (b = _tmp_119_rule(p), !p->error_indicator) // [',' kwargs] + (b = _tmp_121_rule(p), !p->error_indicator) // [',' kwargs] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ [',' kwargs]")); @@ -16723,11 +17130,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _gather_120_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_122_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_122_rule(p)) // ','.kwarg_or_double_starred+ + (b = _gather_124_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -16749,13 +17156,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - asdl_seq * _gather_124_var; + asdl_seq * _gather_126_var; if ( - (_gather_124_var = _gather_124_rule(p)) // ','.kwarg_or_starred+ + (_gather_126_var = _gather_126_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_124_var; + _res = _gather_126_var; goto done; } p->mark = _mark; @@ -16768,13 +17175,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - asdl_seq * _gather_126_var; + asdl_seq * _gather_128_var; if ( - (_gather_126_var = _gather_126_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_128_var = _gather_128_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_126_var; + _res = _gather_128_var; goto done; } p->mark = _mark; @@ -17167,7 +17574,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop0_128_rule(p)) // ((',' star_target))* + (b = _loop0_130_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -17224,7 +17631,7 @@ star_targets_list_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_129_rule(p)) // ','.star_target+ + (a = (asdl_expr_seq*)_gather_131_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -17275,7 +17682,7 @@ star_targets_tuple_seq_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && - (b = _loop1_131_rule(p)) // ((',' star_target))+ + (b = _loop1_133_rule(p)) // ((',' star_target))+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -17364,7 +17771,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (a = _tmp_132_rule(p)) // !'*' star_target + (a = _tmp_134_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -18295,7 +18702,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_133_rule(p)) // ','.del_target+ + (a = (asdl_expr_seq*)_gather_135_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -18656,7 +19063,7 @@ type_expressions_rule(Parser *p) expr_ty b; expr_ty c; if ( - (a = _gather_135_rule(p)) // ','.expression+ + (a = _gather_137_rule(p)) // ','.expression+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -18695,7 +19102,7 @@ type_expressions_rule(Parser *p) asdl_seq * a; expr_ty b; if ( - (a = _gather_137_rule(p)) // ','.expression+ + (a = _gather_139_rule(p)) // ','.expression+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -18728,7 +19135,7 @@ type_expressions_rule(Parser *p) asdl_seq * a; expr_ty b; if ( - (a = _gather_139_rule(p)) // ','.expression+ + (a = _gather_141_rule(p)) // ','.expression+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -18848,7 +19255,7 @@ type_expressions_rule(Parser *p) D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+")); asdl_expr_seq* a; if ( - (a = (asdl_expr_seq*)_gather_141_rule(p)) // ','.expression+ + (a = (asdl_expr_seq*)_gather_143_rule(p)) // ','.expression+ ) { D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+")); @@ -18900,7 +19307,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && - _PyPegen_lookahead(1, _tmp_143_rule, p) + _PyPegen_lookahead(1, _tmp_145_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -19029,7 +19436,7 @@ invalid_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_opt_var = _tmp_144_rule(p), !p->error_indicator) // [args | expression for_if_clauses] + (_opt_var = _tmp_146_rule(p), !p->error_indicator) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -19089,13 +19496,13 @@ invalid_arguments_rule(Parser *p) expr_ty a; Token * b; if ( - (_opt_var = _tmp_145_rule(p), !p->error_indicator) // [(args ',')] + (_opt_var = _tmp_147_rule(p), !p->error_indicator) // [(args ',')] && (a = _PyPegen_name_token(p)) // NAME && (b = _PyPegen_expect_token(p, 22)) // token='=' && - _PyPegen_lookahead(1, _tmp_146_rule, p) + _PyPegen_lookahead(1, _tmp_148_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); @@ -19234,7 +19641,7 @@ invalid_kwarg_rule(Parser *p) Token* a; Token * b; if ( - (a = (Token*)_tmp_147_rule(p)) // 'True' | 'False' | 'None' + (a = (Token*)_tmp_149_rule(p)) // 'True' | 'False' | 'None' && (b = _PyPegen_expect_token(p, 22)) // token='=' ) @@ -19294,7 +19701,7 @@ invalid_kwarg_rule(Parser *p) expr_ty a; Token * b; if ( - _PyPegen_lookahead(0, _tmp_148_rule, p) + _PyPegen_lookahead(0, _tmp_150_rule, p) && (a = expression_rule(p)) // expression && @@ -19552,7 +19959,7 @@ invalid_expression_rule(Parser *p) expr_ty a; expr_ty b; if ( - _PyPegen_lookahead(0, _tmp_149_rule, p) + _PyPegen_lookahead(0, _tmp_151_rule, p) && (a = disjunction_rule(p)) // disjunction && @@ -19588,7 +19995,7 @@ invalid_expression_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && - _PyPegen_lookahead(0, _tmp_150_rule, p) + _PyPegen_lookahead(0, _tmp_152_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); @@ -19677,7 +20084,7 @@ invalid_named_expression_rule(Parser *p) && (b = bitwise_or_rule(p)) // bitwise_or && - _PyPegen_lookahead(0, _tmp_151_rule, p) + _PyPegen_lookahead(0, _tmp_153_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); @@ -19703,7 +20110,7 @@ invalid_named_expression_rule(Parser *p) Token * b; expr_ty bitwise_or_var; if ( - _PyPegen_lookahead(0, _tmp_152_rule, p) + _PyPegen_lookahead(0, _tmp_154_rule, p) && (a = bitwise_or_rule(p)) // bitwise_or && @@ -19711,7 +20118,7 @@ invalid_named_expression_rule(Parser *p) && (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or && - _PyPegen_lookahead(0, _tmp_153_rule, p) + _PyPegen_lookahead(0, _tmp_155_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); @@ -19792,7 +20199,7 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_154_var; + asdl_seq * _loop0_156_var; expr_ty a; expr_ty expression_var; if ( @@ -19800,7 +20207,7 @@ invalid_assignment_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_loop0_154_var = _loop0_154_rule(p)) // star_named_expressions* + (_loop0_156_var = _loop0_156_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -19857,10 +20264,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); Token * _literal; - asdl_seq * _loop0_155_var; + asdl_seq * _loop0_157_var; expr_ty a; if ( - (_loop0_155_var = _loop0_155_rule(p)) // ((star_targets '='))* + (_loop0_157_var = _loop0_157_rule(p)) // ((star_targets '='))* && (a = star_expressions_rule(p)) // star_expressions && @@ -19887,10 +20294,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); Token * _literal; - asdl_seq * _loop0_156_var; + asdl_seq * _loop0_158_var; expr_ty a; if ( - (_loop0_156_var = _loop0_156_rule(p)) // ((star_targets '='))* + (_loop0_158_var = _loop0_158_rule(p)) // ((star_targets '='))* && (a = yield_expr_rule(p)) // yield_expr && @@ -19916,7 +20323,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); - void *_tmp_157_var; + void *_tmp_159_var; expr_ty a; AugOperator* augassign_var; if ( @@ -19924,7 +20331,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && - (_tmp_157_var = _tmp_157_rule(p)) // yield_expr | star_expressions + (_tmp_159_var = _tmp_159_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -20150,11 +20557,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); - void *_tmp_158_var; + void *_tmp_160_var; expr_ty a; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_158_var = _tmp_158_rule(p)) // '[' | '(' | '{' + (_tmp_160_var = _tmp_160_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -20181,12 +20588,12 @@ invalid_comprehension_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); Token * _literal; - void *_tmp_159_var; + void *_tmp_161_var; expr_ty a; asdl_expr_seq* b; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_159_var = _tmp_159_rule(p)) // '[' | '{' + (_tmp_161_var = _tmp_161_rule(p)) // '[' | '{' && (a = star_named_expression_rule(p)) // star_named_expression && @@ -20216,12 +20623,12 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); - void *_tmp_160_var; + void *_tmp_162_var; expr_ty a; Token * b; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_160_var = _tmp_160_rule(p)) // '[' | '{' + (_tmp_162_var = _tmp_162_rule(p)) // '[' | '{' && (a = star_named_expression_rule(p)) // star_named_expression && @@ -20358,13 +20765,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); - asdl_seq * _loop0_162_var; - void *_tmp_161_var; + asdl_seq * _loop0_164_var; + void *_tmp_163_var; Token * a; if ( - (_tmp_161_var = _tmp_161_rule(p)) // slash_no_default | slash_with_default + (_tmp_163_var = _tmp_163_rule(p)) // slash_no_default | slash_with_default && - (_loop0_162_var = _loop0_162_rule(p)) // param_maybe_default* + (_loop0_164_var = _loop0_164_rule(p)) // param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -20388,7 +20795,7 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); - asdl_seq * _loop0_163_var; + asdl_seq * _loop0_165_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings arg_ty a; @@ -20396,7 +20803,7 @@ invalid_parameters_rule(Parser *p) if ( (_opt_var = slash_no_default_rule(p), !p->error_indicator) // slash_no_default? && - (_loop0_163_var = _loop0_163_rule(p)) // param_no_default* + (_loop0_165_var = _loop0_165_rule(p)) // param_no_default* && (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper && @@ -20422,18 +20829,18 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); - asdl_seq * _loop0_164_var; - asdl_seq * _loop1_165_var; + asdl_seq * _loop0_166_var; + asdl_seq * _loop1_167_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; Token * b; if ( - (_loop0_164_var = _loop0_164_rule(p)) // param_no_default* + (_loop0_166_var = _loop0_166_rule(p)) // param_no_default* && (a = _PyPegen_expect_token(p, 7)) // token='(' && - (_loop1_165_var = _loop1_165_rule(p)) // param_no_default+ + (_loop1_167_var = _loop1_167_rule(p)) // param_no_default+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -20460,22 +20867,22 @@ invalid_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); Token * _literal; - asdl_seq * _loop0_167_var; asdl_seq * _loop0_169_var; + asdl_seq * _loop0_171_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_168_var; + void *_tmp_170_var; Token * a; if ( - (_opt_var = _tmp_166_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] + (_opt_var = _tmp_168_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] && - (_loop0_167_var = _loop0_167_rule(p)) // param_maybe_default* + (_loop0_169_var = _loop0_169_rule(p)) // param_maybe_default* && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_168_var = _tmp_168_rule(p)) // ',' | param_no_default + (_tmp_170_var = _tmp_170_rule(p)) // ',' | param_no_default && - (_loop0_169_var = _loop0_169_rule(p)) // param_maybe_default* + (_loop0_171_var = _loop0_171_rule(p)) // param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -20500,10 +20907,10 @@ invalid_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default+ '/' '*'")); Token * _literal; - asdl_seq * _loop1_170_var; + asdl_seq * _loop1_172_var; Token * a; if ( - (_loop1_170_var = _loop1_170_rule(p)) // param_maybe_default+ + (_loop1_172_var = _loop1_172_rule(p)) // param_maybe_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -20553,7 +20960,7 @@ invalid_default_rule(Parser *p) if ( (a = _PyPegen_expect_token(p, 22)) // token='=' && - _PyPegen_lookahead(1, _tmp_171_rule, p) + _PyPegen_lookahead(1, _tmp_173_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' &(')' | ',')")); @@ -20599,12 +21006,12 @@ invalid_star_etc_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); - void *_tmp_172_var; + void *_tmp_174_var; Token * a; if ( (a = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_172_var = _tmp_172_rule(p)) // ')' | ',' (')' | '**') + (_tmp_174_var = _tmp_174_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -20687,20 +21094,20 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); Token * _literal; - asdl_seq * _loop0_174_var; - void *_tmp_173_var; + asdl_seq * _loop0_176_var; void *_tmp_175_var; + void *_tmp_177_var; Token * a; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_173_var = _tmp_173_rule(p)) // param_no_default | ',' + (_tmp_175_var = _tmp_175_rule(p)) // param_no_default | ',' && - (_loop0_174_var = _loop0_174_rule(p)) // param_maybe_default* + (_loop0_176_var = _loop0_176_rule(p)) // param_maybe_default* && (a = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_175_var = _tmp_175_rule(p)) // param_no_default | ',' + (_tmp_177_var = _tmp_177_rule(p)) // param_no_default | ',' ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); @@ -20816,7 +21223,7 @@ invalid_kwds_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (a = (Token*)_tmp_176_rule(p)) // '*' | '**' | '/' + (a = (Token*)_tmp_178_rule(p)) // '*' | '**' | '/' ) { D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); @@ -20882,13 +21289,13 @@ invalid_parameters_helper_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - asdl_seq * _loop1_177_var; + asdl_seq * _loop1_179_var; if ( - (_loop1_177_var = _loop1_177_rule(p)) // param_with_default+ + (_loop1_179_var = _loop1_179_rule(p)) // param_with_default+ ) { D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_177_var; + _res = _loop1_179_var; goto done; } p->mark = _mark; @@ -20954,13 +21361,13 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); - asdl_seq * _loop0_179_var; - void *_tmp_178_var; + asdl_seq * _loop0_181_var; + void *_tmp_180_var; Token * a; if ( - (_tmp_178_var = _tmp_178_rule(p)) // lambda_slash_no_default | lambda_slash_with_default + (_tmp_180_var = _tmp_180_rule(p)) // lambda_slash_no_default | lambda_slash_with_default && - (_loop0_179_var = _loop0_179_rule(p)) // lambda_param_maybe_default* + (_loop0_181_var = _loop0_181_rule(p)) // lambda_param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -20984,7 +21391,7 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); - asdl_seq * _loop0_180_var; + asdl_seq * _loop0_182_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings arg_ty a; @@ -20992,7 +21399,7 @@ invalid_lambda_parameters_rule(Parser *p) if ( (_opt_var = lambda_slash_no_default_rule(p), !p->error_indicator) // lambda_slash_no_default? && - (_loop0_180_var = _loop0_180_rule(p)) // lambda_param_no_default* + (_loop0_182_var = _loop0_182_rule(p)) // lambda_param_no_default* && (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper && @@ -21018,18 +21425,18 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); - asdl_seq * _gather_182_var; - asdl_seq * _loop0_181_var; + asdl_seq * _gather_184_var; + asdl_seq * _loop0_183_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; Token * b; if ( - (_loop0_181_var = _loop0_181_rule(p)) // lambda_param_no_default* + (_loop0_183_var = _loop0_183_rule(p)) // lambda_param_no_default* && (a = _PyPegen_expect_token(p, 7)) // token='(' && - (_gather_182_var = _gather_182_rule(p)) // ','.lambda_param+ + (_gather_184_var = _gather_184_rule(p)) // ','.lambda_param+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -21056,22 +21463,22 @@ invalid_lambda_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); Token * _literal; - asdl_seq * _loop0_185_var; asdl_seq * _loop0_187_var; + asdl_seq * _loop0_189_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_186_var; + void *_tmp_188_var; Token * a; if ( - (_opt_var = _tmp_184_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] + (_opt_var = _tmp_186_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] && - (_loop0_185_var = _loop0_185_rule(p)) // lambda_param_maybe_default* + (_loop0_187_var = _loop0_187_rule(p)) // lambda_param_maybe_default* && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_186_var = _tmp_186_rule(p)) // ',' | lambda_param_no_default + (_tmp_188_var = _tmp_188_rule(p)) // ',' | lambda_param_no_default && - (_loop0_187_var = _loop0_187_rule(p)) // lambda_param_maybe_default* + (_loop0_189_var = _loop0_189_rule(p)) // lambda_param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -21096,10 +21503,10 @@ invalid_lambda_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); Token * _literal; - asdl_seq * _loop1_188_var; + asdl_seq * _loop1_190_var; Token * a; if ( - (_loop1_188_var = _loop1_188_rule(p)) // lambda_param_maybe_default+ + (_loop1_190_var = _loop1_190_rule(p)) // lambda_param_maybe_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -21171,13 +21578,13 @@ invalid_lambda_parameters_helper_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - asdl_seq * _loop1_189_var; + asdl_seq * _loop1_191_var; if ( - (_loop1_189_var = _loop1_189_rule(p)) // lambda_param_with_default+ + (_loop1_191_var = _loop1_191_rule(p)) // lambda_param_with_default+ ) { D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_189_var; + _res = _loop1_191_var; goto done; } p->mark = _mark; @@ -21214,11 +21621,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; - void *_tmp_190_var; + void *_tmp_192_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_190_var = _tmp_190_rule(p)) // ':' | ',' (':' | '**') + (_tmp_192_var = _tmp_192_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -21271,20 +21678,20 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); Token * _literal; - asdl_seq * _loop0_192_var; - void *_tmp_191_var; + asdl_seq * _loop0_194_var; void *_tmp_193_var; + void *_tmp_195_var; Token * a; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_191_var = _tmp_191_rule(p)) // lambda_param_no_default | ',' + (_tmp_193_var = _tmp_193_rule(p)) // lambda_param_no_default | ',' && - (_loop0_192_var = _loop0_192_rule(p)) // lambda_param_maybe_default* + (_loop0_194_var = _loop0_194_rule(p)) // lambda_param_maybe_default* && (a = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_193_var = _tmp_193_rule(p)) // lambda_param_no_default | ',' + (_tmp_195_var = _tmp_195_rule(p)) // lambda_param_no_default | ',' ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); @@ -21403,7 +21810,7 @@ invalid_lambda_kwds_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (a = (Token*)_tmp_194_rule(p)) // '*' | '**' | '/' + (a = (Token*)_tmp_196_rule(p)) // '*' | '**' | '/' ) { D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); @@ -21511,7 +21918,7 @@ invalid_with_item_rule(Parser *p) && (a = expression_rule(p)) // expression && - _PyPegen_lookahead(1, _tmp_195_rule, p) + _PyPegen_lookahead(1, _tmp_197_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); @@ -21792,7 +22199,7 @@ invalid_with_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ NEWLINE")); - asdl_seq * _gather_196_var; + asdl_seq * _gather_198_var; Token * _keyword; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings @@ -21802,7 +22209,7 @@ invalid_with_stmt_rule(Parser *p) && (_keyword = _PyPegen_expect_token(p, 614)) // token='with' && - (_gather_196_var = _gather_196_rule(p)) // ','.(expression ['as' star_target])+ + (_gather_198_var = _gather_198_rule(p)) // ','.(expression ['as' star_target])+ && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -21826,7 +22233,7 @@ invalid_with_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); - asdl_seq * _gather_198_var; + asdl_seq * _gather_200_var; Token * _keyword; Token * _literal; Token * _literal_1; @@ -21842,7 +22249,7 @@ invalid_with_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_gather_198_var = _gather_198_rule(p)) // ','.(expressions ['as' star_target])+ + (_gather_200_var = _gather_200_rule(p)) // ','.(expressions ['as' star_target])+ && (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -21892,7 +22299,7 @@ invalid_with_stmt_indent_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); - asdl_seq * _gather_200_var; + asdl_seq * _gather_202_var; Token * _literal; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings @@ -21903,7 +22310,7 @@ invalid_with_stmt_indent_rule(Parser *p) && (a = _PyPegen_expect_token(p, 614)) // token='with' && - (_gather_200_var = _gather_200_rule(p)) // ','.(expression ['as' star_target])+ + (_gather_202_var = _gather_202_rule(p)) // ','.(expression ['as' star_target])+ && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -21931,7 +22338,7 @@ invalid_with_stmt_indent_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); - asdl_seq * _gather_202_var; + asdl_seq * _gather_204_var; Token * _literal; Token * _literal_1; Token * _literal_2; @@ -21948,7 +22355,7 @@ invalid_with_stmt_indent_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (_gather_202_var = _gather_202_rule(p)) // ','.(expressions ['as' star_target])+ + (_gather_204_var = _gather_204_rule(p)) // ','.(expressions ['as' star_target])+ && (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -22046,7 +22453,7 @@ invalid_try_stmt_rule(Parser *p) && (block_var = block_rule(p)) // block && - _PyPegen_lookahead(0, _tmp_204_rule, p) + _PyPegen_lookahead(0, _tmp_206_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block !('except' | 'finally')")); @@ -22071,8 +22478,8 @@ invalid_try_stmt_rule(Parser *p) Token * _keyword; Token * _literal; Token * _literal_1; - asdl_seq * _loop0_205_var; - asdl_seq * _loop1_206_var; + asdl_seq * _loop0_207_var; + asdl_seq * _loop1_208_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; @@ -22083,9 +22490,9 @@ invalid_try_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (_loop0_205_var = _loop0_205_rule(p)) // block* + (_loop0_207_var = _loop0_207_rule(p)) // block* && - (_loop1_206_var = _loop1_206_rule(p)) // except_block+ + (_loop1_208_var = _loop1_208_rule(p)) // except_block+ && (a = _PyPegen_expect_token(p, 636)) // token='except' && @@ -22093,7 +22500,7 @@ invalid_try_stmt_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_207_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var = _tmp_209_rule(p), !p->error_indicator) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -22120,8 +22527,8 @@ invalid_try_stmt_rule(Parser *p) Token * _keyword; Token * _literal; Token * _literal_1; - asdl_seq * _loop0_208_var; - asdl_seq * _loop1_209_var; + asdl_seq * _loop0_210_var; + asdl_seq * _loop1_211_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; @@ -22130,13 +22537,13 @@ invalid_try_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (_loop0_208_var = _loop0_208_rule(p)) // block* + (_loop0_210_var = _loop0_210_rule(p)) // block* && - (_loop1_209_var = _loop1_209_rule(p)) // except_star_block+ + (_loop1_211_var = _loop1_211_rule(p)) // except_star_block+ && (a = _PyPegen_expect_token(p, 636)) // token='except' && - (_opt_var = _tmp_210_rule(p), !p->error_indicator) // [expression ['as' NAME]] + (_opt_var = _tmp_212_rule(p), !p->error_indicator) // [expression ['as' NAME]] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -22204,7 +22611,7 @@ invalid_except_stmt_rule(Parser *p) && (expressions_var = expressions_rule(p)) // expressions && - (_opt_var_1 = _tmp_211_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var_1 = _tmp_213_rule(p), !p->error_indicator) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -22242,7 +22649,7 @@ invalid_except_stmt_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var_1 = _tmp_212_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var_1 = _tmp_214_rule(p), !p->error_indicator) // ['as' NAME] && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -22294,14 +22701,14 @@ invalid_except_stmt_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); Token * _literal; - void *_tmp_213_var; + void *_tmp_215_var; Token * a; if ( (a = _PyPegen_expect_token(p, 636)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_213_var = _tmp_213_rule(p)) // NEWLINE | ':' + (_tmp_215_var = _tmp_215_rule(p)) // NEWLINE | ':' ) { D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); @@ -22408,7 +22815,7 @@ invalid_except_stmt_indent_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_214_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var = _tmp_216_rule(p), !p->error_indicator) // ['as' NAME] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -22503,7 +22910,7 @@ invalid_except_star_stmt_indent_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_215_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var = _tmp_217_rule(p), !p->error_indicator) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -22872,7 +23279,7 @@ invalid_class_argument_pattern_rule(Parser *p) asdl_pattern_seq* a; asdl_seq* keyword_patterns_var; if ( - (_opt_var = _tmp_216_rule(p), !p->error_indicator) // [positional_patterns ','] + (_opt_var = _tmp_218_rule(p), !p->error_indicator) // [positional_patterns ','] && (keyword_patterns_var = keyword_patterns_rule(p)) // keyword_patterns && @@ -23366,7 +23773,7 @@ invalid_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && - (_opt_var_2 = _tmp_217_rule(p), !p->error_indicator) // ['->' expression] + (_opt_var_2 = _tmp_219_rule(p), !p->error_indicator) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -23426,7 +23833,7 @@ invalid_class_def_raw_rule(Parser *p) && (name_var = _PyPegen_name_token(p)) // NAME && - (_opt_var = _tmp_218_rule(p), !p->error_indicator) // ['(' arguments? ')'] + (_opt_var = _tmp_220_rule(p), !p->error_indicator) // ['(' arguments? ')'] && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -23461,7 +23868,7 @@ invalid_class_def_raw_rule(Parser *p) && (name_var = _PyPegen_name_token(p)) // NAME && - (_opt_var = _tmp_219_rule(p), !p->error_indicator) // ['(' arguments? ')'] + (_opt_var = _tmp_221_rule(p), !p->error_indicator) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -23512,11 +23919,11 @@ invalid_double_starred_kvpairs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); - asdl_seq * _gather_220_var; + asdl_seq * _gather_222_var; Token * _literal; void *invalid_kvpair_var; if ( - (_gather_220_var = _gather_220_rule(p)) // ','.double_starred_kvpair+ + (_gather_222_var = _gather_222_rule(p)) // ','.double_starred_kvpair+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -23524,7 +23931,7 @@ invalid_double_starred_kvpairs_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); - _res = _PyPegen_dummy_name(p, _gather_220_var, _literal, invalid_kvpair_var); + _res = _PyPegen_dummy_name(p, _gather_222_var, _literal, invalid_kvpair_var); goto done; } p->mark = _mark; @@ -23577,7 +23984,7 @@ invalid_double_starred_kvpairs_rule(Parser *p) && (a = _PyPegen_expect_token(p, 11)) // token=':' && - _PyPegen_lookahead(1, _tmp_222_rule, p) + _PyPegen_lookahead(1, _tmp_224_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); @@ -23688,7 +24095,7 @@ invalid_kvpair_rule(Parser *p) && (a = _PyPegen_expect_token(p, 11)) // token=':' && - _PyPegen_lookahead(1, _tmp_223_rule, p) + _PyPegen_lookahead(1, _tmp_225_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); @@ -24592,12 +24999,12 @@ _loop1_14_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_224_var; + void *_tmp_226_var; while ( - (_tmp_224_var = _tmp_224_rule(p)) // star_targets '=' + (_tmp_226_var = _tmp_226_rule(p)) // star_targets '=' ) { - _res = _tmp_224_var; + _res = _tmp_226_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25171,12 +25578,12 @@ _loop0_24_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop0_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_225_var; + void *_tmp_227_var; while ( - (_tmp_225_var = _tmp_225_rule(p)) // '.' | '...' + (_tmp_227_var = _tmp_227_rule(p)) // '.' | '...' ) { - _res = _tmp_225_var; + _res = _tmp_227_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25239,12 +25646,12 @@ _loop1_25_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_226_var; + void *_tmp_228_var; while ( - (_tmp_226_var = _tmp_226_rule(p)) // '.' | '...' + (_tmp_228_var = _tmp_228_rule(p)) // '.' | '...' ) { - _res = _tmp_226_var; + _res = _tmp_228_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -25644,12 +26051,12 @@ _loop1_32_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_227_var; + void *_tmp_229_var; while ( - (_tmp_227_var = _tmp_227_rule(p)) // '@' named_expression NEWLINE + (_tmp_229_var = _tmp_229_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_227_var; + _res = _tmp_229_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28676,9 +29083,128 @@ _gather_78_rule(Parser *p) return _res; } -// _loop1_80: (',' expression) +// _loop0_81: ',' type_param static asdl_seq * -_loop1_80_rule(Parser *p) +_loop0_81_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + Py_ssize_t _children_capacity = 1; + Py_ssize_t _n = 0; + { // ',' type_param + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' type_param")); + Token * _literal; + typeparam_ty elem; + while ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = type_param_rule(p)) // type_param + ) + { + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } + if (_n == _children_capacity) { + _children_capacity *= 2; + void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); + if (!_new_children) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + _children = _new_children; + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' type_param")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _gather_80: type_param _loop0_81 +static asdl_seq * +_gather_80_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + asdl_seq * _res = NULL; + int _mark = p->mark; + { // type_param _loop0_81 + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _gather_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_param _loop0_81")); + typeparam_ty elem; + asdl_seq * seq; + if ( + (elem = type_param_rule(p)) // type_param + && + (seq = _loop0_81_rule(p)) // _loop0_81 + ) + { + D(fprintf(stderr, "%*c+ _gather_80[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_param _loop0_81")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _gather_80[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_param _loop0_81")); + } + _res = NULL; + done: + p->level--; + return _res; +} + +// _loop1_82: (',' expression) +static asdl_seq * +_loop1_82_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -28704,13 +29230,13 @@ _loop1_80_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_228_var; + D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_230_var; while ( - (_tmp_228_var = _tmp_228_rule(p)) // ',' expression + (_tmp_230_var = _tmp_230_rule(p)) // ',' expression ) { - _res = _tmp_228_var; + _res = _tmp_230_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28727,7 +29253,7 @@ _loop1_80_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -28749,9 +29275,9 @@ _loop1_80_rule(Parser *p) return _seq; } -// _loop1_81: (',' star_expression) +// _loop1_83: (',' star_expression) static asdl_seq * -_loop1_81_rule(Parser *p) +_loop1_83_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -28777,13 +29303,13 @@ _loop1_81_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_229_var; + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_231_var; while ( - (_tmp_229_var = _tmp_229_rule(p)) // ',' star_expression + (_tmp_231_var = _tmp_231_rule(p)) // ',' star_expression ) { - _res = _tmp_229_var; + _res = _tmp_231_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28800,7 +29326,7 @@ _loop1_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -28822,9 +29348,9 @@ _loop1_81_rule(Parser *p) return _seq; } -// _loop0_83: ',' star_named_expression +// _loop0_85: ',' star_named_expression static asdl_seq * -_loop0_83_rule(Parser *p) +_loop0_85_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -28850,7 +29376,7 @@ _loop0_83_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); + D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -28882,7 +29408,7 @@ _loop0_83_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_83[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -28899,9 +29425,9 @@ _loop0_83_rule(Parser *p) return _seq; } -// _gather_82: star_named_expression _loop0_83 +// _gather_84: star_named_expression _loop0_85 static asdl_seq * -_gather_82_rule(Parser *p) +_gather_84_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -28913,27 +29439,27 @@ _gather_82_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_named_expression _loop0_83 + { // star_named_expression _loop0_85 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_83")); + D(fprintf(stderr, "%*c> _gather_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_85")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && - (seq = _loop0_83_rule(p)) // _loop0_83 + (seq = _loop0_85_rule(p)) // _loop0_85 ) { - D(fprintf(stderr, "%*c+ _gather_82[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_83")); + D(fprintf(stderr, "%*c+ _gather_84[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_85")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_82[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_83")); + D(fprintf(stderr, "%*c%s _gather_84[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_85")); } _res = NULL; done: @@ -28941,9 +29467,9 @@ _gather_82_rule(Parser *p) return _res; } -// _loop1_84: ('or' conjunction) +// _loop1_86: ('or' conjunction) static asdl_seq * -_loop1_84_rule(Parser *p) +_loop1_86_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -28969,13 +29495,13 @@ _loop1_84_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_230_var; + D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_232_var; while ( - (_tmp_230_var = _tmp_230_rule(p)) // 'or' conjunction + (_tmp_232_var = _tmp_232_rule(p)) // 'or' conjunction ) { - _res = _tmp_230_var; + _res = _tmp_232_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28992,7 +29518,7 @@ _loop1_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -29014,9 +29540,9 @@ _loop1_84_rule(Parser *p) return _seq; } -// _loop1_85: ('and' inversion) +// _loop1_87: ('and' inversion) static asdl_seq * -_loop1_85_rule(Parser *p) +_loop1_87_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29042,13 +29568,13 @@ _loop1_85_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_231_var; + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_233_var; while ( - (_tmp_231_var = _tmp_231_rule(p)) // 'and' inversion + (_tmp_233_var = _tmp_233_rule(p)) // 'and' inversion ) { - _res = _tmp_231_var; + _res = _tmp_233_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -29065,7 +29591,7 @@ _loop1_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -29087,9 +29613,9 @@ _loop1_85_rule(Parser *p) return _seq; } -// _loop1_86: compare_op_bitwise_or_pair +// _loop1_88: compare_op_bitwise_or_pair static asdl_seq * -_loop1_86_rule(Parser *p) +_loop1_88_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29115,7 +29641,7 @@ _loop1_86_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); + D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -29138,7 +29664,7 @@ _loop1_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -29160,9 +29686,9 @@ _loop1_86_rule(Parser *p) return _seq; } -// _tmp_87: '!=' +// _tmp_89: '!=' static void * -_tmp_87_rule(Parser *p) +_tmp_89_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29179,13 +29705,13 @@ _tmp_87_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { - D(fprintf(stderr, "%*c+ _tmp_87[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); + D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29195,7 +29721,7 @@ _tmp_87_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_87[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -29204,9 +29730,9 @@ _tmp_87_rule(Parser *p) return _res; } -// _loop0_89: ',' (slice | starred_expression) +// _loop0_91: ',' (slice | starred_expression) static asdl_seq * -_loop0_89_rule(Parser *p) +_loop0_91_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29232,13 +29758,13 @@ _loop0_89_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); + D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_232_rule(p)) // slice | starred_expression + (elem = _tmp_234_rule(p)) // slice | starred_expression ) { _res = elem; @@ -29264,7 +29790,7 @@ _loop0_89_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_89[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (slice | starred_expression)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -29281,9 +29807,9 @@ _loop0_89_rule(Parser *p) return _seq; } -// _gather_88: (slice | starred_expression) _loop0_89 +// _gather_90: (slice | starred_expression) _loop0_91 static asdl_seq * -_gather_88_rule(Parser *p) +_gather_90_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29295,27 +29821,27 @@ _gather_88_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (slice | starred_expression) _loop0_89 + { // (slice | starred_expression) _loop0_91 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_89")); + D(fprintf(stderr, "%*c> _gather_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_91")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_232_rule(p)) // slice | starred_expression + (elem = _tmp_234_rule(p)) // slice | starred_expression && - (seq = _loop0_89_rule(p)) // _loop0_89 + (seq = _loop0_91_rule(p)) // _loop0_91 ) { - D(fprintf(stderr, "%*c+ _gather_88[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_89")); + D(fprintf(stderr, "%*c+ _gather_90[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_91")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_88[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_89")); + D(fprintf(stderr, "%*c%s _gather_90[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_91")); } _res = NULL; done: @@ -29323,9 +29849,9 @@ _gather_88_rule(Parser *p) return _res; } -// _tmp_90: ':' expression? +// _tmp_92: ':' expression? static void * -_tmp_90_rule(Parser *p) +_tmp_92_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29342,7 +29868,7 @@ _tmp_90_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -29351,7 +29877,7 @@ _tmp_90_rule(Parser *p) (d = expression_rule(p), !p->error_indicator) // expression? ) { - D(fprintf(stderr, "%*c+ _tmp_90[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); + D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -29361,7 +29887,7 @@ _tmp_90_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_90[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -29370,9 +29896,9 @@ _tmp_90_rule(Parser *p) return _res; } -// _tmp_91: tuple | group | genexp +// _tmp_93: tuple | group | genexp static void * -_tmp_91_rule(Parser *p) +_tmp_93_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29389,18 +29915,18 @@ _tmp_91_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -29408,18 +29934,18 @@ _tmp_91_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -29427,18 +29953,18 @@ _tmp_91_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_91[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -29447,9 +29973,9 @@ _tmp_91_rule(Parser *p) return _res; } -// _tmp_92: list | listcomp +// _tmp_94: list | listcomp static void * -_tmp_92_rule(Parser *p) +_tmp_94_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29466,18 +29992,18 @@ _tmp_92_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -29485,18 +30011,18 @@ _tmp_92_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -29505,9 +30031,9 @@ _tmp_92_rule(Parser *p) return _res; } -// _tmp_93: dict | set | dictcomp | setcomp +// _tmp_95: dict | set | dictcomp | setcomp static void * -_tmp_93_rule(Parser *p) +_tmp_95_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29524,18 +30050,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -29543,18 +30069,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -29562,18 +30088,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -29581,18 +30107,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -29601,9 +30127,9 @@ _tmp_93_rule(Parser *p) return _res; } -// _tmp_94: yield_expr | named_expression +// _tmp_96: yield_expr | named_expression static void * -_tmp_94_rule(Parser *p) +_tmp_96_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29620,18 +30146,18 @@ _tmp_94_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -29639,18 +30165,18 @@ _tmp_94_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -29659,9 +30185,9 @@ _tmp_94_rule(Parser *p) return _res; } -// _loop0_95: lambda_param_no_default +// _loop0_97: lambda_param_no_default static asdl_seq * -_loop0_95_rule(Parser *p) +_loop0_97_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29687,7 +30213,7 @@ _loop0_95_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -29710,7 +30236,7 @@ _loop0_95_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -29727,9 +30253,9 @@ _loop0_95_rule(Parser *p) return _seq; } -// _loop0_96: lambda_param_with_default +// _loop0_98: lambda_param_with_default static asdl_seq * -_loop0_96_rule(Parser *p) +_loop0_98_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29755,7 +30281,7 @@ _loop0_96_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -29778,7 +30304,7 @@ _loop0_96_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -29795,9 +30321,9 @@ _loop0_96_rule(Parser *p) return _seq; } -// _loop0_97: lambda_param_with_default +// _loop0_99: lambda_param_with_default static asdl_seq * -_loop0_97_rule(Parser *p) +_loop0_99_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29823,7 +30349,7 @@ _loop0_97_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -29846,7 +30372,7 @@ _loop0_97_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -29863,9 +30389,9 @@ _loop0_97_rule(Parser *p) return _seq; } -// _loop1_98: lambda_param_no_default +// _loop1_100: lambda_param_no_default static asdl_seq * -_loop1_98_rule(Parser *p) +_loop1_100_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29891,7 +30417,7 @@ _loop1_98_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -29914,7 +30440,7 @@ _loop1_98_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_98[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -29936,9 +30462,9 @@ _loop1_98_rule(Parser *p) return _seq; } -// _loop0_99: lambda_param_with_default +// _loop0_101: lambda_param_with_default static asdl_seq * -_loop0_99_rule(Parser *p) +_loop0_101_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -29964,7 +30490,7 @@ _loop0_99_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -29987,7 +30513,7 @@ _loop0_99_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_101[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -30004,9 +30530,9 @@ _loop0_99_rule(Parser *p) return _seq; } -// _loop1_100: lambda_param_with_default +// _loop1_102: lambda_param_with_default static asdl_seq * -_loop1_100_rule(Parser *p) +_loop1_102_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30032,7 +30558,7 @@ _loop1_100_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -30055,7 +30581,7 @@ _loop1_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -30077,9 +30603,9 @@ _loop1_100_rule(Parser *p) return _seq; } -// _loop1_101: lambda_param_no_default +// _loop1_103: lambda_param_no_default static asdl_seq * -_loop1_101_rule(Parser *p) +_loop1_103_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30105,7 +30631,7 @@ _loop1_101_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -30128,7 +30654,7 @@ _loop1_101_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -30150,9 +30676,9 @@ _loop1_101_rule(Parser *p) return _seq; } -// _loop1_102: lambda_param_no_default +// _loop1_104: lambda_param_no_default static asdl_seq * -_loop1_102_rule(Parser *p) +_loop1_104_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30178,7 +30704,7 @@ _loop1_102_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -30201,7 +30727,7 @@ _loop1_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -30223,9 +30749,9 @@ _loop1_102_rule(Parser *p) return _seq; } -// _loop0_103: lambda_param_no_default +// _loop0_105: lambda_param_no_default static asdl_seq * -_loop0_103_rule(Parser *p) +_loop0_105_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30251,7 +30777,7 @@ _loop0_103_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -30274,7 +30800,7 @@ _loop0_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -30291,9 +30817,9 @@ _loop0_103_rule(Parser *p) return _seq; } -// _loop1_104: lambda_param_with_default +// _loop1_106: lambda_param_with_default static asdl_seq * -_loop1_104_rule(Parser *p) +_loop1_106_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30319,7 +30845,7 @@ _loop1_104_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -30342,7 +30868,7 @@ _loop1_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -30364,9 +30890,9 @@ _loop1_104_rule(Parser *p) return _seq; } -// _loop0_105: lambda_param_no_default +// _loop0_107: lambda_param_no_default static asdl_seq * -_loop0_105_rule(Parser *p) +_loop0_107_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30392,7 +30918,7 @@ _loop0_105_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -30415,7 +30941,7 @@ _loop0_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -30432,9 +30958,9 @@ _loop0_105_rule(Parser *p) return _seq; } -// _loop1_106: lambda_param_with_default +// _loop1_108: lambda_param_with_default static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_108_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30460,7 +30986,7 @@ _loop1_106_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -30483,7 +31009,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -30505,9 +31031,9 @@ _loop1_106_rule(Parser *p) return _seq; } -// _loop0_107: lambda_param_maybe_default +// _loop0_109: lambda_param_maybe_default static asdl_seq * -_loop0_107_rule(Parser *p) +_loop0_109_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30533,7 +31059,7 @@ _loop0_107_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -30556,7 +31082,7 @@ _loop0_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -30573,9 +31099,9 @@ _loop0_107_rule(Parser *p) return _seq; } -// _loop1_108: lambda_param_maybe_default +// _loop1_110: lambda_param_maybe_default static asdl_seq * -_loop1_108_rule(Parser *p) +_loop1_110_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30601,7 +31127,7 @@ _loop1_108_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -30624,7 +31150,7 @@ _loop1_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -30646,9 +31172,9 @@ _loop1_108_rule(Parser *p) return _seq; } -// _loop1_109: STRING +// _loop1_111: STRING static asdl_seq * -_loop1_109_rule(Parser *p) +_loop1_111_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30674,7 +31200,7 @@ _loop1_109_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; while ( (string_var = _PyPegen_string_token(p)) // STRING @@ -30697,7 +31223,7 @@ _loop1_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } if (_n == 0 || p->error_indicator) { @@ -30719,9 +31245,9 @@ _loop1_109_rule(Parser *p) return _seq; } -// _tmp_110: star_named_expression ',' star_named_expressions? +// _tmp_112: star_named_expression ',' star_named_expressions? static void * -_tmp_110_rule(Parser *p) +_tmp_112_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30738,7 +31264,7 @@ _tmp_110_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -30750,7 +31276,7 @@ _tmp_110_rule(Parser *p) (z = star_named_expressions_rule(p), !p->error_indicator) // star_named_expressions? ) { - D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); + D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -30760,7 +31286,7 @@ _tmp_110_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -30769,9 +31295,9 @@ _tmp_110_rule(Parser *p) return _res; } -// _loop0_112: ',' double_starred_kvpair +// _loop0_114: ',' double_starred_kvpair static asdl_seq * -_loop0_112_rule(Parser *p) +_loop0_114_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30797,7 +31323,7 @@ _loop0_112_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -30829,7 +31355,7 @@ _loop0_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -30846,9 +31372,9 @@ _loop0_112_rule(Parser *p) return _seq; } -// _gather_111: double_starred_kvpair _loop0_112 +// _gather_113: double_starred_kvpair _loop0_114 static asdl_seq * -_gather_111_rule(Parser *p) +_gather_113_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30860,27 +31386,27 @@ _gather_111_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_112 + { // double_starred_kvpair _loop0_114 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_112")); + D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_114")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_112_rule(p)) // _loop0_112 + (seq = _loop0_114_rule(p)) // _loop0_114 ) { - D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_112")); + D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_114")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_112")); + D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_114")); } _res = NULL; done: @@ -30888,9 +31414,9 @@ _gather_111_rule(Parser *p) return _res; } -// _loop1_113: for_if_clause +// _loop1_115: for_if_clause static asdl_seq * -_loop1_113_rule(Parser *p) +_loop1_115_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30916,7 +31442,7 @@ _loop1_113_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -30939,7 +31465,7 @@ _loop1_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -30961,9 +31487,9 @@ _loop1_113_rule(Parser *p) return _seq; } -// _loop0_114: ('if' disjunction) +// _loop0_116: ('if' disjunction) static asdl_seq * -_loop0_114_rule(Parser *p) +_loop0_116_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -30989,13 +31515,13 @@ _loop0_114_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_233_var; + D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_235_var; while ( - (_tmp_233_var = _tmp_233_rule(p)) // 'if' disjunction + (_tmp_235_var = _tmp_235_rule(p)) // 'if' disjunction ) { - _res = _tmp_233_var; + _res = _tmp_235_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31012,7 +31538,7 @@ _loop0_114_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31029,9 +31555,9 @@ _loop0_114_rule(Parser *p) return _seq; } -// _loop0_115: ('if' disjunction) +// _loop0_117: ('if' disjunction) static asdl_seq * -_loop0_115_rule(Parser *p) +_loop0_117_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31057,13 +31583,13 @@ _loop0_115_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_234_var; + D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_236_var; while ( - (_tmp_234_var = _tmp_234_rule(p)) // 'if' disjunction + (_tmp_236_var = _tmp_236_rule(p)) // 'if' disjunction ) { - _res = _tmp_234_var; + _res = _tmp_236_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31080,7 +31606,7 @@ _loop0_115_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_115[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31097,9 +31623,9 @@ _loop0_115_rule(Parser *p) return _seq; } -// _tmp_116: assignment_expression | expression !':=' +// _tmp_118: assignment_expression | expression !':=' static void * -_tmp_116_rule(Parser *p) +_tmp_118_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31116,18 +31642,18 @@ _tmp_116_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); expr_ty assignment_expression_var; if ( (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression ) { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); _res = assignment_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); } { // expression !':=' @@ -31135,7 +31661,7 @@ _tmp_116_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); + D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression @@ -31143,12 +31669,12 @@ _tmp_116_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); + D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); _res = expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); } _res = NULL; @@ -31157,9 +31683,9 @@ _tmp_116_rule(Parser *p) return _res; } -// _loop0_118: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +// _loop0_120: ',' (starred_expression | (assignment_expression | expression !':=') !'=') static asdl_seq * -_loop0_118_rule(Parser *p) +_loop0_120_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31185,13 +31711,13 @@ _loop0_118_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); + D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_235_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + (elem = _tmp_237_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' ) { _res = elem; @@ -31217,7 +31743,7 @@ _loop0_118_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31234,10 +31760,10 @@ _loop0_118_rule(Parser *p) return _seq; } -// _gather_117: -// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_118 +// _gather_119: +// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120 static asdl_seq * -_gather_117_rule(Parser *p) +_gather_119_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31249,27 +31775,27 @@ _gather_117_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_118 + { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_118")); + D(fprintf(stderr, "%*c> _gather_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_235_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + (elem = _tmp_237_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' && - (seq = _loop0_118_rule(p)) // _loop0_118 + (seq = _loop0_120_rule(p)) // _loop0_120 ) { - D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_118")); + D(fprintf(stderr, "%*c+ _gather_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_118")); + D(fprintf(stderr, "%*c%s _gather_119[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120")); } _res = NULL; done: @@ -31277,9 +31803,9 @@ _gather_117_rule(Parser *p) return _res; } -// _tmp_119: ',' kwargs +// _tmp_121: ',' kwargs static void * -_tmp_119_rule(Parser *p) +_tmp_121_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31296,7 +31822,7 @@ _tmp_119_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); + D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); Token * _literal; asdl_seq* k; if ( @@ -31305,7 +31831,7 @@ _tmp_119_rule(Parser *p) (k = kwargs_rule(p)) // kwargs ) { - D(fprintf(stderr, "%*c+ _tmp_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); + D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); _res = k; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -31315,7 +31841,7 @@ _tmp_119_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_119[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); } _res = NULL; @@ -31324,9 +31850,9 @@ _tmp_119_rule(Parser *p) return _res; } -// _loop0_121: ',' kwarg_or_starred +// _loop0_123: ',' kwarg_or_starred static asdl_seq * -_loop0_121_rule(Parser *p) +_loop0_123_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31352,7 +31878,7 @@ _loop0_121_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -31384,7 +31910,7 @@ _loop0_121_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_123[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31401,9 +31927,9 @@ _loop0_121_rule(Parser *p) return _seq; } -// _gather_120: kwarg_or_starred _loop0_121 +// _gather_122: kwarg_or_starred _loop0_123 static asdl_seq * -_gather_120_rule(Parser *p) +_gather_122_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31415,27 +31941,27 @@ _gather_120_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_121 + { // kwarg_or_starred _loop0_123 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_121")); + D(fprintf(stderr, "%*c> _gather_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_123")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_121_rule(p)) // _loop0_121 + (seq = _loop0_123_rule(p)) // _loop0_123 ) { - D(fprintf(stderr, "%*c+ _gather_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_121")); + D(fprintf(stderr, "%*c+ _gather_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_123")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_120[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_121")); + D(fprintf(stderr, "%*c%s _gather_122[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_123")); } _res = NULL; done: @@ -31443,9 +31969,9 @@ _gather_120_rule(Parser *p) return _res; } -// _loop0_123: ',' kwarg_or_double_starred +// _loop0_125: ',' kwarg_or_double_starred static asdl_seq * -_loop0_123_rule(Parser *p) +_loop0_125_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31471,7 +31997,7 @@ _loop0_123_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -31503,7 +32029,7 @@ _loop0_123_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31520,9 +32046,9 @@ _loop0_123_rule(Parser *p) return _seq; } -// _gather_122: kwarg_or_double_starred _loop0_123 +// _gather_124: kwarg_or_double_starred _loop0_125 static asdl_seq * -_gather_122_rule(Parser *p) +_gather_124_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31534,27 +32060,27 @@ _gather_122_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_123 + { // kwarg_or_double_starred _loop0_125 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_123")); + D(fprintf(stderr, "%*c> _gather_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_125")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_123_rule(p)) // _loop0_123 + (seq = _loop0_125_rule(p)) // _loop0_125 ) { - D(fprintf(stderr, "%*c+ _gather_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_123")); + D(fprintf(stderr, "%*c+ _gather_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_125")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_122[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_123")); + D(fprintf(stderr, "%*c%s _gather_124[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_125")); } _res = NULL; done: @@ -31562,9 +32088,9 @@ _gather_122_rule(Parser *p) return _res; } -// _loop0_125: ',' kwarg_or_starred +// _loop0_127: ',' kwarg_or_starred static asdl_seq * -_loop0_125_rule(Parser *p) +_loop0_127_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31590,7 +32116,7 @@ _loop0_125_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -31622,7 +32148,7 @@ _loop0_125_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31639,9 +32165,9 @@ _loop0_125_rule(Parser *p) return _seq; } -// _gather_124: kwarg_or_starred _loop0_125 +// _gather_126: kwarg_or_starred _loop0_127 static asdl_seq * -_gather_124_rule(Parser *p) +_gather_126_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31653,27 +32179,27 @@ _gather_124_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_125 + { // kwarg_or_starred _loop0_127 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_125")); + D(fprintf(stderr, "%*c> _gather_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_127")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_125_rule(p)) // _loop0_125 + (seq = _loop0_127_rule(p)) // _loop0_127 ) { - D(fprintf(stderr, "%*c+ _gather_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_125")); + D(fprintf(stderr, "%*c+ _gather_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_127")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_124[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_125")); + D(fprintf(stderr, "%*c%s _gather_126[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_127")); } _res = NULL; done: @@ -31681,9 +32207,9 @@ _gather_124_rule(Parser *p) return _res; } -// _loop0_127: ',' kwarg_or_double_starred +// _loop0_129: ',' kwarg_or_double_starred static asdl_seq * -_loop0_127_rule(Parser *p) +_loop0_129_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31709,7 +32235,7 @@ _loop0_127_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -31741,7 +32267,7 @@ _loop0_127_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31758,9 +32284,9 @@ _loop0_127_rule(Parser *p) return _seq; } -// _gather_126: kwarg_or_double_starred _loop0_127 +// _gather_128: kwarg_or_double_starred _loop0_129 static asdl_seq * -_gather_126_rule(Parser *p) +_gather_128_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31772,27 +32298,27 @@ _gather_126_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_127 + { // kwarg_or_double_starred _loop0_129 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_127")); + D(fprintf(stderr, "%*c> _gather_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_129")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_127_rule(p)) // _loop0_127 + (seq = _loop0_129_rule(p)) // _loop0_129 ) { - D(fprintf(stderr, "%*c+ _gather_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_127")); + D(fprintf(stderr, "%*c+ _gather_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_129")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_126[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_127")); + D(fprintf(stderr, "%*c%s _gather_128[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_129")); } _res = NULL; done: @@ -31800,9 +32326,9 @@ _gather_126_rule(Parser *p) return _res; } -// _loop0_128: (',' star_target) +// _loop0_130: (',' star_target) static asdl_seq * -_loop0_128_rule(Parser *p) +_loop0_130_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31828,13 +32354,13 @@ _loop0_128_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_236_var; + D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_238_var; while ( - (_tmp_236_var = _tmp_236_rule(p)) // ',' star_target + (_tmp_238_var = _tmp_238_rule(p)) // ',' star_target ) { - _res = _tmp_236_var; + _res = _tmp_238_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31851,7 +32377,7 @@ _loop0_128_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31868,9 +32394,9 @@ _loop0_128_rule(Parser *p) return _seq; } -// _loop0_130: ',' star_target +// _loop0_132: ',' star_target static asdl_seq * -_loop0_130_rule(Parser *p) +_loop0_132_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31896,7 +32422,7 @@ _loop0_130_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty elem; while ( @@ -31928,7 +32454,7 @@ _loop0_130_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31945,9 +32471,9 @@ _loop0_130_rule(Parser *p) return _seq; } -// _gather_129: star_target _loop0_130 +// _gather_131: star_target _loop0_132 static asdl_seq * -_gather_129_rule(Parser *p) +_gather_131_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31959,27 +32485,27 @@ _gather_129_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_130 + { // star_target _loop0_132 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_130")); + D(fprintf(stderr, "%*c> _gather_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_132")); expr_ty elem; asdl_seq * seq; if ( (elem = star_target_rule(p)) // star_target && - (seq = _loop0_130_rule(p)) // _loop0_130 + (seq = _loop0_132_rule(p)) // _loop0_132 ) { - D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_130")); + D(fprintf(stderr, "%*c+ _gather_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_132")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_130")); + D(fprintf(stderr, "%*c%s _gather_131[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_132")); } _res = NULL; done: @@ -31987,9 +32513,9 @@ _gather_129_rule(Parser *p) return _res; } -// _loop1_131: (',' star_target) +// _loop1_133: (',' star_target) static asdl_seq * -_loop1_131_rule(Parser *p) +_loop1_133_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32015,13 +32541,13 @@ _loop1_131_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_237_var; + D(fprintf(stderr, "%*c> _loop1_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_239_var; while ( - (_tmp_237_var = _tmp_237_rule(p)) // ',' star_target + (_tmp_239_var = _tmp_239_rule(p)) // ',' star_target ) { - _res = _tmp_237_var; + _res = _tmp_239_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -32038,7 +32564,7 @@ _loop1_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_131[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } if (_n == 0 || p->error_indicator) { @@ -32060,9 +32586,9 @@ _loop1_131_rule(Parser *p) return _seq; } -// _tmp_132: !'*' star_target +// _tmp_134: !'*' star_target static void * -_tmp_132_rule(Parser *p) +_tmp_134_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32079,7 +32605,7 @@ _tmp_132_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); expr_ty star_target_var; if ( _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' @@ -32087,12 +32613,12 @@ _tmp_132_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; @@ -32101,9 +32627,9 @@ _tmp_132_rule(Parser *p) return _res; } -// _loop0_134: ',' del_target +// _loop0_136: ',' del_target static asdl_seq * -_loop0_134_rule(Parser *p) +_loop0_136_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32129,7 +32655,7 @@ _loop0_134_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); Token * _literal; expr_ty elem; while ( @@ -32161,7 +32687,7 @@ _loop0_134_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -32178,9 +32704,9 @@ _loop0_134_rule(Parser *p) return _seq; } -// _gather_133: del_target _loop0_134 +// _gather_135: del_target _loop0_136 static asdl_seq * -_gather_133_rule(Parser *p) +_gather_135_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32192,27 +32718,27 @@ _gather_133_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // del_target _loop0_134 + { // del_target _loop0_136 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_134")); + D(fprintf(stderr, "%*c> _gather_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_136")); expr_ty elem; asdl_seq * seq; if ( (elem = del_target_rule(p)) // del_target && - (seq = _loop0_134_rule(p)) // _loop0_134 + (seq = _loop0_136_rule(p)) // _loop0_136 ) { - D(fprintf(stderr, "%*c+ _gather_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_134")); + D(fprintf(stderr, "%*c+ _gather_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_136")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_133[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_134")); + D(fprintf(stderr, "%*c%s _gather_135[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_136")); } _res = NULL; done: @@ -32220,9 +32746,9 @@ _gather_133_rule(Parser *p) return _res; } -// _loop0_136: ',' expression +// _loop0_138: ',' expression static asdl_seq * -_loop0_136_rule(Parser *p) +_loop0_138_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32248,7 +32774,7 @@ _loop0_136_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( @@ -32280,7 +32806,7 @@ _loop0_136_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -32297,9 +32823,9 @@ _loop0_136_rule(Parser *p) return _seq; } -// _gather_135: expression _loop0_136 +// _gather_137: expression _loop0_138 static asdl_seq * -_gather_135_rule(Parser *p) +_gather_137_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32311,27 +32837,27 @@ _gather_135_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_136 + { // expression _loop0_138 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_136")); + D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_138")); expr_ty elem; asdl_seq * seq; if ( (elem = expression_rule(p)) // expression && - (seq = _loop0_136_rule(p)) // _loop0_136 + (seq = _loop0_138_rule(p)) // _loop0_138 ) { - D(fprintf(stderr, "%*c+ _gather_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_136")); + D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_138")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_136")); + D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_138")); } _res = NULL; done: @@ -32339,9 +32865,9 @@ _gather_135_rule(Parser *p) return _res; } -// _loop0_138: ',' expression +// _loop0_140: ',' expression static asdl_seq * -_loop0_138_rule(Parser *p) +_loop0_140_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32367,7 +32893,7 @@ _loop0_138_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( @@ -32399,7 +32925,7 @@ _loop0_138_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -32416,9 +32942,9 @@ _loop0_138_rule(Parser *p) return _seq; } -// _gather_137: expression _loop0_138 +// _gather_139: expression _loop0_140 static asdl_seq * -_gather_137_rule(Parser *p) +_gather_139_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32430,27 +32956,27 @@ _gather_137_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_138 + { // expression _loop0_140 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_138")); + D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_140")); expr_ty elem; asdl_seq * seq; if ( (elem = expression_rule(p)) // expression && - (seq = _loop0_138_rule(p)) // _loop0_138 + (seq = _loop0_140_rule(p)) // _loop0_140 ) { - D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_138")); + D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_140")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_138")); + D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_140")); } _res = NULL; done: @@ -32458,9 +32984,9 @@ _gather_137_rule(Parser *p) return _res; } -// _loop0_140: ',' expression +// _loop0_142: ',' expression static asdl_seq * -_loop0_140_rule(Parser *p) +_loop0_142_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32486,7 +33012,7 @@ _loop0_140_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( @@ -32518,7 +33044,7 @@ _loop0_140_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -32535,9 +33061,9 @@ _loop0_140_rule(Parser *p) return _seq; } -// _gather_139: expression _loop0_140 +// _gather_141: expression _loop0_142 static asdl_seq * -_gather_139_rule(Parser *p) +_gather_141_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32549,27 +33075,27 @@ _gather_139_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_140 + { // expression _loop0_142 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_140")); + D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); expr_ty elem; asdl_seq * seq; if ( (elem = expression_rule(p)) // expression && - (seq = _loop0_140_rule(p)) // _loop0_140 + (seq = _loop0_142_rule(p)) // _loop0_142 ) { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_140")); + D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_140")); + D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_142")); } _res = NULL; done: @@ -32577,9 +33103,9 @@ _gather_139_rule(Parser *p) return _res; } -// _loop0_142: ',' expression +// _loop0_144: ',' expression static asdl_seq * -_loop0_142_rule(Parser *p) +_loop0_144_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32605,7 +33131,7 @@ _loop0_142_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( @@ -32637,7 +33163,7 @@ _loop0_142_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -32654,9 +33180,9 @@ _loop0_142_rule(Parser *p) return _seq; } -// _gather_141: expression _loop0_142 +// _gather_143: expression _loop0_144 static asdl_seq * -_gather_141_rule(Parser *p) +_gather_143_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32668,27 +33194,27 @@ _gather_141_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_142 + { // expression _loop0_144 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); + D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_144")); expr_ty elem; asdl_seq * seq; if ( (elem = expression_rule(p)) // expression && - (seq = _loop0_142_rule(p)) // _loop0_142 + (seq = _loop0_144_rule(p)) // _loop0_144 ) { - D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); + D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_144")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_142")); + D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_144")); } _res = NULL; done: @@ -32696,9 +33222,9 @@ _gather_141_rule(Parser *p) return _res; } -// _tmp_143: NEWLINE INDENT +// _tmp_145: NEWLINE INDENT static void * -_tmp_143_rule(Parser *p) +_tmp_145_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32715,7 +33241,7 @@ _tmp_143_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -32724,12 +33250,12 @@ _tmp_143_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { - D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); + D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -32738,9 +33264,9 @@ _tmp_143_rule(Parser *p) return _res; } -// _tmp_144: args | expression for_if_clauses +// _tmp_146: args | expression for_if_clauses static void * -_tmp_144_rule(Parser *p) +_tmp_146_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32757,18 +33283,18 @@ _tmp_144_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -32776,7 +33302,7 @@ _tmp_144_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_comprehension_seq* for_if_clauses_var; if ( @@ -32785,12 +33311,12 @@ _tmp_144_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { - D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); + D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -32799,9 +33325,9 @@ _tmp_144_rule(Parser *p) return _res; } -// _tmp_145: args ',' +// _tmp_147: args ',' static void * -_tmp_145_rule(Parser *p) +_tmp_147_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32818,7 +33344,7 @@ _tmp_145_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); + D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); Token * _literal; expr_ty args_var; if ( @@ -32827,12 +33353,12 @@ _tmp_145_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); + D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); _res = _PyPegen_dummy_name(p, args_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','")); } _res = NULL; @@ -32841,9 +33367,9 @@ _tmp_145_rule(Parser *p) return _res; } -// _tmp_146: ',' | ')' +// _tmp_148: ',' | ')' static void * -_tmp_146_rule(Parser *p) +_tmp_148_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32860,18 +33386,18 @@ _tmp_146_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // ')' @@ -32879,18 +33405,18 @@ _tmp_146_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } _res = NULL; @@ -32899,9 +33425,9 @@ _tmp_146_rule(Parser *p) return _res; } -// _tmp_147: 'True' | 'False' | 'None' +// _tmp_149: 'True' | 'False' | 'None' static void * -_tmp_147_rule(Parser *p) +_tmp_149_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32918,18 +33444,18 @@ _tmp_147_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 600)) // token='True' ) { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); } { // 'False' @@ -32937,18 +33463,18 @@ _tmp_147_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 602)) // token='False' ) { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); } { // 'None' @@ -32956,18 +33482,18 @@ _tmp_147_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 601)) // token='None' ) { - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); } _res = NULL; @@ -32976,9 +33502,9 @@ _tmp_147_rule(Parser *p) return _res; } -// _tmp_148: NAME '=' +// _tmp_150: NAME '=' static void * -_tmp_148_rule(Parser *p) +_tmp_150_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32995,7 +33521,7 @@ _tmp_148_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); Token * _literal; expr_ty name_var; if ( @@ -33004,12 +33530,12 @@ _tmp_148_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); _res = _PyPegen_dummy_name(p, name_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '='")); } _res = NULL; @@ -33018,9 +33544,9 @@ _tmp_148_rule(Parser *p) return _res; } -// _tmp_149: NAME STRING | SOFT_KEYWORD +// _tmp_151: NAME STRING | SOFT_KEYWORD static void * -_tmp_149_rule(Parser *p) +_tmp_151_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33037,7 +33563,7 @@ _tmp_149_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); expr_ty name_var; expr_ty string_var; if ( @@ -33046,12 +33572,12 @@ _tmp_149_rule(Parser *p) (string_var = _PyPegen_string_token(p)) // STRING ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); _res = _PyPegen_dummy_name(p, name_var, string_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME STRING")); } { // SOFT_KEYWORD @@ -33059,18 +33585,18 @@ _tmp_149_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); expr_ty soft_keyword_var; if ( (soft_keyword_var = _PyPegen_soft_keyword_token(p)) // SOFT_KEYWORD ) { - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); _res = soft_keyword_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "SOFT_KEYWORD")); } _res = NULL; @@ -33079,9 +33605,9 @@ _tmp_149_rule(Parser *p) return _res; } -// _tmp_150: 'else' | ':' +// _tmp_152: 'else' | ':' static void * -_tmp_150_rule(Parser *p) +_tmp_152_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33098,18 +33624,18 @@ _tmp_150_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 644)) // token='else' ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else'")); } { // ':' @@ -33117,18 +33643,18 @@ _tmp_150_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } _res = NULL; @@ -33137,9 +33663,9 @@ _tmp_150_rule(Parser *p) return _res; } -// _tmp_151: '=' | ':=' +// _tmp_153: '=' | ':=' static void * -_tmp_151_rule(Parser *p) +_tmp_153_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33156,18 +33682,18 @@ _tmp_151_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } { // ':=' @@ -33175,18 +33701,18 @@ _tmp_151_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 53)) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); } _res = NULL; @@ -33195,9 +33721,9 @@ _tmp_151_rule(Parser *p) return _res; } -// _tmp_152: list | tuple | genexp | 'True' | 'None' | 'False' +// _tmp_154: list | tuple | genexp | 'True' | 'None' | 'False' static void * -_tmp_152_rule(Parser *p) +_tmp_154_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33214,18 +33740,18 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // tuple @@ -33233,18 +33759,18 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // genexp @@ -33252,18 +33778,18 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } { // 'True' @@ -33271,18 +33797,18 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 600)) // token='True' ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); } { // 'None' @@ -33290,18 +33816,18 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 601)) // token='None' ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); } { // 'False' @@ -33309,18 +33835,18 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 602)) // token='False' ) { - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); } _res = NULL; @@ -33329,9 +33855,9 @@ _tmp_152_rule(Parser *p) return _res; } -// _tmp_153: '=' | ':=' +// _tmp_155: '=' | ':=' static void * -_tmp_153_rule(Parser *p) +_tmp_155_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33348,18 +33874,18 @@ _tmp_153_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } { // ':=' @@ -33367,18 +33893,18 @@ _tmp_153_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 53)) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); } _res = NULL; @@ -33387,9 +33913,9 @@ _tmp_153_rule(Parser *p) return _res; } -// _loop0_154: star_named_expressions +// _loop0_156: star_named_expressions static asdl_seq * -_loop0_154_rule(Parser *p) +_loop0_156_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33415,7 +33941,7 @@ _loop0_154_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); asdl_expr_seq* star_named_expressions_var; while ( (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions @@ -33438,7 +33964,7 @@ _loop0_154_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_154[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33455,9 +33981,9 @@ _loop0_154_rule(Parser *p) return _seq; } -// _loop0_155: (star_targets '=') +// _loop0_157: (star_targets '=') static asdl_seq * -_loop0_155_rule(Parser *p) +_loop0_157_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33483,13 +34009,13 @@ _loop0_155_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_238_var; + D(fprintf(stderr, "%*c> _loop0_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_240_var; while ( - (_tmp_238_var = _tmp_238_rule(p)) // star_targets '=' + (_tmp_240_var = _tmp_240_rule(p)) // star_targets '=' ) { - _res = _tmp_238_var; + _res = _tmp_240_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -33506,7 +34032,7 @@ _loop0_155_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33523,9 +34049,9 @@ _loop0_155_rule(Parser *p) return _seq; } -// _loop0_156: (star_targets '=') +// _loop0_158: (star_targets '=') static asdl_seq * -_loop0_156_rule(Parser *p) +_loop0_158_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33551,13 +34077,13 @@ _loop0_156_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_239_var; + D(fprintf(stderr, "%*c> _loop0_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_241_var; while ( - (_tmp_239_var = _tmp_239_rule(p)) // star_targets '=' + (_tmp_241_var = _tmp_241_rule(p)) // star_targets '=' ) { - _res = _tmp_239_var; + _res = _tmp_241_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -33574,7 +34100,7 @@ _loop0_156_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33591,9 +34117,9 @@ _loop0_156_rule(Parser *p) return _seq; } -// _tmp_157: yield_expr | star_expressions +// _tmp_159: yield_expr | star_expressions static void * -_tmp_157_rule(Parser *p) +_tmp_159_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33610,18 +34136,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -33629,18 +34155,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -33649,9 +34175,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: '[' | '(' | '{' +// _tmp_160: '[' | '(' | '{' static void * -_tmp_158_rule(Parser *p) +_tmp_160_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33668,18 +34194,18 @@ _tmp_158_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '(' @@ -33687,18 +34213,18 @@ _tmp_158_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -33706,18 +34232,18 @@ _tmp_158_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -33726,9 +34252,9 @@ _tmp_158_rule(Parser *p) return _res; } -// _tmp_159: '[' | '{' +// _tmp_161: '[' | '{' static void * -_tmp_159_rule(Parser *p) +_tmp_161_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33745,18 +34271,18 @@ _tmp_159_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '{' @@ -33764,18 +34290,18 @@ _tmp_159_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -33784,9 +34310,9 @@ _tmp_159_rule(Parser *p) return _res; } -// _tmp_160: '[' | '{' +// _tmp_162: '[' | '{' static void * -_tmp_160_rule(Parser *p) +_tmp_162_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33803,18 +34329,18 @@ _tmp_160_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '{' @@ -33822,18 +34348,18 @@ _tmp_160_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -33842,9 +34368,9 @@ _tmp_160_rule(Parser *p) return _res; } -// _tmp_161: slash_no_default | slash_with_default +// _tmp_163: slash_no_default | slash_with_default static void * -_tmp_161_rule(Parser *p) +_tmp_163_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33861,18 +34387,18 @@ _tmp_161_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); asdl_arg_seq* slash_no_default_var; if ( (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); _res = slash_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); } { // slash_with_default @@ -33880,18 +34406,18 @@ _tmp_161_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); SlashWithDefault* slash_with_default_var; if ( (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); _res = slash_with_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } _res = NULL; @@ -33900,9 +34426,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _loop0_162: param_maybe_default +// _loop0_164: param_maybe_default static asdl_seq * -_loop0_162_rule(Parser *p) +_loop0_164_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33928,7 +34454,7 @@ _loop0_162_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -33951,7 +34477,7 @@ _loop0_162_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33968,9 +34494,9 @@ _loop0_162_rule(Parser *p) return _seq; } -// _loop0_163: param_no_default +// _loop0_165: param_no_default static asdl_seq * -_loop0_163_rule(Parser *p) +_loop0_165_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33996,7 +34522,7 @@ _loop0_163_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; while ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -34019,7 +34545,7 @@ _loop0_163_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_163[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34036,9 +34562,9 @@ _loop0_163_rule(Parser *p) return _seq; } -// _loop0_164: param_no_default +// _loop0_166: param_no_default static asdl_seq * -_loop0_164_rule(Parser *p) +_loop0_166_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34064,7 +34590,7 @@ _loop0_164_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; while ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -34087,7 +34613,7 @@ _loop0_164_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_164[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34104,9 +34630,9 @@ _loop0_164_rule(Parser *p) return _seq; } -// _loop1_165: param_no_default +// _loop1_167: param_no_default static asdl_seq * -_loop1_165_rule(Parser *p) +_loop1_167_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34132,7 +34658,7 @@ _loop1_165_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; while ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -34155,7 +34681,7 @@ _loop1_165_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_165[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -34177,9 +34703,9 @@ _loop1_165_rule(Parser *p) return _seq; } -// _tmp_166: slash_no_default | slash_with_default +// _tmp_168: slash_no_default | slash_with_default static void * -_tmp_166_rule(Parser *p) +_tmp_168_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34196,18 +34722,18 @@ _tmp_166_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); asdl_arg_seq* slash_no_default_var; if ( (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); _res = slash_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); } { // slash_with_default @@ -34215,18 +34741,18 @@ _tmp_166_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); SlashWithDefault* slash_with_default_var; if ( (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default ) { - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); _res = slash_with_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } _res = NULL; @@ -34235,9 +34761,9 @@ _tmp_166_rule(Parser *p) return _res; } -// _loop0_167: param_maybe_default +// _loop0_169: param_maybe_default static asdl_seq * -_loop0_167_rule(Parser *p) +_loop0_169_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34263,7 +34789,7 @@ _loop0_167_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -34286,7 +34812,7 @@ _loop0_167_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_167[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34303,9 +34829,9 @@ _loop0_167_rule(Parser *p) return _seq; } -// _tmp_168: ',' | param_no_default +// _tmp_170: ',' | param_no_default static void * -_tmp_168_rule(Parser *p) +_tmp_170_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34322,18 +34848,18 @@ _tmp_168_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // param_no_default @@ -34341,18 +34867,18 @@ _tmp_168_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; if ( (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); _res = param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } _res = NULL; @@ -34361,9 +34887,9 @@ _tmp_168_rule(Parser *p) return _res; } -// _loop0_169: param_maybe_default +// _loop0_171: param_maybe_default static asdl_seq * -_loop0_169_rule(Parser *p) +_loop0_171_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34389,7 +34915,7 @@ _loop0_169_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -34412,7 +34938,7 @@ _loop0_169_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_171[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34429,9 +34955,9 @@ _loop0_169_rule(Parser *p) return _seq; } -// _loop1_170: param_maybe_default +// _loop1_172: param_maybe_default static asdl_seq * -_loop1_170_rule(Parser *p) +_loop1_172_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34457,7 +34983,7 @@ _loop1_170_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -34480,7 +35006,7 @@ _loop1_170_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_170[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -34502,9 +35028,9 @@ _loop1_170_rule(Parser *p) return _seq; } -// _tmp_171: ')' | ',' +// _tmp_173: ')' | ',' static void * -_tmp_171_rule(Parser *p) +_tmp_173_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34521,18 +35047,18 @@ _tmp_171_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' @@ -34540,18 +35066,18 @@ _tmp_171_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -34560,9 +35086,9 @@ _tmp_171_rule(Parser *p) return _res; } -// _tmp_172: ')' | ',' (')' | '**') +// _tmp_174: ')' | ',' (')' | '**') static void * -_tmp_172_rule(Parser *p) +_tmp_174_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34579,18 +35105,18 @@ _tmp_172_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -34598,21 +35124,21 @@ _tmp_172_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_240_var; + void *_tmp_242_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_240_var = _tmp_240_rule(p)) // ')' | '**' + (_tmp_242_var = _tmp_242_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_240_var); + D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_242_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -34621,9 +35147,9 @@ _tmp_172_rule(Parser *p) return _res; } -// _tmp_173: param_no_default | ',' +// _tmp_175: param_no_default | ',' static void * -_tmp_173_rule(Parser *p) +_tmp_175_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34640,18 +35166,18 @@ _tmp_173_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; if ( (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); _res = param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } { // ',' @@ -34659,18 +35185,18 @@ _tmp_173_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -34679,9 +35205,9 @@ _tmp_173_rule(Parser *p) return _res; } -// _loop0_174: param_maybe_default +// _loop0_176: param_maybe_default static asdl_seq * -_loop0_174_rule(Parser *p) +_loop0_176_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34707,7 +35233,7 @@ _loop0_174_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -34730,7 +35256,7 @@ _loop0_174_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_174[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_176[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34747,9 +35273,9 @@ _loop0_174_rule(Parser *p) return _seq; } -// _tmp_175: param_no_default | ',' +// _tmp_177: param_no_default | ',' static void * -_tmp_175_rule(Parser *p) +_tmp_177_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34766,18 +35292,18 @@ _tmp_175_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; if ( (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); _res = param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } { // ',' @@ -34785,18 +35311,18 @@ _tmp_175_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -34805,9 +35331,9 @@ _tmp_175_rule(Parser *p) return _res; } -// _tmp_176: '*' | '**' | '/' +// _tmp_178: '*' | '**' | '/' static void * -_tmp_176_rule(Parser *p) +_tmp_178_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34824,18 +35350,18 @@ _tmp_176_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -34843,18 +35369,18 @@ _tmp_176_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } { // '/' @@ -34862,18 +35388,18 @@ _tmp_176_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 17)) // token='/' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); } _res = NULL; @@ -34882,9 +35408,9 @@ _tmp_176_rule(Parser *p) return _res; } -// _loop1_177: param_with_default +// _loop1_179: param_with_default static asdl_seq * -_loop1_177_rule(Parser *p) +_loop1_179_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34910,7 +35436,7 @@ _loop1_177_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); + D(fprintf(stderr, "%*c> _loop1_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -34933,7 +35459,7 @@ _loop1_177_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_177[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -34955,9 +35481,9 @@ _loop1_177_rule(Parser *p) return _seq; } -// _tmp_178: lambda_slash_no_default | lambda_slash_with_default +// _tmp_180: lambda_slash_no_default | lambda_slash_with_default static void * -_tmp_178_rule(Parser *p) +_tmp_180_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34974,18 +35500,18 @@ _tmp_178_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); asdl_arg_seq* lambda_slash_no_default_var; if ( (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); _res = lambda_slash_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default")); } { // lambda_slash_with_default @@ -34993,18 +35519,18 @@ _tmp_178_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); SlashWithDefault* lambda_slash_with_default_var; if ( (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); _res = lambda_slash_with_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); } _res = NULL; @@ -35013,9 +35539,9 @@ _tmp_178_rule(Parser *p) return _res; } -// _loop0_179: lambda_param_maybe_default +// _loop0_181: lambda_param_maybe_default static asdl_seq * -_loop0_179_rule(Parser *p) +_loop0_181_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35041,7 +35567,7 @@ _loop0_179_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -35064,7 +35590,7 @@ _loop0_179_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_179[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35081,9 +35607,9 @@ _loop0_179_rule(Parser *p) return _seq; } -// _loop0_180: lambda_param_no_default +// _loop0_182: lambda_param_no_default static asdl_seq * -_loop0_180_rule(Parser *p) +_loop0_182_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35109,7 +35635,7 @@ _loop0_180_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -35132,7 +35658,7 @@ _loop0_180_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_180[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35149,9 +35675,9 @@ _loop0_180_rule(Parser *p) return _seq; } -// _loop0_181: lambda_param_no_default +// _loop0_183: lambda_param_no_default static asdl_seq * -_loop0_181_rule(Parser *p) +_loop0_183_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35177,7 +35703,7 @@ _loop0_181_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -35200,7 +35726,7 @@ _loop0_181_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_181[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35217,9 +35743,9 @@ _loop0_181_rule(Parser *p) return _seq; } -// _loop0_183: ',' lambda_param +// _loop0_185: ',' lambda_param static asdl_seq * -_loop0_183_rule(Parser *p) +_loop0_185_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35245,7 +35771,7 @@ _loop0_183_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); + D(fprintf(stderr, "%*c> _loop0_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); Token * _literal; arg_ty elem; while ( @@ -35277,7 +35803,7 @@ _loop0_183_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_183[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_185[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' lambda_param")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35294,9 +35820,9 @@ _loop0_183_rule(Parser *p) return _seq; } -// _gather_182: lambda_param _loop0_183 +// _gather_184: lambda_param _loop0_185 static asdl_seq * -_gather_182_rule(Parser *p) +_gather_184_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35308,27 +35834,27 @@ _gather_182_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // lambda_param _loop0_183 + { // lambda_param _loop0_185 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_183")); + D(fprintf(stderr, "%*c> _gather_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_185")); arg_ty elem; asdl_seq * seq; if ( (elem = lambda_param_rule(p)) // lambda_param && - (seq = _loop0_183_rule(p)) // _loop0_183 + (seq = _loop0_185_rule(p)) // _loop0_185 ) { - D(fprintf(stderr, "%*c+ _gather_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_183")); + D(fprintf(stderr, "%*c+ _gather_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_185")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_182[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_183")); + D(fprintf(stderr, "%*c%s _gather_184[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_185")); } _res = NULL; done: @@ -35336,9 +35862,9 @@ _gather_182_rule(Parser *p) return _res; } -// _tmp_184: lambda_slash_no_default | lambda_slash_with_default +// _tmp_186: lambda_slash_no_default | lambda_slash_with_default static void * -_tmp_184_rule(Parser *p) +_tmp_186_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35355,18 +35881,18 @@ _tmp_184_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); + D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); asdl_arg_seq* lambda_slash_no_default_var; if ( (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); + D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); _res = lambda_slash_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default")); } { // lambda_slash_with_default @@ -35374,18 +35900,18 @@ _tmp_184_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); SlashWithDefault* lambda_slash_with_default_var; if ( (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default ) { - D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); _res = lambda_slash_with_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); } _res = NULL; @@ -35394,9 +35920,9 @@ _tmp_184_rule(Parser *p) return _res; } -// _loop0_185: lambda_param_maybe_default +// _loop0_187: lambda_param_maybe_default static asdl_seq * -_loop0_185_rule(Parser *p) +_loop0_187_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35422,7 +35948,7 @@ _loop0_185_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -35445,7 +35971,7 @@ _loop0_185_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_185[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_187[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35462,9 +35988,9 @@ _loop0_185_rule(Parser *p) return _seq; } -// _tmp_186: ',' | lambda_param_no_default +// _tmp_188: ',' | lambda_param_no_default static void * -_tmp_186_rule(Parser *p) +_tmp_188_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35481,18 +36007,18 @@ _tmp_186_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_188[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // lambda_param_no_default @@ -35500,18 +36026,18 @@ _tmp_186_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; if ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); _res = lambda_param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_188[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } _res = NULL; @@ -35520,9 +36046,9 @@ _tmp_186_rule(Parser *p) return _res; } -// _loop0_187: lambda_param_maybe_default +// _loop0_189: lambda_param_maybe_default static asdl_seq * -_loop0_187_rule(Parser *p) +_loop0_189_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35548,7 +36074,7 @@ _loop0_187_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -35571,7 +36097,7 @@ _loop0_187_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_187[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_189[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35588,9 +36114,9 @@ _loop0_187_rule(Parser *p) return _seq; } -// _loop1_188: lambda_param_maybe_default +// _loop1_190: lambda_param_maybe_default static asdl_seq * -_loop1_188_rule(Parser *p) +_loop1_190_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35616,7 +36142,7 @@ _loop1_188_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -35639,7 +36165,7 @@ _loop1_188_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_188[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_190[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -35661,9 +36187,9 @@ _loop1_188_rule(Parser *p) return _seq; } -// _loop1_189: lambda_param_with_default +// _loop1_191: lambda_param_with_default static asdl_seq * -_loop1_189_rule(Parser *p) +_loop1_191_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35689,7 +36215,7 @@ _loop1_189_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -35712,7 +36238,7 @@ _loop1_189_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_189[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_191[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -35734,9 +36260,9 @@ _loop1_189_rule(Parser *p) return _seq; } -// _tmp_190: ':' | ',' (':' | '**') +// _tmp_192: ':' | ',' (':' | '**') static void * -_tmp_190_rule(Parser *p) +_tmp_192_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35753,18 +36279,18 @@ _tmp_190_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_192[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_190[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_192[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -35772,21 +36298,21 @@ _tmp_190_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_241_var; + void *_tmp_243_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_241_var = _tmp_241_rule(p)) // ':' | '**' + (_tmp_243_var = _tmp_243_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_190[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_241_var); + D(fprintf(stderr, "%*c+ _tmp_192[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_243_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_190[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_192[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -35795,9 +36321,9 @@ _tmp_190_rule(Parser *p) return _res; } -// _tmp_191: lambda_param_no_default | ',' +// _tmp_193: lambda_param_no_default | ',' static void * -_tmp_191_rule(Parser *p) +_tmp_193_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35814,18 +36340,18 @@ _tmp_191_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; if ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); _res = lambda_param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } { // ',' @@ -35833,18 +36359,18 @@ _tmp_191_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -35853,9 +36379,9 @@ _tmp_191_rule(Parser *p) return _res; } -// _loop0_192: lambda_param_maybe_default +// _loop0_194: lambda_param_maybe_default static asdl_seq * -_loop0_192_rule(Parser *p) +_loop0_194_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35881,7 +36407,7 @@ _loop0_192_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -35904,7 +36430,7 @@ _loop0_192_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_192[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_194[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35921,9 +36447,9 @@ _loop0_192_rule(Parser *p) return _seq; } -// _tmp_193: lambda_param_no_default | ',' +// _tmp_195: lambda_param_no_default | ',' static void * -_tmp_193_rule(Parser *p) +_tmp_195_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35940,18 +36466,18 @@ _tmp_193_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; if ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); _res = lambda_param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } { // ',' @@ -35959,18 +36485,18 @@ _tmp_193_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -35979,9 +36505,9 @@ _tmp_193_rule(Parser *p) return _res; } -// _tmp_194: '*' | '**' | '/' +// _tmp_196: '*' | '**' | '/' static void * -_tmp_194_rule(Parser *p) +_tmp_196_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35998,18 +36524,18 @@ _tmp_194_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_194[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_194[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -36017,18 +36543,18 @@ _tmp_194_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_194[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_194[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } { // '/' @@ -36036,18 +36562,18 @@ _tmp_194_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 17)) // token='/' ) { - D(fprintf(stderr, "%*c+ _tmp_194[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_194[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); } _res = NULL; @@ -36056,9 +36582,9 @@ _tmp_194_rule(Parser *p) return _res; } -// _tmp_195: ',' | ')' | ':' +// _tmp_197: ',' | ')' | ':' static void * -_tmp_195_rule(Parser *p) +_tmp_197_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36075,18 +36601,18 @@ _tmp_195_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // ')' @@ -36094,18 +36620,18 @@ _tmp_195_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ':' @@ -36113,18 +36639,18 @@ _tmp_195_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } _res = NULL; @@ -36133,9 +36659,9 @@ _tmp_195_rule(Parser *p) return _res; } -// _loop0_197: ',' (expression ['as' star_target]) +// _loop0_199: ',' (expression ['as' star_target]) static asdl_seq * -_loop0_197_rule(Parser *p) +_loop0_199_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36161,13 +36687,13 @@ _loop0_197_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_242_rule(p)) // expression ['as' star_target] + (elem = _tmp_244_rule(p)) // expression ['as' star_target] ) { _res = elem; @@ -36193,7 +36719,7 @@ _loop0_197_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_197[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_199[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36210,9 +36736,9 @@ _loop0_197_rule(Parser *p) return _seq; } -// _gather_196: (expression ['as' star_target]) _loop0_197 +// _gather_198: (expression ['as' star_target]) _loop0_199 static asdl_seq * -_gather_196_rule(Parser *p) +_gather_198_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36224,27 +36750,27 @@ _gather_196_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expression ['as' star_target]) _loop0_197 + { // (expression ['as' star_target]) _loop0_199 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_197")); + D(fprintf(stderr, "%*c> _gather_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_199")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_242_rule(p)) // expression ['as' star_target] + (elem = _tmp_244_rule(p)) // expression ['as' star_target] && - (seq = _loop0_197_rule(p)) // _loop0_197 + (seq = _loop0_199_rule(p)) // _loop0_199 ) { - D(fprintf(stderr, "%*c+ _gather_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_197")); + D(fprintf(stderr, "%*c+ _gather_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_199")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_196[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_197")); + D(fprintf(stderr, "%*c%s _gather_198[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_199")); } _res = NULL; done: @@ -36252,9 +36778,9 @@ _gather_196_rule(Parser *p) return _res; } -// _loop0_199: ',' (expressions ['as' star_target]) +// _loop0_201: ',' (expressions ['as' star_target]) static asdl_seq * -_loop0_199_rule(Parser *p) +_loop0_201_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36280,13 +36806,13 @@ _loop0_199_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_243_rule(p)) // expressions ['as' star_target] + (elem = _tmp_245_rule(p)) // expressions ['as' star_target] ) { _res = elem; @@ -36312,7 +36838,7 @@ _loop0_199_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_199[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_201[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36329,9 +36855,9 @@ _loop0_199_rule(Parser *p) return _seq; } -// _gather_198: (expressions ['as' star_target]) _loop0_199 +// _gather_200: (expressions ['as' star_target]) _loop0_201 static asdl_seq * -_gather_198_rule(Parser *p) +_gather_200_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36343,27 +36869,27 @@ _gather_198_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expressions ['as' star_target]) _loop0_199 + { // (expressions ['as' star_target]) _loop0_201 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_199")); + D(fprintf(stderr, "%*c> _gather_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_201")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_243_rule(p)) // expressions ['as' star_target] + (elem = _tmp_245_rule(p)) // expressions ['as' star_target] && - (seq = _loop0_199_rule(p)) // _loop0_199 + (seq = _loop0_201_rule(p)) // _loop0_201 ) { - D(fprintf(stderr, "%*c+ _gather_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_199")); + D(fprintf(stderr, "%*c+ _gather_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_201")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_198[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_199")); + D(fprintf(stderr, "%*c%s _gather_200[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_201")); } _res = NULL; done: @@ -36371,9 +36897,9 @@ _gather_198_rule(Parser *p) return _res; } -// _loop0_201: ',' (expression ['as' star_target]) +// _loop0_203: ',' (expression ['as' star_target]) static asdl_seq * -_loop0_201_rule(Parser *p) +_loop0_203_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36399,13 +36925,13 @@ _loop0_201_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_203[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_244_rule(p)) // expression ['as' star_target] + (elem = _tmp_246_rule(p)) // expression ['as' star_target] ) { _res = elem; @@ -36431,7 +36957,7 @@ _loop0_201_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_201[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_203[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36448,9 +36974,9 @@ _loop0_201_rule(Parser *p) return _seq; } -// _gather_200: (expression ['as' star_target]) _loop0_201 +// _gather_202: (expression ['as' star_target]) _loop0_203 static asdl_seq * -_gather_200_rule(Parser *p) +_gather_202_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36462,27 +36988,27 @@ _gather_200_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expression ['as' star_target]) _loop0_201 + { // (expression ['as' star_target]) _loop0_203 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_201")); + D(fprintf(stderr, "%*c> _gather_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_203")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_244_rule(p)) // expression ['as' star_target] + (elem = _tmp_246_rule(p)) // expression ['as' star_target] && - (seq = _loop0_201_rule(p)) // _loop0_201 + (seq = _loop0_203_rule(p)) // _loop0_203 ) { - D(fprintf(stderr, "%*c+ _gather_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_201")); + D(fprintf(stderr, "%*c+ _gather_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_203")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_200[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_201")); + D(fprintf(stderr, "%*c%s _gather_202[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_203")); } _res = NULL; done: @@ -36490,9 +37016,9 @@ _gather_200_rule(Parser *p) return _res; } -// _loop0_203: ',' (expressions ['as' star_target]) +// _loop0_205: ',' (expressions ['as' star_target]) static asdl_seq * -_loop0_203_rule(Parser *p) +_loop0_205_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36518,13 +37044,13 @@ _loop0_203_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_203[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_245_rule(p)) // expressions ['as' star_target] + (elem = _tmp_247_rule(p)) // expressions ['as' star_target] ) { _res = elem; @@ -36550,7 +37076,7 @@ _loop0_203_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_203[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_205[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36567,9 +37093,9 @@ _loop0_203_rule(Parser *p) return _seq; } -// _gather_202: (expressions ['as' star_target]) _loop0_203 +// _gather_204: (expressions ['as' star_target]) _loop0_205 static asdl_seq * -_gather_202_rule(Parser *p) +_gather_204_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36581,27 +37107,27 @@ _gather_202_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expressions ['as' star_target]) _loop0_203 + { // (expressions ['as' star_target]) _loop0_205 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_203")); + D(fprintf(stderr, "%*c> _gather_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_205")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_245_rule(p)) // expressions ['as' star_target] + (elem = _tmp_247_rule(p)) // expressions ['as' star_target] && - (seq = _loop0_203_rule(p)) // _loop0_203 + (seq = _loop0_205_rule(p)) // _loop0_205 ) { - D(fprintf(stderr, "%*c+ _gather_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_203")); + D(fprintf(stderr, "%*c+ _gather_204[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_205")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_202[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_203")); + D(fprintf(stderr, "%*c%s _gather_204[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_205")); } _res = NULL; done: @@ -36609,9 +37135,9 @@ _gather_202_rule(Parser *p) return _res; } -// _tmp_204: 'except' | 'finally' +// _tmp_206: 'except' | 'finally' static void * -_tmp_204_rule(Parser *p) +_tmp_206_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36628,18 +37154,18 @@ _tmp_204_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); + D(fprintf(stderr, "%*c> _tmp_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 636)) // token='except' ) { - D(fprintf(stderr, "%*c+ _tmp_204[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); + D(fprintf(stderr, "%*c+ _tmp_206[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_204[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_206[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except'")); } { // 'finally' @@ -36647,18 +37173,18 @@ _tmp_204_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); + D(fprintf(stderr, "%*c> _tmp_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 632)) // token='finally' ) { - D(fprintf(stderr, "%*c+ _tmp_204[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); + D(fprintf(stderr, "%*c+ _tmp_206[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_204[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_206[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally'")); } _res = NULL; @@ -36667,9 +37193,9 @@ _tmp_204_rule(Parser *p) return _res; } -// _loop0_205: block +// _loop0_207: block static asdl_seq * -_loop0_205_rule(Parser *p) +_loop0_207_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36695,7 +37221,7 @@ _loop0_205_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); + D(fprintf(stderr, "%*c> _loop0_207[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); asdl_stmt_seq* block_var; while ( (block_var = block_rule(p)) // block @@ -36718,7 +37244,7 @@ _loop0_205_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_205[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_207[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "block")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36735,9 +37261,9 @@ _loop0_205_rule(Parser *p) return _seq; } -// _loop1_206: except_block +// _loop1_208: except_block static asdl_seq * -_loop1_206_rule(Parser *p) +_loop1_208_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36763,7 +37289,7 @@ _loop1_206_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); + D(fprintf(stderr, "%*c> _loop1_208[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); excepthandler_ty except_block_var; while ( (except_block_var = except_block_rule(p)) // except_block @@ -36786,7 +37312,7 @@ _loop1_206_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_206[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_208[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); } if (_n == 0 || p->error_indicator) { @@ -36808,9 +37334,9 @@ _loop1_206_rule(Parser *p) return _seq; } -// _tmp_207: 'as' NAME +// _tmp_209: 'as' NAME static void * -_tmp_207_rule(Parser *p) +_tmp_209_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36827,7 +37353,7 @@ _tmp_207_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_207[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_209[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -36836,12 +37362,12 @@ _tmp_207_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_207[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_209[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_207[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_209[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -36850,9 +37376,9 @@ _tmp_207_rule(Parser *p) return _res; } -// _loop0_208: block +// _loop0_210: block static asdl_seq * -_loop0_208_rule(Parser *p) +_loop0_210_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36878,7 +37404,7 @@ _loop0_208_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_208[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); + D(fprintf(stderr, "%*c> _loop0_210[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); asdl_stmt_seq* block_var; while ( (block_var = block_rule(p)) // block @@ -36901,7 +37427,7 @@ _loop0_208_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_208[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_210[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "block")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36918,9 +37444,9 @@ _loop0_208_rule(Parser *p) return _seq; } -// _loop1_209: except_star_block +// _loop1_211: except_star_block static asdl_seq * -_loop1_209_rule(Parser *p) +_loop1_211_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36946,7 +37472,7 @@ _loop1_209_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_209[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); + D(fprintf(stderr, "%*c> _loop1_211[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); excepthandler_ty except_star_block_var; while ( (except_star_block_var = except_star_block_rule(p)) // except_star_block @@ -36969,7 +37495,7 @@ _loop1_209_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_209[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_211[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_star_block")); } if (_n == 0 || p->error_indicator) { @@ -36991,9 +37517,9 @@ _loop1_209_rule(Parser *p) return _seq; } -// _tmp_210: expression ['as' NAME] +// _tmp_212: expression ['as' NAME] static void * -_tmp_210_rule(Parser *p) +_tmp_212_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37010,22 +37536,22 @@ _tmp_210_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_210[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); + D(fprintf(stderr, "%*c> _tmp_212[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_246_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var = _tmp_248_rule(p), !p->error_indicator) // ['as' NAME] ) { - D(fprintf(stderr, "%*c+ _tmp_210[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); + D(fprintf(stderr, "%*c+ _tmp_212[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_210[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_212[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' NAME]")); } _res = NULL; @@ -37034,9 +37560,9 @@ _tmp_210_rule(Parser *p) return _res; } -// _tmp_211: 'as' NAME +// _tmp_213: 'as' NAME static void * -_tmp_211_rule(Parser *p) +_tmp_213_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37053,7 +37579,7 @@ _tmp_211_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_211[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_213[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -37062,12 +37588,12 @@ _tmp_211_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_211[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_213[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_211[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_213[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -37076,9 +37602,9 @@ _tmp_211_rule(Parser *p) return _res; } -// _tmp_212: 'as' NAME +// _tmp_214: 'as' NAME static void * -_tmp_212_rule(Parser *p) +_tmp_214_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37095,7 +37621,7 @@ _tmp_212_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_212[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_214[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -37104,12 +37630,12 @@ _tmp_212_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_212[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_214[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_212[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_214[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -37118,9 +37644,9 @@ _tmp_212_rule(Parser *p) return _res; } -// _tmp_213: NEWLINE | ':' +// _tmp_215: NEWLINE | ':' static void * -_tmp_213_rule(Parser *p) +_tmp_215_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37137,18 +37663,18 @@ _tmp_213_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_213[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); Token * newline_var; if ( (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_213[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_215[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); _res = newline_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_213[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_215[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); } { // ':' @@ -37156,18 +37682,18 @@ _tmp_213_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_213[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_213[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_215[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_213[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_215[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } _res = NULL; @@ -37176,9 +37702,9 @@ _tmp_213_rule(Parser *p) return _res; } -// _tmp_214: 'as' NAME +// _tmp_216: 'as' NAME static void * -_tmp_214_rule(Parser *p) +_tmp_216_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37195,7 +37721,7 @@ _tmp_214_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_214[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_216[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -37204,12 +37730,12 @@ _tmp_214_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_214[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_216[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_214[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_216[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -37218,9 +37744,9 @@ _tmp_214_rule(Parser *p) return _res; } -// _tmp_215: 'as' NAME +// _tmp_217: 'as' NAME static void * -_tmp_215_rule(Parser *p) +_tmp_217_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37237,7 +37763,7 @@ _tmp_215_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_217[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -37246,12 +37772,12 @@ _tmp_215_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_215[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_217[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_215[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_217[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -37260,9 +37786,9 @@ _tmp_215_rule(Parser *p) return _res; } -// _tmp_216: positional_patterns ',' +// _tmp_218: positional_patterns ',' static void * -_tmp_216_rule(Parser *p) +_tmp_218_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37279,7 +37805,7 @@ _tmp_216_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_216[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); + D(fprintf(stderr, "%*c> _tmp_218[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); Token * _literal; asdl_pattern_seq* positional_patterns_var; if ( @@ -37288,12 +37814,12 @@ _tmp_216_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_216[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); + D(fprintf(stderr, "%*c+ _tmp_218[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); _res = _PyPegen_dummy_name(p, positional_patterns_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_216[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_218[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "positional_patterns ','")); } _res = NULL; @@ -37302,9 +37828,9 @@ _tmp_216_rule(Parser *p) return _res; } -// _tmp_217: '->' expression +// _tmp_219: '->' expression static void * -_tmp_217_rule(Parser *p) +_tmp_219_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37321,7 +37847,7 @@ _tmp_217_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_217[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c> _tmp_219[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty expression_var; if ( @@ -37330,12 +37856,12 @@ _tmp_217_rule(Parser *p) (expression_var = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_217[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); + D(fprintf(stderr, "%*c+ _tmp_219[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = _PyPegen_dummy_name(p, _literal, expression_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_217[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_219[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -37344,9 +37870,9 @@ _tmp_217_rule(Parser *p) return _res; } -// _tmp_218: '(' arguments? ')' +// _tmp_220: '(' arguments? ')' static void * -_tmp_218_rule(Parser *p) +_tmp_220_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37363,7 +37889,7 @@ _tmp_218_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_218[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_220[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -37376,12 +37902,12 @@ _tmp_218_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_218[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_220[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = _PyPegen_dummy_name(p, _literal, _opt_var, _literal_1); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_218[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_220[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -37390,9 +37916,9 @@ _tmp_218_rule(Parser *p) return _res; } -// _tmp_219: '(' arguments? ')' +// _tmp_221: '(' arguments? ')' static void * -_tmp_219_rule(Parser *p) +_tmp_221_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37409,7 +37935,7 @@ _tmp_219_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_219[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c> _tmp_221[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -37422,12 +37948,12 @@ _tmp_219_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_219[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); + D(fprintf(stderr, "%*c+ _tmp_221[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = _PyPegen_dummy_name(p, _literal, _opt_var, _literal_1); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_219[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_221[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -37436,9 +37962,9 @@ _tmp_219_rule(Parser *p) return _res; } -// _loop0_221: ',' double_starred_kvpair +// _loop0_223: ',' double_starred_kvpair static asdl_seq * -_loop0_221_rule(Parser *p) +_loop0_223_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37464,7 +37990,7 @@ _loop0_221_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_221[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); + D(fprintf(stderr, "%*c> _loop0_223[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -37496,7 +38022,7 @@ _loop0_221_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_221[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_223[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -37513,9 +38039,9 @@ _loop0_221_rule(Parser *p) return _seq; } -// _gather_220: double_starred_kvpair _loop0_221 +// _gather_222: double_starred_kvpair _loop0_223 static asdl_seq * -_gather_220_rule(Parser *p) +_gather_222_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37527,27 +38053,27 @@ _gather_220_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // double_starred_kvpair _loop0_221 + { // double_starred_kvpair _loop0_223 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_220[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_221")); + D(fprintf(stderr, "%*c> _gather_222[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_223")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && - (seq = _loop0_221_rule(p)) // _loop0_221 + (seq = _loop0_223_rule(p)) // _loop0_223 ) { - D(fprintf(stderr, "%*c+ _gather_220[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_221")); + D(fprintf(stderr, "%*c+ _gather_222[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_223")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_220[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_221")); + D(fprintf(stderr, "%*c%s _gather_222[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_223")); } _res = NULL; done: @@ -37555,9 +38081,9 @@ _gather_220_rule(Parser *p) return _res; } -// _tmp_222: '}' | ',' +// _tmp_224: '}' | ',' static void * -_tmp_222_rule(Parser *p) +_tmp_224_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37574,18 +38100,18 @@ _tmp_222_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_222[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ _tmp_222[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_222[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); } { // ',' @@ -37593,18 +38119,18 @@ _tmp_222_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_222[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_222[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_222[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -37613,9 +38139,9 @@ _tmp_222_rule(Parser *p) return _res; } -// _tmp_223: '}' | ',' +// _tmp_225: '}' | ',' static void * -_tmp_223_rule(Parser *p) +_tmp_225_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37632,18 +38158,18 @@ _tmp_223_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_223[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ _tmp_223[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_223[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); } { // ',' @@ -37651,18 +38177,18 @@ _tmp_223_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_223[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_223[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_223[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -37671,9 +38197,9 @@ _tmp_223_rule(Parser *p) return _res; } -// _tmp_224: star_targets '=' +// _tmp_226: star_targets '=' static void * -_tmp_224_rule(Parser *p) +_tmp_226_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37690,7 +38216,7 @@ _tmp_224_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_226[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -37699,7 +38225,7 @@ _tmp_224_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_226[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -37709,7 +38235,7 @@ _tmp_224_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_226[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -37718,9 +38244,9 @@ _tmp_224_rule(Parser *p) return _res; } -// _tmp_225: '.' | '...' +// _tmp_227: '.' | '...' static void * -_tmp_225_rule(Parser *p) +_tmp_227_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37737,18 +38263,18 @@ _tmp_225_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -37756,18 +38282,18 @@ _tmp_225_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -37776,9 +38302,9 @@ _tmp_225_rule(Parser *p) return _res; } -// _tmp_226: '.' | '...' +// _tmp_228: '.' | '...' static void * -_tmp_226_rule(Parser *p) +_tmp_228_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37795,18 +38321,18 @@ _tmp_226_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_226[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_226[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_226[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -37814,18 +38340,18 @@ _tmp_226_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_226[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_226[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_226[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -37834,9 +38360,9 @@ _tmp_226_rule(Parser *p) return _res; } -// _tmp_227: '@' named_expression NEWLINE +// _tmp_229: '@' named_expression NEWLINE static void * -_tmp_227_rule(Parser *p) +_tmp_229_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37853,7 +38379,7 @@ _tmp_227_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -37865,7 +38391,7 @@ _tmp_227_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -37875,7 +38401,7 @@ _tmp_227_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -37884,9 +38410,9 @@ _tmp_227_rule(Parser *p) return _res; } -// _tmp_228: ',' expression +// _tmp_230: ',' expression static void * -_tmp_228_rule(Parser *p) +_tmp_230_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37903,7 +38429,7 @@ _tmp_228_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -37912,7 +38438,7 @@ _tmp_228_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -37922,7 +38448,7 @@ _tmp_228_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -37931,9 +38457,9 @@ _tmp_228_rule(Parser *p) return _res; } -// _tmp_229: ',' star_expression +// _tmp_231: ',' star_expression static void * -_tmp_229_rule(Parser *p) +_tmp_231_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37950,7 +38476,7 @@ _tmp_229_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -37959,7 +38485,7 @@ _tmp_229_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -37969,7 +38495,7 @@ _tmp_229_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -37978,9 +38504,9 @@ _tmp_229_rule(Parser *p) return _res; } -// _tmp_230: 'or' conjunction +// _tmp_232: 'or' conjunction static void * -_tmp_230_rule(Parser *p) +_tmp_232_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37997,7 +38523,7 @@ _tmp_230_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -38006,7 +38532,7 @@ _tmp_230_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -38016,7 +38542,7 @@ _tmp_230_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -38025,9 +38551,9 @@ _tmp_230_rule(Parser *p) return _res; } -// _tmp_231: 'and' inversion +// _tmp_233: 'and' inversion static void * -_tmp_231_rule(Parser *p) +_tmp_233_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38044,7 +38570,7 @@ _tmp_231_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_233[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -38053,7 +38579,7 @@ _tmp_231_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_233[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -38063,7 +38589,7 @@ _tmp_231_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_233[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -38072,9 +38598,9 @@ _tmp_231_rule(Parser *p) return _res; } -// _tmp_232: slice | starred_expression +// _tmp_234: slice | starred_expression static void * -_tmp_232_rule(Parser *p) +_tmp_234_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38091,18 +38617,18 @@ _tmp_232_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); + D(fprintf(stderr, "%*c> _tmp_234[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); expr_ty slice_var; if ( (slice_var = slice_rule(p)) // slice ) { - D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); + D(fprintf(stderr, "%*c+ _tmp_234[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); _res = slice_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_234[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice")); } { // starred_expression @@ -38110,18 +38636,18 @@ _tmp_232_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_234[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); expr_ty starred_expression_var; if ( (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_234[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_234[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } _res = NULL; @@ -38130,9 +38656,9 @@ _tmp_232_rule(Parser *p) return _res; } -// _tmp_233: 'if' disjunction +// _tmp_235: 'if' disjunction static void * -_tmp_233_rule(Parser *p) +_tmp_235_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38149,7 +38675,7 @@ _tmp_233_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_233[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -38158,7 +38684,7 @@ _tmp_233_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_233[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -38168,7 +38694,7 @@ _tmp_233_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_233[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_235[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -38177,9 +38703,9 @@ _tmp_233_rule(Parser *p) return _res; } -// _tmp_234: 'if' disjunction +// _tmp_236: 'if' disjunction static void * -_tmp_234_rule(Parser *p) +_tmp_236_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38196,7 +38722,7 @@ _tmp_234_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_234[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_236[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -38205,7 +38731,7 @@ _tmp_234_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_234[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_236[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -38215,7 +38741,7 @@ _tmp_234_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_234[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_236[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -38224,9 +38750,9 @@ _tmp_234_rule(Parser *p) return _res; } -// _tmp_235: starred_expression | (assignment_expression | expression !':=') !'=' +// _tmp_237: starred_expression | (assignment_expression | expression !':=') !'=' static void * -_tmp_235_rule(Parser *p) +_tmp_237_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38243,18 +38769,18 @@ _tmp_235_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); expr_ty starred_expression_var; if ( (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_235[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } { // (assignment_expression | expression !':=') !'=' @@ -38262,20 +38788,20 @@ _tmp_235_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - void *_tmp_247_var; + D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + void *_tmp_249_var; if ( - (_tmp_247_var = _tmp_247_rule(p)) // assignment_expression | expression !':=' + (_tmp_249_var = _tmp_249_rule(p)) // assignment_expression | expression !':=' && _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - _res = _tmp_247_var; + D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + _res = _tmp_249_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_235[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(assignment_expression | expression !':=') !'='")); } _res = NULL; @@ -38284,9 +38810,9 @@ _tmp_235_rule(Parser *p) return _res; } -// _tmp_236: ',' star_target +// _tmp_238: ',' star_target static void * -_tmp_236_rule(Parser *p) +_tmp_238_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38303,7 +38829,7 @@ _tmp_236_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_236[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_238[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -38312,7 +38838,7 @@ _tmp_236_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_236[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_238[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -38322,7 +38848,7 @@ _tmp_236_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_236[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_238[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -38331,9 +38857,9 @@ _tmp_236_rule(Parser *p) return _res; } -// _tmp_237: ',' star_target +// _tmp_239: ',' star_target static void * -_tmp_237_rule(Parser *p) +_tmp_239_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38350,7 +38876,7 @@ _tmp_237_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_239[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -38359,7 +38885,7 @@ _tmp_237_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_239[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -38369,7 +38895,7 @@ _tmp_237_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_239[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -38378,9 +38904,9 @@ _tmp_237_rule(Parser *p) return _res; } -// _tmp_238: star_targets '=' +// _tmp_240: star_targets '=' static void * -_tmp_238_rule(Parser *p) +_tmp_240_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38397,7 +38923,7 @@ _tmp_238_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_238[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -38406,12 +38932,12 @@ _tmp_238_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_238[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_240[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = _PyPegen_dummy_name(p, star_targets_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_238[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_240[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -38420,9 +38946,9 @@ _tmp_238_rule(Parser *p) return _res; } -// _tmp_239: star_targets '=' +// _tmp_241: star_targets '=' static void * -_tmp_239_rule(Parser *p) +_tmp_241_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38439,7 +38965,7 @@ _tmp_239_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_239[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -38448,12 +38974,12 @@ _tmp_239_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_239[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = _PyPegen_dummy_name(p, star_targets_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_239[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -38462,9 +38988,9 @@ _tmp_239_rule(Parser *p) return _res; } -// _tmp_240: ')' | '**' +// _tmp_242: ')' | '**' static void * -_tmp_240_rule(Parser *p) +_tmp_242_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38481,18 +39007,18 @@ _tmp_240_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_240[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_242[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_240[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_242[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -38500,18 +39026,18 @@ _tmp_240_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_240[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_242[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_240[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_242[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -38520,9 +39046,9 @@ _tmp_240_rule(Parser *p) return _res; } -// _tmp_241: ':' | '**' +// _tmp_243: ':' | '**' static void * -_tmp_241_rule(Parser *p) +_tmp_243_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38539,18 +39065,18 @@ _tmp_241_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -38558,18 +39084,18 @@ _tmp_241_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -38578,9 +39104,9 @@ _tmp_241_rule(Parser *p) return _res; } -// _tmp_242: expression ['as' star_target] +// _tmp_244: expression ['as' star_target] static void * -_tmp_242_rule(Parser *p) +_tmp_244_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38597,22 +39123,22 @@ _tmp_242_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_244[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_248_rule(p), !p->error_indicator) // ['as' star_target] + (_opt_var = _tmp_250_rule(p), !p->error_indicator) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_242[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_244[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_242[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_244[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); } _res = NULL; @@ -38621,9 +39147,9 @@ _tmp_242_rule(Parser *p) return _res; } -// _tmp_243: expressions ['as' star_target] +// _tmp_245: expressions ['as' star_target] static void * -_tmp_243_rule(Parser *p) +_tmp_245_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38640,22 +39166,22 @@ _tmp_243_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_245[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expressions_var; if ( (expressions_var = expressions_rule(p)) // expressions && - (_opt_var = _tmp_249_rule(p), !p->error_indicator) // ['as' star_target] + (_opt_var = _tmp_251_rule(p), !p->error_indicator) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_245[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_245[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); } _res = NULL; @@ -38664,9 +39190,9 @@ _tmp_243_rule(Parser *p) return _res; } -// _tmp_244: expression ['as' star_target] +// _tmp_246: expression ['as' star_target] static void * -_tmp_244_rule(Parser *p) +_tmp_246_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38683,22 +39209,22 @@ _tmp_244_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_244[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_246[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_250_rule(p), !p->error_indicator) // ['as' star_target] + (_opt_var = _tmp_252_rule(p), !p->error_indicator) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_244[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_246[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_244[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_246[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); } _res = NULL; @@ -38707,9 +39233,9 @@ _tmp_244_rule(Parser *p) return _res; } -// _tmp_245: expressions ['as' star_target] +// _tmp_247: expressions ['as' star_target] static void * -_tmp_245_rule(Parser *p) +_tmp_247_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38726,22 +39252,22 @@ _tmp_245_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_245[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expressions_var; if ( (expressions_var = expressions_rule(p)) // expressions && - (_opt_var = _tmp_251_rule(p), !p->error_indicator) // ['as' star_target] + (_opt_var = _tmp_253_rule(p), !p->error_indicator) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_245[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_245[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); } _res = NULL; @@ -38750,9 +39276,9 @@ _tmp_245_rule(Parser *p) return _res; } -// _tmp_246: 'as' NAME +// _tmp_248: 'as' NAME static void * -_tmp_246_rule(Parser *p) +_tmp_248_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38769,7 +39295,7 @@ _tmp_246_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_246[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_248[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -38778,12 +39304,12 @@ _tmp_246_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_246[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_248[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_246[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_248[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -38792,9 +39318,9 @@ _tmp_246_rule(Parser *p) return _res; } -// _tmp_247: assignment_expression | expression !':=' +// _tmp_249: assignment_expression | expression !':=' static void * -_tmp_247_rule(Parser *p) +_tmp_249_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38811,18 +39337,18 @@ _tmp_247_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); expr_ty assignment_expression_var; if ( (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression ) { - D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); + D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); _res = assignment_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); } { // expression !':=' @@ -38830,7 +39356,7 @@ _tmp_247_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); + D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression @@ -38838,12 +39364,12 @@ _tmp_247_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); + D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); _res = expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); } _res = NULL; @@ -38852,9 +39378,9 @@ _tmp_247_rule(Parser *p) return _res; } -// _tmp_248: 'as' star_target +// _tmp_250: 'as' star_target static void * -_tmp_248_rule(Parser *p) +_tmp_250_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38871,7 +39397,7 @@ _tmp_248_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_248[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_250[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -38880,12 +39406,12 @@ _tmp_248_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_248[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_250[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_248[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_250[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; @@ -38894,9 +39420,9 @@ _tmp_248_rule(Parser *p) return _res; } -// _tmp_249: 'as' star_target +// _tmp_251: 'as' star_target static void * -_tmp_249_rule(Parser *p) +_tmp_251_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38913,7 +39439,7 @@ _tmp_249_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_251[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -38922,12 +39448,12 @@ _tmp_249_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_251[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_251[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; @@ -38936,9 +39462,9 @@ _tmp_249_rule(Parser *p) return _res; } -// _tmp_250: 'as' star_target +// _tmp_252: 'as' star_target static void * -_tmp_250_rule(Parser *p) +_tmp_252_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38955,7 +39481,7 @@ _tmp_250_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_250[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_252[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -38964,12 +39490,12 @@ _tmp_250_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_250[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_252[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_250[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_252[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; @@ -38978,9 +39504,9 @@ _tmp_250_rule(Parser *p) return _res; } -// _tmp_251: 'as' star_target +// _tmp_253: 'as' star_target static void * -_tmp_251_rule(Parser *p) +_tmp_253_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38997,7 +39523,7 @@ _tmp_251_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_251[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_253[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( @@ -39006,12 +39532,12 @@ _tmp_251_rule(Parser *p) (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_251[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_253[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_251[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_253[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 6c878474afb192..c30f3f851e37cb 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -131,6 +131,7 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->Not_type); Py_CLEAR(state->Or_singleton); Py_CLEAR(state->Or_type); + Py_CLEAR(state->ParamSpec_type); Py_CLEAR(state->Pass_type); Py_CLEAR(state->Pow_singleton); Py_CLEAR(state->Pow_type); @@ -150,7 +151,10 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->TryStar_type); Py_CLEAR(state->Try_type); Py_CLEAR(state->Tuple_type); + Py_CLEAR(state->TypeAlias_type); Py_CLEAR(state->TypeIgnore_type); + Py_CLEAR(state->TypeVarTuple_type); + Py_CLEAR(state->TypeVar_type); Py_CLEAR(state->UAdd_singleton); Py_CLEAR(state->UAdd_type); Py_CLEAR(state->USub_singleton); @@ -179,6 +183,7 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->bases); Py_CLEAR(state->body); Py_CLEAR(state->boolop_type); + Py_CLEAR(state->bound); Py_CLEAR(state->cases); Py_CLEAR(state->cause); Py_CLEAR(state->cls); @@ -256,6 +261,8 @@ void _PyAST_Fini(PyInterpreterState *interp) Py_CLEAR(state->type_comment); Py_CLEAR(state->type_ignore_type); Py_CLEAR(state->type_ignores); + Py_CLEAR(state->typeparam_type); + Py_CLEAR(state->typeparams); Py_CLEAR(state->unaryop_type); Py_CLEAR(state->upper); Py_CLEAR(state->value); @@ -289,6 +296,7 @@ static int init_identifiers(struct ast_state *state) if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return 0; if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return 0; if ((state->body = PyUnicode_InternFromString("body")) == NULL) return 0; + if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return 0; if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return 0; if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return 0; if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return 0; @@ -354,6 +362,7 @@ static int init_identifiers(struct ast_state *state) if ((state->type = PyUnicode_InternFromString("type")) == NULL) return 0; if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return 0; if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return 0; + if ((state->typeparams = PyUnicode_InternFromString("typeparams")) == NULL) return 0; if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return 0; if ((state->value = PyUnicode_InternFromString("value")) == NULL) return 0; if ((state->values = PyUnicode_InternFromString("values")) == NULL) return 0; @@ -374,6 +383,7 @@ GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty) GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty) +GENERATE_ASDL_SEQ_CONSTRUCTOR(typeparam, typeparam_ty) static PyObject* ast2obj_mod(struct ast_state *state, void*); static const char * const Module_fields[]={ @@ -399,6 +409,7 @@ static const char * const stmt_attributes[] = { static PyObject* ast2obj_stmt(struct ast_state *state, void*); static const char * const FunctionDef_fields[]={ "name", + "typeparams", "args", "body", "decorator_list", @@ -407,6 +418,7 @@ static const char * const FunctionDef_fields[]={ }; static const char * const AsyncFunctionDef_fields[]={ "name", + "typeparams", "args", "body", "decorator_list", @@ -415,6 +427,7 @@ static const char * const AsyncFunctionDef_fields[]={ }; static const char * const ClassDef_fields[]={ "name", + "typeparams", "bases", "keywords", "body", @@ -431,6 +444,11 @@ static const char * const Assign_fields[]={ "value", "type_comment", }; +static const char * const TypeAlias_fields[]={ + "name", + "typeparams", + "value", +}; static const char * const AugAssign_fields[]={ "target", "op", @@ -757,6 +775,23 @@ static const char * const TypeIgnore_fields[]={ "lineno", "tag", }; +static const char * const typeparam_attributes[] = { + "lineno", + "col_offset", + "end_lineno", + "end_col_offset", +}; +static PyObject* ast2obj_typeparam(struct ast_state *state, void*); +static const char * const TypeVar_fields[]={ + "name", + "bound", +}; +static const char * const ParamSpec_fields[]={ + "name", +}; +static const char * const TypeVarTuple_fields[]={ + "name", +}; @@ -1134,12 +1169,13 @@ init_types(struct ast_state *state) "FunctionType(expr* argtypes, expr returns)"); if (!state->FunctionType_type) return 0; state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0, - "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n" - " | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n" - " | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)\n" + "stmt = FunctionDef(identifier name, typeparam* typeparams, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n" + " | AsyncFunctionDef(identifier name, typeparam* typeparams, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)\n" + " | ClassDef(identifier name, typeparam* typeparams, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)\n" " | Return(expr? value)\n" " | Delete(expr* targets)\n" " | Assign(expr* targets, expr value, string? type_comment)\n" + " | TypeAlias(identifier name, typeparam* typeparams, expr value)\n" " | AugAssign(expr target, operator op, expr value)\n" " | AnnAssign(expr target, expr annotation, expr? value, int simple)\n" " | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n" @@ -1169,8 +1205,8 @@ init_types(struct ast_state *state) -1) return 0; state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type, - FunctionDef_fields, 6, - "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)"); + FunctionDef_fields, 7, + "FunctionDef(identifier name, typeparam* typeparams, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)"); if (!state->FunctionDef_type) return 0; if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) == -1) @@ -1180,8 +1216,8 @@ init_types(struct ast_state *state) return 0; state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef", state->stmt_type, - AsyncFunctionDef_fields, 6, - "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)"); + AsyncFunctionDef_fields, 7, + "AsyncFunctionDef(identifier name, typeparam* typeparams, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment)"); if (!state->AsyncFunctionDef_type) return 0; if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None) == -1) @@ -1190,8 +1226,8 @@ init_types(struct ast_state *state) Py_None) == -1) return 0; state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type, - ClassDef_fields, 5, - "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)"); + ClassDef_fields, 6, + "ClassDef(identifier name, typeparam* typeparams, expr* bases, keyword* keywords, stmt* body, expr* decorator_list)"); if (!state->ClassDef_type) return 0; state->Return_type = make_type(state, "Return", state->stmt_type, Return_fields, 1, @@ -1210,6 +1246,10 @@ init_types(struct ast_state *state) if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) == -1) return 0; + state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type, + TypeAlias_fields, 3, + "TypeAlias(identifier name, typeparam* typeparams, expr value)"); + if (!state->TypeAlias_type) return 0; state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type, AugAssign_fields, 3, "AugAssign(expr target, operator op, expr value)"); @@ -1854,6 +1894,36 @@ init_types(struct ast_state *state) TypeIgnore_fields, 2, "TypeIgnore(int lineno, string tag)"); if (!state->TypeIgnore_type) return 0; + state->typeparam_type = make_type(state, "typeparam", state->AST_type, + NULL, 0, + "typeparam = TypeVar(identifier name, expr? bound)\n" + " | ParamSpec(identifier name)\n" + " | TypeVarTuple(identifier name)"); + if (!state->typeparam_type) return 0; + if (!add_attributes(state, state->typeparam_type, typeparam_attributes, 4)) + return 0; + if (PyObject_SetAttr(state->typeparam_type, state->end_lineno, Py_None) == + -1) + return 0; + if (PyObject_SetAttr(state->typeparam_type, state->end_col_offset, Py_None) + == -1) + return 0; + state->TypeVar_type = make_type(state, "TypeVar", state->typeparam_type, + TypeVar_fields, 2, + "TypeVar(identifier name, expr? bound)"); + if (!state->TypeVar_type) return 0; + if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1) + return 0; + state->ParamSpec_type = make_type(state, "ParamSpec", + state->typeparam_type, ParamSpec_fields, + 1, + "ParamSpec(identifier name)"); + if (!state->ParamSpec_type) return 0; + state->TypeVarTuple_type = make_type(state, "TypeVarTuple", + state->typeparam_type, + TypeVarTuple_fields, 1, + "TypeVarTuple(identifier name)"); + if (!state->TypeVarTuple_type) return 0; state->recursion_depth = 0; state->recursion_limit = 0; @@ -1897,6 +1967,8 @@ static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out, PyArena* arena); static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty* out, PyArena* arena); +static int obj2ast_typeparam(struct ast_state *state, PyObject* obj, + typeparam_ty* out, PyArena* arena); mod_ty _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores, @@ -1960,10 +2032,11 @@ _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena) } stmt_ty -_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body, - asdl_expr_seq * decorator_list, expr_ty returns, string - type_comment, int lineno, int col_offset, int end_lineno, - int end_col_offset, PyArena *arena) +_PyAST_FunctionDef(identifier name, asdl_typeparam_seq * typeparams, + arguments_ty args, asdl_stmt_seq * body, asdl_expr_seq * + decorator_list, expr_ty returns, string type_comment, int + lineno, int col_offset, int end_lineno, int end_col_offset, + PyArena *arena) { stmt_ty p; if (!name) { @@ -1981,6 +2054,7 @@ _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body, return NULL; p->kind = FunctionDef_kind; p->v.FunctionDef.name = name; + p->v.FunctionDef.typeparams = typeparams; p->v.FunctionDef.args = args; p->v.FunctionDef.body = body; p->v.FunctionDef.decorator_list = decorator_list; @@ -1994,10 +2068,11 @@ _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body, } stmt_ty -_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * - body, asdl_expr_seq * decorator_list, expr_ty returns, - string type_comment, int lineno, int col_offset, int - end_lineno, int end_col_offset, PyArena *arena) +_PyAST_AsyncFunctionDef(identifier name, asdl_typeparam_seq * typeparams, + arguments_ty args, asdl_stmt_seq * body, asdl_expr_seq + * decorator_list, expr_ty returns, string type_comment, + int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena) { stmt_ty p; if (!name) { @@ -2015,6 +2090,7 @@ _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * return NULL; p->kind = AsyncFunctionDef_kind; p->v.AsyncFunctionDef.name = name; + p->v.AsyncFunctionDef.typeparams = typeparams; p->v.AsyncFunctionDef.args = args; p->v.AsyncFunctionDef.body = body; p->v.AsyncFunctionDef.decorator_list = decorator_list; @@ -2028,10 +2104,10 @@ _PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * } stmt_ty -_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq * - keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list, - int lineno, int col_offset, int end_lineno, int end_col_offset, - PyArena *arena) +_PyAST_ClassDef(identifier name, asdl_typeparam_seq * typeparams, asdl_expr_seq + * bases, asdl_keyword_seq * keywords, asdl_stmt_seq * body, + asdl_expr_seq * decorator_list, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena) { stmt_ty p; if (!name) { @@ -2044,6 +2120,7 @@ _PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq * return NULL; p->kind = ClassDef_kind; p->v.ClassDef.name = name; + p->v.ClassDef.typeparams = typeparams; p->v.ClassDef.bases = bases; p->v.ClassDef.keywords = keywords; p->v.ClassDef.body = body; @@ -2114,6 +2191,36 @@ _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int return p; } +stmt_ty +_PyAST_TypeAlias(identifier name, asdl_typeparam_seq * typeparams, expr_ty + value, int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena) +{ + stmt_ty p; + if (!name) { + PyErr_SetString(PyExc_ValueError, + "field 'name' is required for TypeAlias"); + return NULL; + } + if (!value) { + PyErr_SetString(PyExc_ValueError, + "field 'value' is required for TypeAlias"); + return NULL; + } + p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = TypeAlias_kind; + p->v.TypeAlias.name = name; + p->v.TypeAlias.typeparams = typeparams; + p->v.TypeAlias.value = value; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + stmt_ty _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) @@ -3606,6 +3713,73 @@ _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena) return p; } +typeparam_ty +_PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena) +{ + typeparam_ty p; + if (!name) { + PyErr_SetString(PyExc_ValueError, + "field 'name' is required for TypeVar"); + return NULL; + } + p = (typeparam_ty)_PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = TypeVar_kind; + p->v.TypeVar.name = name; + p->v.TypeVar.bound = bound; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + +typeparam_ty +_PyAST_ParamSpec(identifier name, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena) +{ + typeparam_ty p; + if (!name) { + PyErr_SetString(PyExc_ValueError, + "field 'name' is required for ParamSpec"); + return NULL; + } + p = (typeparam_ty)_PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = ParamSpec_kind; + p->v.ParamSpec.name = name; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + +typeparam_ty +_PyAST_TypeVarTuple(identifier name, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena) +{ + typeparam_ty p; + if (!name) { + PyErr_SetString(PyExc_ValueError, + "field 'name' is required for TypeVarTuple"); + return NULL; + } + p = (typeparam_ty)_PyArena_Malloc(arena, sizeof(*p)); + if (!p) + return NULL; + p->kind = TypeVarTuple_kind; + p->v.TypeVarTuple.name = name; + p->lineno = lineno; + p->col_offset = col_offset; + p->end_lineno = end_lineno; + p->end_col_offset = end_col_offset; + return p; +} + PyObject* ast2obj_mod(struct ast_state *state, void* _o) @@ -3708,6 +3882,12 @@ ast2obj_stmt(struct ast_state *state, void* _o) if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; Py_DECREF(value); + value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.typeparams, + ast2obj_typeparam); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->typeparams, value) == -1) + goto failed; + Py_DECREF(value); value = ast2obj_arguments(state, o->v.FunctionDef.args); if (!value) goto failed; if (PyObject_SetAttr(result, state->args, value) == -1) @@ -3745,6 +3925,13 @@ ast2obj_stmt(struct ast_state *state, void* _o) if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; Py_DECREF(value); + value = ast2obj_list(state, + (asdl_seq*)o->v.AsyncFunctionDef.typeparams, + ast2obj_typeparam); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->typeparams, value) == -1) + goto failed; + Py_DECREF(value); value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args); if (!value) goto failed; if (PyObject_SetAttr(result, state->args, value) == -1) @@ -3783,6 +3970,12 @@ ast2obj_stmt(struct ast_state *state, void* _o) if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; Py_DECREF(value); + value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.typeparams, + ast2obj_typeparam); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->typeparams, value) == -1) + goto failed; + Py_DECREF(value); value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases, ast2obj_expr); if (!value) goto failed; @@ -3850,6 +4043,27 @@ ast2obj_stmt(struct ast_state *state, void* _o) goto failed; Py_DECREF(value); break; + case TypeAlias_kind: + tp = (PyTypeObject *)state->TypeAlias_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_identifier(state, o->v.TypeAlias.name); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->name, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.typeparams, + ast2obj_typeparam); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->typeparams, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_expr(state, o->v.TypeAlias.value); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->value, value) == -1) + goto failed; + Py_DECREF(value); + break; case AugAssign_kind: tp = (PyTypeObject *)state->AugAssign_type; result = PyType_GenericNew(tp, NULL, NULL); @@ -5441,6 +5655,85 @@ ast2obj_type_ignore(struct ast_state *state, void* _o) return NULL; } +PyObject* +ast2obj_typeparam(struct ast_state *state, void* _o) +{ + typeparam_ty o = (typeparam_ty)_o; + PyObject *result = NULL, *value = NULL; + PyTypeObject *tp; + if (!o) { + Py_RETURN_NONE; + } + if (++state->recursion_depth > state->recursion_limit) { + PyErr_SetString(PyExc_RecursionError, + "maximum recursion depth exceeded during ast construction"); + return 0; + } + switch (o->kind) { + case TypeVar_kind: + tp = (PyTypeObject *)state->TypeVar_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_identifier(state, o->v.TypeVar.name); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->name, value) == -1) + goto failed; + Py_DECREF(value); + value = ast2obj_expr(state, o->v.TypeVar.bound); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->bound, value) == -1) + goto failed; + Py_DECREF(value); + break; + case ParamSpec_kind: + tp = (PyTypeObject *)state->ParamSpec_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_identifier(state, o->v.ParamSpec.name); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->name, value) == -1) + goto failed; + Py_DECREF(value); + break; + case TypeVarTuple_kind: + tp = (PyTypeObject *)state->TypeVarTuple_type; + result = PyType_GenericNew(tp, NULL, NULL); + if (!result) goto failed; + value = ast2obj_identifier(state, o->v.TypeVarTuple.name); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->name, value) == -1) + goto failed; + Py_DECREF(value); + break; + } + value = ast2obj_int(state, o->lineno); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->lineno, value) < 0) + goto failed; + Py_DECREF(value); + value = ast2obj_int(state, o->col_offset); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->col_offset, value) < 0) + goto failed; + Py_DECREF(value); + value = ast2obj_int(state, o->end_lineno); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->end_lineno, value) < 0) + goto failed; + Py_DECREF(value); + value = ast2obj_int(state, o->end_col_offset); + if (!value) goto failed; + if (PyObject_SetAttr(result, state->end_col_offset, value) < 0) + goto failed; + Py_DECREF(value); + state->recursion_depth--; + return result; +failed: + Py_XDECREF(value); + Py_XDECREF(result); + return NULL; +} + int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena) @@ -5781,6 +6074,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* } if (isinstance) { identifier name; + asdl_typeparam_seq* typeparams; arguments_ty args; asdl_stmt_seq* body; asdl_expr_seq* decorator_list; @@ -5804,6 +6098,42 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (res != 0) goto failed; Py_CLEAR(tmp); } + if (_PyObject_LookupAttr(obj, state->typeparams, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"typeparams\" missing from FunctionDef"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "FunctionDef field \"typeparams\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + typeparams = _Py_asdl_typeparam_seq_new(len, arena); + if (typeparams == NULL) goto failed; + for (i = 0; i < len; i++) { + typeparam_ty val; + PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i)); + if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) { + goto failed; + } + res = obj2ast_typeparam(state, tmp2, &val, arena); + _Py_LeaveRecursiveCall(); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"typeparams\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(typeparams, i, val); + } + Py_CLEAR(tmp); + } if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) { return 1; } @@ -5927,9 +6257,9 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (res != 0) goto failed; Py_CLEAR(tmp); } - *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns, - type_comment, lineno, col_offset, end_lineno, - end_col_offset, arena); + *out = _PyAST_FunctionDef(name, typeparams, args, body, decorator_list, + returns, type_comment, lineno, col_offset, + end_lineno, end_col_offset, arena); if (*out == NULL) goto failed; return 0; } @@ -5940,6 +6270,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* } if (isinstance) { identifier name; + asdl_typeparam_seq* typeparams; arguments_ty args; asdl_stmt_seq* body; asdl_expr_seq* decorator_list; @@ -5963,6 +6294,42 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (res != 0) goto failed; Py_CLEAR(tmp); } + if (_PyObject_LookupAttr(obj, state->typeparams, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"typeparams\" missing from AsyncFunctionDef"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"typeparams\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + typeparams = _Py_asdl_typeparam_seq_new(len, arena); + if (typeparams == NULL) goto failed; + for (i = 0; i < len; i++) { + typeparam_ty val; + PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i)); + if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) { + goto failed; + } + res = obj2ast_typeparam(state, tmp2, &val, arena); + _Py_LeaveRecursiveCall(); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"typeparams\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(typeparams, i, val); + } + Py_CLEAR(tmp); + } if (_PyObject_LookupAttr(obj, state->args, &tmp) < 0) { return 1; } @@ -6086,10 +6453,10 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (res != 0) goto failed; Py_CLEAR(tmp); } - *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list, - returns, type_comment, lineno, - col_offset, end_lineno, end_col_offset, - arena); + *out = _PyAST_AsyncFunctionDef(name, typeparams, args, body, + decorator_list, returns, type_comment, + lineno, col_offset, end_lineno, + end_col_offset, arena); if (*out == NULL) goto failed; return 0; } @@ -6100,6 +6467,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* } if (isinstance) { identifier name; + asdl_typeparam_seq* typeparams; asdl_expr_seq* bases; asdl_keyword_seq* keywords; asdl_stmt_seq* body; @@ -6122,6 +6490,42 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (res != 0) goto failed; Py_CLEAR(tmp); } + if (_PyObject_LookupAttr(obj, state->typeparams, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"typeparams\" missing from ClassDef"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "ClassDef field \"typeparams\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + typeparams = _Py_asdl_typeparam_seq_new(len, arena); + if (typeparams == NULL) goto failed; + for (i = 0; i < len; i++) { + typeparam_ty val; + PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i)); + if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) { + goto failed; + } + res = obj2ast_typeparam(state, tmp2, &val, arena); + _Py_LeaveRecursiveCall(); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"typeparams\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(typeparams, i, val); + } + Py_CLEAR(tmp); + } if (_PyObject_LookupAttr(obj, state->bases, &tmp) < 0) { return 1; } @@ -6266,9 +6670,9 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* } Py_CLEAR(tmp); } - *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list, - lineno, col_offset, end_lineno, end_col_offset, - arena); + *out = _PyAST_ClassDef(name, typeparams, bases, keywords, body, + decorator_list, lineno, col_offset, end_lineno, + end_col_offset, arena); if (*out == NULL) goto failed; return 0; } @@ -6436,6 +6840,91 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (*out == NULL) goto failed; return 0; } + tp = state->TypeAlias_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + identifier name; + asdl_typeparam_seq* typeparams; + expr_ty value; + + if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) { + goto failed; + } + res = obj2ast_identifier(state, tmp, &name, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->typeparams, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"typeparams\" missing from TypeAlias"); + return 1; + } + else { + int res; + Py_ssize_t len; + Py_ssize_t i; + if (!PyList_Check(tmp)) { + PyErr_Format(PyExc_TypeError, "TypeAlias field \"typeparams\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp))); + goto failed; + } + len = PyList_GET_SIZE(tmp); + typeparams = _Py_asdl_typeparam_seq_new(len, arena); + if (typeparams == NULL) goto failed; + for (i = 0; i < len; i++) { + typeparam_ty val; + PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i)); + if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) { + goto failed; + } + res = obj2ast_typeparam(state, tmp2, &val, arena); + _Py_LeaveRecursiveCall(); + Py_DECREF(tmp2); + if (res != 0) goto failed; + if (len != PyList_GET_SIZE(tmp)) { + PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"typeparams\" changed size during iteration"); + goto failed; + } + asdl_seq_SET(typeparams, i, val); + } + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->value, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) { + goto failed; + } + res = obj2ast_expr(state, tmp, &value, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + *out = _PyAST_TypeAlias(name, typeparams, value, lineno, col_offset, + end_lineno, end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } tp = state->AugAssign_type; isinstance = PyObject_IsInstance(obj, tp); if (isinstance == -1) { @@ -11803,6 +12292,206 @@ obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty* return 1; } +int +obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, + PyArena* arena) +{ + int isinstance; + + PyObject *tmp = NULL; + PyObject *tp; + int lineno; + int col_offset; + int end_lineno; + int end_col_offset; + + if (obj == Py_None) { + *out = NULL; + return 0; + } + if (_PyObject_LookupAttr(obj, state->lineno, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from typeparam"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'typeparam' node")) { + goto failed; + } + res = obj2ast_int(state, tmp, &lineno, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->col_offset, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from typeparam"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'typeparam' node")) { + goto failed; + } + res = obj2ast_int(state, tmp, &col_offset, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->end_lineno, &tmp) < 0) { + return 1; + } + if (tmp == NULL || tmp == Py_None) { + Py_CLEAR(tmp); + end_lineno = lineno; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'typeparam' node")) { + goto failed; + } + res = obj2ast_int(state, tmp, &end_lineno, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->end_col_offset, &tmp) < 0) { + return 1; + } + if (tmp == NULL || tmp == Py_None) { + Py_CLEAR(tmp); + end_col_offset = col_offset; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'typeparam' node")) { + goto failed; + } + res = obj2ast_int(state, tmp, &end_col_offset, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + tp = state->TypeVar_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + identifier name; + expr_ty bound; + + if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) { + goto failed; + } + res = obj2ast_identifier(state, tmp, &name, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + if (_PyObject_LookupAttr(obj, state->bound, &tmp) < 0) { + return 1; + } + if (tmp == NULL || tmp == Py_None) { + Py_CLEAR(tmp); + bound = NULL; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) { + goto failed; + } + res = obj2ast_expr(state, tmp, &bound, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + *out = _PyAST_TypeVar(name, bound, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } + tp = state->ParamSpec_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + identifier name; + + if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) { + goto failed; + } + res = obj2ast_identifier(state, tmp, &name, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + *out = _PyAST_ParamSpec(name, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } + tp = state->TypeVarTuple_type; + isinstance = PyObject_IsInstance(obj, tp); + if (isinstance == -1) { + return 1; + } + if (isinstance) { + identifier name; + + if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { + return 1; + } + if (tmp == NULL) { + PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple"); + return 1; + } + else { + int res; + if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) { + goto failed; + } + res = obj2ast_identifier(state, tmp, &name, arena); + _Py_LeaveRecursiveCall(); + if (res != 0) goto failed; + Py_CLEAR(tmp); + } + *out = _PyAST_TypeVarTuple(name, lineno, col_offset, end_lineno, + end_col_offset, arena); + if (*out == NULL) goto failed; + return 0; + } + + PyErr_Format(PyExc_TypeError, "expected some sort of typeparam, but got %R", obj); + failed: + Py_XDECREF(tmp); + return 1; +} + static int astmodule_exec(PyObject *m) @@ -11861,6 +12550,9 @@ astmodule_exec(PyObject *m) if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) { return -1; } + if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) { + return -1; + } if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) { return -1; } @@ -12188,6 +12880,19 @@ astmodule_exec(PyObject *m) if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) { return -1; } + if (PyModule_AddObjectRef(m, "typeparam", state->typeparam_type) < 0) { + return -1; + } + if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) { + return -1; + } + if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) { + return -1; + } + if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0) + { + return -1; + } return 0; } diff --git a/Python/ast.c b/Python/ast.c index 50fc8e01fb3f69..c3e202047f8705 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -746,6 +746,9 @@ validate_stmt(struct validator *state, stmt_ty stmt) validate_expr(state, stmt->v.AnnAssign.value, Load)) && validate_expr(state, stmt->v.AnnAssign.annotation, Load); break; + case TypeAlias_kind: + ret = validate_expr(state, stmt->v.TypeAlias.value, Load); + break; case For_kind: ret = validate_expr(state, stmt->v.For.target, Store) && validate_expr(state, stmt->v.For.iter, Load) && diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 8270fa8e372d93..53984be7655c14 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -923,6 +923,9 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) } CALL_OPT(astfold_expr, expr_ty, node_->v.AnnAssign.value); break; + case TypeAlias_kind: + CALL(astfold_expr, expr_ty, node_->v.TypeAlias.value); + break; case For_kind: CALL(astfold_expr, expr_ty, node_->v.For.target); CALL(astfold_expr, expr_ty, node_->v.For.iter); From 609ac0d8edd844da7be22339c589047d79789a48 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 12 Apr 2023 18:30:15 -0700 Subject: [PATCH 002/200] Run Tools/build/generate_global_objects.py This fixes compilation for me locally. --- Include/internal/pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + Include/internal/pycore_runtime_init_generated.h | 1 + Include/internal/pycore_unicodeobject_generated.h | 3 +++ 4 files changed, 6 insertions(+) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 6c974c253ceaca..64c1d3e0348244 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -1121,6 +1121,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reducer_override)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(registry)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(rel_tol)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(release)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reload)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(repl)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(replace)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 6b862ca17dd33e..750e58007523b5 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -607,6 +607,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(reducer_override) STRUCT_FOR_ID(registry) STRUCT_FOR_ID(rel_tol) + STRUCT_FOR_ID(release) STRUCT_FOR_ID(reload) STRUCT_FOR_ID(repl) STRUCT_FOR_ID(replace) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index ef76de1b320571..3a346531c9795d 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -1113,6 +1113,7 @@ extern "C" { INIT_ID(reducer_override), \ INIT_ID(registry), \ INIT_ID(rel_tol), \ + INIT_ID(release), \ INIT_ID(reload), \ INIT_ID(repl), \ INIT_ID(replace), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 01b3cb7606f767..2c593f1a01dee6 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1674,6 +1674,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(rel_tol); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(release); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(reload); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); From 7a5e457b626c40f2487ad4ddc128a758a00a6ca9 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 12 Apr 2023 19:36:09 -0700 Subject: [PATCH 003/200] Basic C implementation of TypeVar, TypeVarTuple, ParamSpec This isn't fully functional, but it should be enough to unblock work on the runtime. I'll update this PR as I implement more. --- .../pycore_global_objects_fini_generated.h | 5 + Include/internal/pycore_global_strings.h | 5 + .../internal/pycore_runtime_init_generated.h | 5 + Include/internal/pycore_typevarobject.h | 22 ++ .../internal/pycore_unicodeobject_generated.h | 15 + Makefile.pre.in | 2 + Objects/clinic/typevarobject.c.h | 294 ++++++++++++++ Objects/typevarobject.c | 365 ++++++++++++++++++ PCbuild/pythoncore.vcxproj | 2 + PCbuild/pythoncore.vcxproj.filters | 6 + Python/bltinmodule.c | 5 + 11 files changed, 726 insertions(+) create mode 100644 Include/internal/pycore_typevarobject.h create mode 100644 Objects/clinic/typevarobject.c.h create mode 100644 Objects/typevarobject.c diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 64c1d3e0348244..270507dbb8f7a4 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -789,6 +789,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(attribute)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(authorizer_callback)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autocommit)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autovariance)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(b)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(backtick)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(base)); @@ -796,6 +797,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(big)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(binary_form)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(block)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(bound)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffer)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffer_callback)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(buffer_size)); @@ -848,13 +850,16 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(code)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(command)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(comment_factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(constraints)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(consts)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(context)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(contravariant)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cookie)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(copy)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(copyreg)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(coro)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(count)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(covariant)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(cwd)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(d)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(data)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 750e58007523b5..db7986d3686e18 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -275,6 +275,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(attribute) STRUCT_FOR_ID(authorizer_callback) STRUCT_FOR_ID(autocommit) + STRUCT_FOR_ID(autovariance) STRUCT_FOR_ID(b) STRUCT_FOR_ID(backtick) STRUCT_FOR_ID(base) @@ -282,6 +283,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(big) STRUCT_FOR_ID(binary_form) STRUCT_FOR_ID(block) + STRUCT_FOR_ID(bound) STRUCT_FOR_ID(buffer) STRUCT_FOR_ID(buffer_callback) STRUCT_FOR_ID(buffer_size) @@ -334,13 +336,16 @@ struct _Py_global_strings { STRUCT_FOR_ID(code) STRUCT_FOR_ID(command) STRUCT_FOR_ID(comment_factory) + STRUCT_FOR_ID(constraints) STRUCT_FOR_ID(consts) STRUCT_FOR_ID(context) + STRUCT_FOR_ID(contravariant) STRUCT_FOR_ID(cookie) STRUCT_FOR_ID(copy) STRUCT_FOR_ID(copyreg) STRUCT_FOR_ID(coro) STRUCT_FOR_ID(count) + STRUCT_FOR_ID(covariant) STRUCT_FOR_ID(cwd) STRUCT_FOR_ID(d) STRUCT_FOR_ID(data) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 3a346531c9795d..8c97833b8a9cb7 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -781,6 +781,7 @@ extern "C" { INIT_ID(attribute), \ INIT_ID(authorizer_callback), \ INIT_ID(autocommit), \ + INIT_ID(autovariance), \ INIT_ID(b), \ INIT_ID(backtick), \ INIT_ID(base), \ @@ -788,6 +789,7 @@ extern "C" { INIT_ID(big), \ INIT_ID(binary_form), \ INIT_ID(block), \ + INIT_ID(bound), \ INIT_ID(buffer), \ INIT_ID(buffer_callback), \ INIT_ID(buffer_size), \ @@ -840,13 +842,16 @@ extern "C" { INIT_ID(code), \ INIT_ID(command), \ INIT_ID(comment_factory), \ + INIT_ID(constraints), \ INIT_ID(consts), \ INIT_ID(context), \ + INIT_ID(contravariant), \ INIT_ID(cookie), \ INIT_ID(copy), \ INIT_ID(copyreg), \ INIT_ID(coro), \ INIT_ID(count), \ + INIT_ID(covariant), \ INIT_ID(cwd), \ INIT_ID(d), \ INIT_ID(data), \ diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h new file mode 100644 index 00000000000000..a4ce06fc8a09cc --- /dev/null +++ b/Include/internal/pycore_typevarobject.h @@ -0,0 +1,22 @@ +#ifndef Py_INTERNAL_TYPEVAROBJECT_H +#define Py_INTERNAL_TYPEVAROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +extern PyTypeObject _PyTypeVar_Type; +extern PyTypeObject _PyTypeVarTuple_Type; +extern PyTypeObject _PyParamSpec_Type; + +extern PyObject *_Py_make_typevar(const char *, PyObject *); +extern PyObject *_Py_make_paramspec(const char *); +extern PyObject *_Py_make_typevartuple(const char *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_TYPEVAROBJECT_H */ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 2c593f1a01dee6..f1db5380a53e24 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -678,6 +678,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(autocommit); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(autovariance); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(b); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); @@ -699,6 +702,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(block); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(bound); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(buffer); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); @@ -855,12 +861,18 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(comment_factory); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(constraints); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(consts); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(context); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(contravariant); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(cookie); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); @@ -876,6 +888,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(count); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(covariant); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(cwd); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Makefile.pre.in b/Makefile.pre.in index fefa5d4e8147bf..c9c45a2d6d5690 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -475,6 +475,7 @@ OBJECT_OBJS= \ Objects/structseq.o \ Objects/tupleobject.o \ Objects/typeobject.o \ + Objects/typevarobject.o \ Objects/unicodeobject.o \ Objects/unicodectype.o \ Objects/unionobject.o \ @@ -1731,6 +1732,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_tracemalloc.h \ $(srcdir)/Include/internal/pycore_tuple.h \ $(srcdir)/Include/internal/pycore_typeobject.h \ + $(srcdir)/Include/internal/pycore_typevarobject.h \ $(srcdir)/Include/internal/pycore_ucnhash.h \ $(srcdir)/Include/internal/pycore_unionobject.h \ $(srcdir)/Include/internal/pycore_unicodeobject.h \ diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h new file mode 100644 index 00000000000000..b70e57716855f7 --- /dev/null +++ b/Objects/clinic/typevarobject.c.h @@ -0,0 +1,294 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# include "pycore_gc.h" // PyGC_Head +# include "pycore_runtime.h" // _Py_ID() +#endif + + +PyDoc_STRVAR(typevar_new__doc__, +"typevar(name, *, bound=None, constraints=None, covariant=False,\n" +" contravariant=False, autovariance=False)\n" +"--\n" +"\n" +"Create a TypeVar."); + +static PyObject * +typevar_new_impl(PyTypeObject *type, const char *name, PyObject *bound, + PyObject *constraints, int covariant, int contravariant, + int autovariance); + +static PyObject * +typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 6 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(constraints), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", "bound", "constraints", "covariant", "contravariant", "autovariance", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "typevar", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[6]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + const char *name; + PyObject *bound = Py_None; + PyObject *constraints = Py_None; + int covariant = 0; + int contravariant = 0; + int autovariance = 0; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("typevar", "argument 'name'", "str", fastargs[0]); + goto exit; + } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + bound = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + constraints = fastargs[2]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + covariant = PyObject_IsTrue(fastargs[3]); + if (covariant < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[4]) { + contravariant = PyObject_IsTrue(fastargs[4]); + if (contravariant < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + autovariance = PyObject_IsTrue(fastargs[5]); + if (autovariance < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = typevar_new_impl(type, name, bound, constraints, covariant, contravariant, autovariance); + +exit: + return return_value; +} + +PyDoc_STRVAR(paramspec_new__doc__, +"paramspec(name, *, bound=None, covariant=False, contravariant=False,\n" +" autovariance=False)\n" +"--\n" +"\n" +"Create a ParamSpec object."); + +static PyObject * +paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, + int covariant, int contravariant, int autovariance); + +static PyObject * +paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 5 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "autovariance", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "paramspec", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[5]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + const char *name; + PyObject *bound = Py_None; + int covariant = 0; + int contravariant = 0; + int autovariance = 0; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("paramspec", "argument 'name'", "str", fastargs[0]); + goto exit; + } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + bound = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + covariant = PyObject_IsTrue(fastargs[2]); + if (covariant < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + contravariant = PyObject_IsTrue(fastargs[3]); + if (contravariant < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + autovariance = PyObject_IsTrue(fastargs[4]); + if (autovariance < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = paramspec_new_impl(type, name, bound, covariant, contravariant, autovariance); + +exit: + return return_value; +} + +PyDoc_STRVAR(typevartuple__doc__, +"typevartuple(name)\n" +"--\n" +"\n" +"Create a new TypeVarTuple with the given name."); + +static PyObject * +typevartuple_impl(PyTypeObject *type, const char *name); + +static PyObject * +typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(name), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "typevartuple", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + const char *name; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("typevartuple", "argument 'name'", "str", fastargs[0]); + goto exit; + } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + return_value = typevartuple_impl(type, name); + +exit: + return return_value; +} +/*[clinic end generated code: output=e500e924addebd33 input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c new file mode 100644 index 00000000000000..4586b0d3ce9a4b --- /dev/null +++ b/Objects/typevarobject.c @@ -0,0 +1,365 @@ +// TypeVar, TypeVarTuple, and ParamSpec +#include "Python.h" +#include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK +#include "pycore_typevarobject.h" +#include "structmember.h" + +/*[clinic input] +class typevar "typevarobject *" "&_PyTypeVar_Type" +class paramspec "paramspecobject *" "&_PyParamSpec_Type" +class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=d1b368d1521582f6]*/ + +#include "clinic/typevarobject.c.h" + +typedef struct { + PyObject_HEAD + const char *name; + PyObject *bound; + PyObject *constraints; + bool covariant; + bool contravariant; + bool autovariance; +} typevarobject; + +static void typevarobject_dealloc(PyObject *self) +{ + typevarobject *tv = (typevarobject *)self; + + _PyObject_GC_UNTRACK(self); + + free((void *)tv->name); + Py_XDECREF(tv->bound); + Py_XDECREF(tv->constraints); + + Py_TYPE(self)->tp_free(self); +} + +static int typevarobject_traverse(PyObject *self, visitproc visit, void *arg) +{ + typevarobject *tv = (typevarobject *)self; + Py_VISIT(tv->bound); + Py_VISIT(tv->constraints); + return 0; +} + +static PyObject *typevarobject_repr(PyObject *self) +{ + typevarobject *tv = (typevarobject *)self; + + if (tv->autovariance) { + return PyUnicode_FromFormat("%s", tv->name); + } + + char variance = tv->covariant ? '+' : tv->contravariant ? '-' : '~'; + return PyUnicode_FromFormat("%c%s", variance, tv->name); +} + +static PyMemberDef typevar_members[] = { + {"__name__", T_STRING, offsetof(typevarobject, name), READONLY}, + {"__bound__", T_OBJECT, offsetof(typevarobject, bound), READONLY}, + {"__constraints__", T_OBJECT, offsetof(typevarobject, constraints), READONLY}, + {"__covariant__", T_BOOL, offsetof(typevarobject, covariant), READONLY}, + {"__contravariant__", T_BOOL, offsetof(typevarobject, contravariant), READONLY}, + {"__autovariance__", T_BOOL, offsetof(typevarobject, autovariance), READONLY}, + {0} +}; + +static typevarobject *typevarobject_alloc(const char *name, PyObject *bound, + PyObject *constraints, + bool covariant, bool contravariant, + bool autovariance) +{ + typevarobject *tv = PyObject_GC_New(typevarobject, &_PyTypeVar_Type); + if (tv == NULL) { + return NULL; + } + + tv->name = strdup(name); + if (tv->name == NULL) { + Py_DECREF(tv); + return NULL; + } + + tv->bound = Py_XNewRef(bound); + tv->constraints = Py_XNewRef(constraints); + + tv->covariant = covariant; + tv->contravariant = contravariant; + tv->autovariance = autovariance; + + _PyObject_GC_TRACK(tv); + return tv; +} + +/*[clinic input] +@classmethod +typevar.__new__ as typevar_new + + name: str + * + bound: object = None + constraints: object = None + covariant: bool = False + contravariant: bool = False + autovariance: bool = False + +Create a TypeVar. +[clinic start generated code]*/ + +static PyObject * +typevar_new_impl(PyTypeObject *type, const char *name, PyObject *bound, + PyObject *constraints, int covariant, int contravariant, + int autovariance) +/*[clinic end generated code: output=1a13d705ffbce358 input=ef28fd4e62fcfc83]*/ +{ + if (covariant && contravariant) { + PyErr_SetString(PyExc_ValueError, + "Bivariant types are not supported."); + return NULL; + } + + if (autovariance && (covariant || contravariant)) { + PyErr_SetString(PyExc_ValueError, + "Variance cannot be specified with autovariance."); + return NULL; + } + + if (constraints != NULL) { + if (!PyTuple_CheckExact(constraints)) { + PyErr_SetString(PyExc_TypeError, + "constraints must be a tuple"); + return NULL; + } + Py_ssize_t n_constraints = PyTuple_GET_SIZE(constraints); + if (n_constraints == 1) { + PyErr_SetString(PyExc_TypeError, + "A single constraint is not allowed"); + return NULL; + } else if (n_constraints == 0) { + PyErr_SetString(PyExc_TypeError, + "constraints must be a non-empty tuple"); + return NULL; + } + } + + return (PyObject *)typevarobject_alloc(name, bound, constraints, + covariant, contravariant, + autovariance); +} + +PyTypeObject _PyTypeVar_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "typing.TypeVar", + .tp_basicsize = sizeof(typevarobject), + .tp_dealloc = typevarobject_dealloc, + .tp_free = PyObject_GC_Del, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, + .tp_traverse = typevarobject_traverse, + .tp_repr = typevarobject_repr, + .tp_members = typevar_members, + .tp_new = typevar_new, +}; + +typedef struct { + PyObject_HEAD + const char *name; + PyObject *bound; + bool covariant; + bool contravariant; + bool autovariance; +} paramspecobject; + +static void paramspecobject_dealloc(PyObject *self) +{ + paramspecobject *ps = (paramspecobject *)self; + + _PyObject_GC_UNTRACK(self); + + free((void *)ps->name); + Py_XDECREF(ps->bound); + + Py_TYPE(self)->tp_free(self); +} + +static int paramspecobject_traverse(PyObject *self, visitproc visit, void *arg) +{ + paramspecobject *ps = (paramspecobject *)self; + Py_VISIT(ps->bound); + return 0; +} + +static PyObject *paramspecobject_repr(PyObject *self) +{ + paramspecobject *ps = (paramspecobject *)self; + + if (ps->autovariance) { + return PyUnicode_FromFormat("%s", ps->name); + } + + char variance = ps->covariant ? '+' : ps->contravariant ? '-' : '~'; + return PyUnicode_FromFormat("%c%s", variance, ps->name); +} + +static PyMemberDef paramspec_members[] = { + {"__name__", T_STRING, offsetof(paramspecobject, name), READONLY}, + {"__bound__", T_OBJECT, offsetof(paramspecobject, bound), READONLY}, + {"__covariant__", T_BOOL, offsetof(paramspecobject, covariant), READONLY}, + {"__contravariant__", T_BOOL, offsetof(paramspecobject, contravariant), READONLY}, + {"__autovariance__", T_BOOL, offsetof(paramspecobject, autovariance), READONLY}, + {0} +}; + +static paramspecobject *paramspecobject_alloc(const char *name, PyObject *bound, bool covariant, + bool contravariant, bool autovariance) +{ + paramspecobject *ps = PyObject_New(paramspecobject, &_PyParamSpec_Type); + if (ps == NULL) { + return NULL; + } + ps->name = strdup(name); + if (ps->name == NULL) { + Py_DECREF(ps); + return NULL; + } + ps->bound = Py_NewRef(bound); + ps->covariant = covariant; + ps->contravariant = contravariant; + ps->autovariance = autovariance; + return ps; +} + +/*[clinic input] +@classmethod +paramspec.__new__ as paramspec_new + + name: str + * + bound: object = None + covariant: bool = False + contravariant: bool = False + autovariance: bool = False + +Create a ParamSpec object. +[clinic start generated code]*/ + +static PyObject * +paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, + int covariant, int contravariant, int autovariance) +/*[clinic end generated code: output=d1693f0a5be7d69d input=09c84e07c5c0722e]*/ +{ + if (covariant && contravariant) { + PyErr_SetString(PyExc_ValueError, "Bivariant types are not supported."); + return NULL; + } + if (autovariance && (covariant || contravariant)) { + PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with autovariance."); + return NULL; + } + // TODO typing._type_check on bound + return (PyObject *)paramspecobject_alloc(name, bound, covariant, contravariant, autovariance); +} + +// TODO: +// - args/kwargs +// - pickling +// - __typing_prepare_subst__ +PyTypeObject _PyParamSpec_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "typing.ParamSpec", + .tp_basicsize = sizeof(paramspecobject), + .tp_dealloc = paramspecobject_dealloc, + .tp_free = PyObject_GC_Del, + .tp_repr = paramspecobject_repr, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, + .tp_traverse = paramspecobject_traverse, + .tp_members = paramspec_members, + .tp_new = paramspec_new, +}; + +typedef struct { + PyObject_HEAD + const char *name; +} typevartupleobject; + +static void typevartupleobject_dealloc(PyObject *self) +{ + typevartupleobject *tvt = (typevartupleobject *)self; + + free((void *)tvt->name); + Py_TYPE(self)->tp_free(self); +} + +static PyObject *typevartupleobject_repr(PyObject *self) +{ + typevartupleobject *tvt = (typevartupleobject *)self; + + return PyUnicode_FromFormat("%s", tvt->name); +} + +static PyMemberDef typevartuple_members[] = { + {"__name__", T_STRING, offsetof(typevartupleobject, name), READONLY}, + {0} +}; + +static typevartupleobject *typevartupleobject_alloc(const char *name) +{ + typevartupleobject *tvt = PyObject_New(typevartupleobject, &_PyTypeVarTuple_Type); + if (tvt == NULL) { + return NULL; + } + tvt->name = strdup(name); + if (tvt->name == NULL) { + Py_DECREF(tvt); + return NULL; + } + return tvt; +} + +/*[clinic input] +@classmethod +typevartuple.__new__ + + name: str + +Create a new TypeVarTuple with the given name. +[clinic start generated code]*/ + +static PyObject * +typevartuple_impl(PyTypeObject *type, const char *name) +/*[clinic end generated code: output=a5a5bc3437a27749 input=d89424a0e967cee6]*/ +{ + return (PyObject *)typevartupleobject_alloc(name); +} + +// TODO: +// - Iterable (for Unpack) +// - Pickling +// - __typing_subst__/__typing_prepare_subst__ +PyTypeObject _PyTypeVarTuple_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "typing.TypeVarTuple", + .tp_basicsize = sizeof(typevartupleobject), + .tp_dealloc = typevartupleobject_dealloc, + .tp_repr = typevartupleobject_repr, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .tp_members = typevartuple_members, + .tp_new = typevartuple, +}; + +PyObject *_Py_make_typevar(const char *name, PyObject *bound_or_constraints) { + if (PyTuple_CheckExact(bound_or_constraints)) { + return (PyObject *)typevarobject_alloc(name, NULL, bound_or_constraints, false, false, true); + } else { + return (PyObject *)typevarobject_alloc(name, bound_or_constraints, NULL, false, false, true); + } +} + +PyObject *_Py_make_paramspec(const char *name) { + return (PyObject *)paramspecobject_alloc(name, NULL, false, false, true); +} + +PyObject *_Py_make_typevartuple(const char *name) { + return (PyObject *)typevartupleobject_alloc(name); +} diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 29f32db579fa40..f145602c15bd9a 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -269,6 +269,7 @@ + @@ -480,6 +481,7 @@ + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 6a622fd93930ad..6a03ffb9faa331 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -705,6 +705,9 @@ Include\internal + + Include\internal + Include\internal @@ -1352,6 +1355,9 @@ Objects + + Objects + Objects diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index fcb4d7a9a975c6..3eb2b04e52972f 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -11,6 +11,7 @@ #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_ceval.h" // _PyEval_Vector() +#include "pycore_typevarobject.h" #include "clinic/bltinmodule.c.h" @@ -3091,6 +3092,10 @@ _PyBuiltin_Init(PyInterpreterState *interp) SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type); SETBUILTIN("zip", &PyZip_Type); + // TODO these shouldn't be builtins, remove when PEP 695 is fully implemented + SETBUILTIN("TypeVar", &_PyTypeVar_Type); + SETBUILTIN("TypeVarTuple", &_PyTypeVarTuple_Type); + SETBUILTIN("ParamSpec", &_PyParamSpec_Type); debug = PyBool_FromLong(config->optimization_level == 0); if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { Py_DECREF(debug); From 1e0b74c53bd85c867a80c510f83c18372ef00b8e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 13 Apr 2023 15:46:07 -0700 Subject: [PATCH 004/200] fix TypeVar signature --- Objects/clinic/typevarobject.c.h | 32 ++++++++++++++------------------ Objects/typevarobject.c | 8 ++++---- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index b70e57716855f7..aabd0e904d58d5 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -9,15 +9,15 @@ preserve PyDoc_STRVAR(typevar_new__doc__, -"typevar(name, *, bound=None, constraints=None, covariant=False,\n" +"typevar(name, *constraints, *, bound=None, covariant=False,\n" " contravariant=False, autovariance=False)\n" "--\n" "\n" "Create a TypeVar."); static PyObject * -typevar_new_impl(PyTypeObject *type, const char *name, PyObject *bound, - PyObject *constraints, int covariant, int contravariant, +typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, + PyObject *bound, int covariant, int contravariant, int autovariance); static PyObject * @@ -26,14 +26,14 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - #define NUM_KEYWORDS 6 + #define NUM_KEYWORDS 5 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) - .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(constraints), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -42,7 +42,7 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"name", "bound", "constraints", "covariant", "contravariant", "autovariance", NULL}; + static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "autovariance", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, .fname = "typevar", @@ -52,15 +52,15 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *argsbuf[6]; PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + Py_ssize_t noptargs = Py_MIN(nargs, 1) + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; const char *name; + PyObject *constraints = NULL; PyObject *bound = Py_None; - PyObject *constraints = Py_None; int covariant = 0; int contravariant = 0; int autovariance = 0; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + fastargs = _PyArg_UnpackKeywordsWithVararg(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, 1, argsbuf); if (!fastargs) { goto exit; } @@ -77,17 +77,12 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyErr_SetString(PyExc_ValueError, "embedded null character"); goto exit; } + constraints = fastargs[1]; if (!noptargs) { goto skip_optional_kwonly; } - if (fastargs[1]) { - bound = fastargs[1]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } if (fastargs[2]) { - constraints = fastargs[2]; + bound = fastargs[2]; if (!--noptargs) { goto skip_optional_kwonly; } @@ -115,9 +110,10 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto exit; } skip_optional_kwonly: - return_value = typevar_new_impl(type, name, bound, constraints, covariant, contravariant, autovariance); + return_value = typevar_new_impl(type, name, constraints, bound, covariant, contravariant, autovariance); exit: + Py_XDECREF(constraints); return return_value; } @@ -291,4 +287,4 @@ typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=e500e924addebd33 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2514140af973a73f input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 4586b0d3ce9a4b..d0e8d2b4dfa4a4 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -98,9 +98,9 @@ static typevarobject *typevarobject_alloc(const char *name, PyObject *bound, typevar.__new__ as typevar_new name: str + *constraints: object * bound: object = None - constraints: object = None covariant: bool = False contravariant: bool = False autovariance: bool = False @@ -109,10 +109,10 @@ Create a TypeVar. [clinic start generated code]*/ static PyObject * -typevar_new_impl(PyTypeObject *type, const char *name, PyObject *bound, - PyObject *constraints, int covariant, int contravariant, +typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, + PyObject *bound, int covariant, int contravariant, int autovariance) -/*[clinic end generated code: output=1a13d705ffbce358 input=ef28fd4e62fcfc83]*/ +/*[clinic end generated code: output=e74ea8371ab8103a input=9d08a995b997a11b]*/ { if (covariant && contravariant) { PyErr_SetString(PyExc_ValueError, From 2a5023a9a48bb86da2e78b5dd26f4b003258a1d6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 13 Apr 2023 15:49:43 -0700 Subject: [PATCH 005/200] fix TypeVar argument parsing --- Objects/typevarobject.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index d0e8d2b4dfa4a4..a280ffe7726aed 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -126,22 +126,22 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, return NULL; } - if (constraints != NULL) { - if (!PyTuple_CheckExact(constraints)) { - PyErr_SetString(PyExc_TypeError, - "constraints must be a tuple"); - return NULL; - } - Py_ssize_t n_constraints = PyTuple_GET_SIZE(constraints); - if (n_constraints == 1) { - PyErr_SetString(PyExc_TypeError, - "A single constraint is not allowed"); - return NULL; - } else if (n_constraints == 0) { - PyErr_SetString(PyExc_TypeError, - "constraints must be a non-empty tuple"); - return NULL; - } + if (!PyTuple_CheckExact(constraints)) { + PyErr_SetString(PyExc_TypeError, + "constraints must be a tuple"); + return NULL; + } + Py_ssize_t n_constraints = PyTuple_GET_SIZE(constraints); + if (n_constraints == 1) { + PyErr_SetString(PyExc_TypeError, + "A single constraint is not allowed"); + return NULL; + } else if (n_constraints == 0) { + constraints = NULL; + } + + if (Py_IsNone(bound)) { + bound = NULL; } return (PyObject *)typevarobject_alloc(name, bound, constraints, From 1bc85743ae1c5fa92b8e8c5cfa2a09371072806d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 13 Apr 2023 20:34:33 -0700 Subject: [PATCH 006/200] ParamSpecArgs/Kwargs --- .../pycore_global_objects_fini_generated.h | 2 +- Include/internal/pycore_global_strings.h | 2 +- .../internal/pycore_runtime_init_generated.h | 2 +- Include/internal/pycore_typevarobject.h | 2 + .../internal/pycore_unicodeobject_generated.h | 6 +- Objects/clinic/typevarobject.c.h | 110 ++++++++++- Objects/object.c | 6 + Objects/typevarobject.c | 179 +++++++++++++++++- 8 files changed, 300 insertions(+), 9 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 270507dbb8f7a4..5eaf2998bd1f19 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -850,7 +850,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(code)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(command)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(comment_factory)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(constraints)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(consts)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(context)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(contravariant)); @@ -1081,6 +1080,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(optimize)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(options)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(order)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(origin)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(out_fd)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(outgoing)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(overlapped)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index db7986d3686e18..f47820256813cc 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -336,7 +336,6 @@ struct _Py_global_strings { STRUCT_FOR_ID(code) STRUCT_FOR_ID(command) STRUCT_FOR_ID(comment_factory) - STRUCT_FOR_ID(constraints) STRUCT_FOR_ID(consts) STRUCT_FOR_ID(context) STRUCT_FOR_ID(contravariant) @@ -567,6 +566,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(optimize) STRUCT_FOR_ID(options) STRUCT_FOR_ID(order) + STRUCT_FOR_ID(origin) STRUCT_FOR_ID(out_fd) STRUCT_FOR_ID(outgoing) STRUCT_FOR_ID(overlapped) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 8c97833b8a9cb7..f90256b0cdc980 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -842,7 +842,6 @@ extern "C" { INIT_ID(code), \ INIT_ID(command), \ INIT_ID(comment_factory), \ - INIT_ID(constraints), \ INIT_ID(consts), \ INIT_ID(context), \ INIT_ID(contravariant), \ @@ -1073,6 +1072,7 @@ extern "C" { INIT_ID(optimize), \ INIT_ID(options), \ INIT_ID(order), \ + INIT_ID(origin), \ INIT_ID(out_fd), \ INIT_ID(outgoing), \ INIT_ID(overlapped), \ diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index a4ce06fc8a09cc..85a1698b9cbd45 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -11,6 +11,8 @@ extern "C" { extern PyTypeObject _PyTypeVar_Type; extern PyTypeObject _PyTypeVarTuple_Type; extern PyTypeObject _PyParamSpec_Type; +extern PyTypeObject _PyParamSpecArgs_Type; +extern PyTypeObject _PyParamSpecKwargs_Type; extern PyObject *_Py_make_typevar(const char *, PyObject *); extern PyObject *_Py_make_paramspec(const char *); diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index f1db5380a53e24..1f369d631a7e95 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -861,9 +861,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(comment_factory); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); - string = &_Py_ID(constraints); - assert(_PyUnicode_CheckConsistency(string, 1)); - _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(consts); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); @@ -1554,6 +1551,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(order); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(origin); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(out_fd); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index aabd0e904d58d5..dcdb83cf30e7d1 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -222,6 +222,114 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +PyDoc_STRVAR(paramspecargs_new__doc__, +"paramspecargs(origin)\n" +"--\n" +"\n" +"Create a ParamSpecArgs object."); + +static PyObject * +paramspecargs_new_impl(PyTypeObject *type, PyObject *origin); + +static PyObject * +paramspecargs_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(origin), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"origin", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "paramspecargs", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + PyObject *origin; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + origin = fastargs[0]; + return_value = paramspecargs_new_impl(type, origin); + +exit: + return return_value; +} + +PyDoc_STRVAR(paramspeckwargs_new__doc__, +"paramspeckwargs(origin)\n" +"--\n" +"\n" +"Create a ParamSpecKwargs object."); + +static PyObject * +paramspeckwargs_new_impl(PyTypeObject *type, PyObject *origin); + +static PyObject * +paramspeckwargs_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(origin), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"origin", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "paramspeckwargs", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + PyObject *origin; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + origin = fastargs[0]; + return_value = paramspeckwargs_new_impl(type, origin); + +exit: + return return_value; +} + PyDoc_STRVAR(typevartuple__doc__, "typevartuple(name)\n" "--\n" @@ -287,4 +395,4 @@ typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=2514140af973a73f input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0a84cbcb2d2232fe input=a9049054013a1b77]*/ diff --git a/Objects/object.c b/Objects/object.c index 71f098eed37f51..2677fe822a6b10 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -14,6 +14,7 @@ #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_symtable.h" // PySTEntry_Type +#include "pycore_typevarobject.h" // _PyTypeVar_Type etc. #include "pycore_unionobject.h" // _PyUnion_Type #include "pycore_interpreteridobject.h" // _PyInterpreterID_Type @@ -2083,6 +2084,11 @@ static PyTypeObject* static_types[] = { &_PyWeakref_CallableProxyType, &_PyWeakref_ProxyType, &_PyWeakref_RefType, + &_PyTypeVar_Type, + &_PyTypeVarTuple_Type, + &_PyParamSpec_Type, + &_PyParamSpecArgs_Type, + &_PyParamSpecKwargs_Type, // subclasses: _PyTypes_FiniTypes() deallocates them before their base // class diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index a280ffe7726aed..0727f4aa8f0818 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -7,9 +7,11 @@ /*[clinic input] class typevar "typevarobject *" "&_PyTypeVar_Type" class paramspec "paramspecobject *" "&_PyParamSpec_Type" +class paramspecargs "paramspecargsobject *" "&_PyParamSpecArgs_Type" +class paramspeckwargs "paramspeckwargsobject *" "&_PyParamSpecKwargs_Type" class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=d1b368d1521582f6]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=74cb9c15a049111b]*/ #include "clinic/typevarobject.c.h" @@ -154,6 +156,7 @@ PyTypeObject _PyTypeVar_Type = { .tp_name = "typing.TypeVar", .tp_basicsize = sizeof(typevarobject), .tp_dealloc = typevarobject_dealloc, + .tp_alloc = PyType_GenericAlloc, .tp_free = PyObject_GC_Del, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = typevarobject_traverse, @@ -162,6 +165,158 @@ PyTypeObject _PyTypeVar_Type = { .tp_new = typevar_new, }; +typedef struct { + PyObject_HEAD + PyObject *__origin__; +} paramspecargsobject; + +static void paramspecargsobject_dealloc(PyObject *self) +{ + paramspecargsobject *psa = (paramspecargsobject *)self; + + _PyObject_GC_UNTRACK(self); + + Py_XDECREF(psa->__origin__); + + Py_TYPE(self)->tp_free(self); +} + +static int paramspecargsobject_traverse(PyObject *self, visitproc visit, void *arg) +{ + paramspecargsobject *psa = (paramspecargsobject *)self; + Py_VISIT(psa->__origin__); + return 0; +} + +static PyObject *paramspecargsobject_repr(PyObject *self) +{ + paramspecargsobject *psa = (paramspecargsobject *)self; + + return PyUnicode_FromFormat("%R.args", psa->__origin__); +} + +static PyMemberDef paramspecargs_members[] = { + {"__origin__", T_OBJECT, offsetof(paramspecargsobject, __origin__), READONLY}, + {0} +}; + +static paramspecargsobject *paramspecargsobject_new(PyObject *origin) +{ + paramspecargsobject *psa = PyObject_GC_New(paramspecargsobject, &_PyParamSpecArgs_Type); + if (psa == NULL) { + return NULL; + } + psa->__origin__ = Py_NewRef(origin); + _PyObject_GC_TRACK(psa); + return psa; +} + +/*[clinic input] +@classmethod +paramspecargs.__new__ as paramspecargs_new + + origin: object + +Create a ParamSpecArgs object. +[clinic start generated code]*/ + +static PyObject * +paramspecargs_new_impl(PyTypeObject *type, PyObject *origin) +/*[clinic end generated code: output=9a1463dc8942fe4e input=3596a0bb6183c208]*/ +{ + return (PyObject *)paramspecargsobject_new(origin); +} + +PyTypeObject _PyParamSpecArgs_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "typing.ParamSpecArgs", + .tp_basicsize = sizeof(paramspecargsobject), + .tp_dealloc = paramspecargsobject_dealloc, + .tp_alloc = PyType_GenericAlloc, + .tp_free = PyObject_GC_Del, + .tp_repr = paramspecargsobject_repr, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, + .tp_traverse = paramspecargsobject_traverse, + .tp_members = paramspecargs_members, + .tp_new = paramspecargs_new, +}; + +typedef struct { + PyObject_HEAD + PyObject *__origin__; +} paramspeckwargsobject; + +static void paramspeckwargsobject_dealloc(PyObject *self) +{ + paramspeckwargsobject *psk = (paramspeckwargsobject *)self; + + _PyObject_GC_UNTRACK(self); + + Py_XDECREF(psk->__origin__); + + Py_TYPE(self)->tp_free(self); +} + +static int paramspeckwargsobject_traverse(PyObject *self, visitproc visit, void *arg) +{ + paramspeckwargsobject *psk = (paramspeckwargsobject *)self; + Py_VISIT(psk->__origin__); + return 0; +} + +static PyObject *paramspeckwargsobject_repr(PyObject *self) +{ + paramspeckwargsobject *psk = (paramspeckwargsobject *)self; + + return PyUnicode_FromFormat("%R.kwargs", psk->__origin__); +} + +static PyMemberDef paramspeckwargs_members[] = { + {"__origin__", T_OBJECT, offsetof(paramspeckwargsobject, __origin__), READONLY}, + {0} +}; + +static paramspeckwargsobject *paramspeckwargsobject_new(PyObject *origin) +{ + paramspeckwargsobject *psk = PyObject_GC_New(paramspeckwargsobject, &_PyParamSpecKwargs_Type); + if (psk == NULL) { + return NULL; + } + psk->__origin__ = Py_NewRef(origin); + _PyObject_GC_TRACK(psk); + return psk; +} + +/*[clinic input] +@classmethod +paramspeckwargs.__new__ as paramspeckwargs_new + + origin: object + +Create a ParamSpecKwargs object. +[clinic start generated code]*/ + +static PyObject * +paramspeckwargs_new_impl(PyTypeObject *type, PyObject *origin) +/*[clinic end generated code: output=277b11967ebaf4ab input=981bca9b0cf9e40a]*/ +{ + return (PyObject *)paramspeckwargsobject_new(origin); +} + +PyTypeObject _PyParamSpecKwargs_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "typing.ParamSpecKwargs", + .tp_basicsize = sizeof(paramspeckwargsobject), + .tp_dealloc = paramspeckwargsobject_dealloc, + .tp_alloc = PyType_GenericAlloc, + .tp_free = PyObject_GC_Del, + .tp_repr = paramspeckwargsobject_repr, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, + .tp_traverse = paramspeckwargsobject_traverse, + .tp_members = paramspeckwargs_members, + .tp_new = paramspeckwargs_new, +}; + typedef struct { PyObject_HEAD const char *name; @@ -211,10 +366,26 @@ static PyMemberDef paramspec_members[] = { {0} }; +static PyObject *paramspecobject_args(PyObject *self, void *unused) +{ + return (PyObject *)paramspecargsobject_new(self); +} + +static PyObject *paramspecobject_kwargs(PyObject *self, void *unused) +{ + return (PyObject *)paramspeckwargsobject_new(self); +} + +static PyGetSetDef paramspec_getset[] = { + {"args", (getter)paramspecobject_args, NULL, "Represents positional arguments.", NULL}, + {"kwargs", (getter)paramspecobject_kwargs, NULL, "Represents keyword arguments.", NULL}, + {0}, +}; + static paramspecobject *paramspecobject_alloc(const char *name, PyObject *bound, bool covariant, bool contravariant, bool autovariance) { - paramspecobject *ps = PyObject_New(paramspecobject, &_PyParamSpec_Type); + paramspecobject *ps = PyObject_GC_New(paramspecobject, &_PyParamSpec_Type); if (ps == NULL) { return NULL; } @@ -227,6 +398,7 @@ static paramspecobject *paramspecobject_alloc(const char *name, PyObject *bound, ps->covariant = covariant; ps->contravariant = contravariant; ps->autovariance = autovariance; + _PyObject_GC_TRACK(ps); return ps; } @@ -270,11 +442,13 @@ PyTypeObject _PyParamSpec_Type = { .tp_name = "typing.ParamSpec", .tp_basicsize = sizeof(paramspecobject), .tp_dealloc = paramspecobject_dealloc, + .tp_alloc = PyType_GenericAlloc, .tp_free = PyObject_GC_Del, .tp_repr = paramspecobject_repr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = paramspecobject_traverse, .tp_members = paramspec_members, + .tp_getset = paramspec_getset, .tp_new = paramspec_new, }; @@ -342,6 +516,7 @@ PyTypeObject _PyTypeVarTuple_Type = { .tp_name = "typing.TypeVarTuple", .tp_basicsize = sizeof(typevartupleobject), .tp_dealloc = typevartupleobject_dealloc, + .tp_alloc = PyType_GenericAlloc, .tp_repr = typevartupleobject_repr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, .tp_members = typevartuple_members, From ed42796a0108e2c6bab16c2ab0e09ba9025827fd Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 13 Apr 2023 20:45:34 -0700 Subject: [PATCH 007/200] make typing importable --- .../pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + .../internal/pycore_runtime_init_generated.h | 1 + .../internal/pycore_unicodeobject_generated.h | 3 + Lib/typing.py | 9 + Objects/clinic/typevarobject.c.h | 194 +++++++++++------- Objects/typevarobject.c | 26 ++- 7 files changed, 163 insertions(+), 72 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 5eaf2998bd1f19..8b6fd26141bca7 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -781,6 +781,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_parent)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aggregate_class)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(append)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arg)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argdefs)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arguments)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argv)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index f47820256813cc..abf2cb587bb960 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -267,6 +267,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(after_in_parent) STRUCT_FOR_ID(aggregate_class) STRUCT_FOR_ID(append) + STRUCT_FOR_ID(arg) STRUCT_FOR_ID(argdefs) STRUCT_FOR_ID(arguments) STRUCT_FOR_ID(argv) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index f90256b0cdc980..707b438d253123 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -773,6 +773,7 @@ extern "C" { INIT_ID(after_in_parent), \ INIT_ID(aggregate_class), \ INIT_ID(append), \ + INIT_ID(arg), \ INIT_ID(argdefs), \ INIT_ID(arguments), \ INIT_ID(argv), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 1f369d631a7e95..867d9a8b48e200 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -654,6 +654,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(append); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(arg); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(argdefs); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Lib/typing.py b/Lib/typing.py index e4877a35952aac..505cccaf077948 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1292,6 +1292,15 @@ def __typing_prepare_subst__(self, alias, args): args = (*args[:i], tuple(args[i]), *args[i+1:]) return args + +import builtins +if hasattr(builtins, "TypeVar"): + TypeVar = builtins.TypeVar + TypeVarTuple = builtins.TypeVarTuple + ParamSpec = builtins.ParamSpec + ParamSpecArgs = type(ParamSpec("P").args) + ParamSpecKwargs = type(ParamSpec("P").kwargs) + def _is_dunder(attr): return attr.startswith('__') and attr.endswith('__') diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index dcdb83cf30e7d1..37ebfa42630258 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -117,31 +117,31 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } -PyDoc_STRVAR(paramspec_new__doc__, -"paramspec(name, *, bound=None, covariant=False, contravariant=False,\n" -" autovariance=False)\n" +PyDoc_STRVAR(typevar_typing_subst__doc__, +"__typing_subst__($self, /, arg)\n" "--\n" -"\n" -"Create a ParamSpec object."); +"\n"); + +#define TYPEVAR_TYPING_SUBST_METHODDEF \ + {"__typing_subst__", _PyCFunction_CAST(typevar_typing_subst), METH_FASTCALL|METH_KEYWORDS, typevar_typing_subst__doc__}, static PyObject * -paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, - int covariant, int contravariant, int autovariance); +typevar_typing_subst_impl(typevarobject *self, PyObject *arg); static PyObject * -paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +typevar_typing_subst(typevarobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) - #define NUM_KEYWORDS 5 + #define NUM_KEYWORDS 1 static struct { PyGC_Head _this_is_not_used; PyObject_VAR_HEAD PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) - .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + .ob_item = { &_Py_ID(arg), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -150,73 +150,22 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "autovariance", NULL}; + static const char * const _keywords[] = {"arg", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, - .fname = "paramspec", + .fname = "__typing_subst__", .kwtuple = KWTUPLE, }; #undef KWTUPLE - PyObject *argsbuf[5]; - PyObject * const *fastargs; - Py_ssize_t nargs = PyTuple_GET_SIZE(args); - Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; - const char *name; - PyObject *bound = Py_None; - int covariant = 0; - int contravariant = 0; - int autovariance = 0; + PyObject *argsbuf[1]; + PyObject *arg; - fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); - if (!fastargs) { - goto exit; - } - if (!PyUnicode_Check(fastargs[0])) { - _PyArg_BadArgument("paramspec", "argument 'name'", "str", fastargs[0]); - goto exit; - } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { goto exit; } - if (!noptargs) { - goto skip_optional_kwonly; - } - if (fastargs[1]) { - bound = fastargs[1]; - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[2]) { - covariant = PyObject_IsTrue(fastargs[2]); - if (covariant < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - if (fastargs[3]) { - contravariant = PyObject_IsTrue(fastargs[3]); - if (contravariant < 0) { - goto exit; - } - if (!--noptargs) { - goto skip_optional_kwonly; - } - } - autovariance = PyObject_IsTrue(fastargs[4]); - if (autovariance < 0) { - goto exit; - } -skip_optional_kwonly: - return_value = paramspec_new_impl(type, name, bound, covariant, contravariant, autovariance); + arg = args[0]; + return_value = typevar_typing_subst_impl(self, arg); exit: return return_value; @@ -330,6 +279,111 @@ paramspeckwargs_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +PyDoc_STRVAR(paramspec_new__doc__, +"paramspec(name, *, bound=None, covariant=False, contravariant=False,\n" +" autovariance=False)\n" +"--\n" +"\n" +"Create a ParamSpec object."); + +static PyObject * +paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, + int covariant, int contravariant, int autovariance); + +static PyObject * +paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 5 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "autovariance", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "paramspec", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[5]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; + const char *name; + PyObject *bound = Py_None; + int covariant = 0; + int contravariant = 0; + int autovariance = 0; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("paramspec", "argument 'name'", "str", fastargs[0]); + goto exit; + } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + if (!noptargs) { + goto skip_optional_kwonly; + } + if (fastargs[1]) { + bound = fastargs[1]; + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[2]) { + covariant = PyObject_IsTrue(fastargs[2]); + if (covariant < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + if (fastargs[3]) { + contravariant = PyObject_IsTrue(fastargs[3]); + if (contravariant < 0) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_kwonly; + } + } + autovariance = PyObject_IsTrue(fastargs[4]); + if (autovariance < 0) { + goto exit; + } +skip_optional_kwonly: + return_value = paramspec_new_impl(type, name, bound, covariant, contravariant, autovariance); + +exit: + return return_value; +} + PyDoc_STRVAR(typevartuple__doc__, "typevartuple(name)\n" "--\n" @@ -395,4 +449,4 @@ typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=0a84cbcb2d2232fe input=a9049054013a1b77]*/ +/*[clinic end generated code: output=5bec221c90526610 input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 0727f4aa8f0818..90b0f5930adcc9 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -13,8 +13,6 @@ class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=74cb9c15a049111b]*/ -#include "clinic/typevarobject.c.h" - typedef struct { PyObject_HEAD const char *name; @@ -25,6 +23,8 @@ typedef struct { bool autovariance; } typevarobject; +#include "clinic/typevarobject.c.h" + static void typevarobject_dealloc(PyObject *self) { typevarobject *tv = (typevarobject *)self; @@ -151,6 +151,27 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, autovariance); } +/*[clinic input] +typevar.__typing_subst__ as typevar_typing_subst + + arg: object + +[clinic start generated code]*/ + +static PyObject * +typevar_typing_subst_impl(typevarobject *self, PyObject *arg) +/*[clinic end generated code: output=c76ced134ed8f4e1 input=6b70a4bb2da838de]*/ +{ + // TODO _type_check + // TODO reject Unpack[] + return Py_NewRef(arg); +} + +static PyMethodDef typevar_methods[] = { + TYPEVAR_TYPING_SUBST_METHODDEF + {0} +}; + PyTypeObject _PyTypeVar_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.TypeVar", @@ -162,6 +183,7 @@ PyTypeObject _PyTypeVar_Type = { .tp_traverse = typevarobject_traverse, .tp_repr = typevarobject_repr, .tp_members = typevar_members, + .tp_methods = typevar_methods, .tp_new = typevar_new, }; From d06f43d275d20b158dddcd51ce412c5c47541aa6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 13 Apr 2023 21:17:20 -0700 Subject: [PATCH 008/200] Add some things --- Objects/clinic/typevarobject.c.h | 110 +++++++++++++++++++++++++++- Objects/typevarobject.c | 118 +++++++++++++++++++++++++++---- 2 files changed, 213 insertions(+), 15 deletions(-) diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index 37ebfa42630258..6cb9966fb8074b 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -384,6 +384,60 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) return return_value; } +PyDoc_STRVAR(paramspec_typing_subst__doc__, +"__typing_subst__($self, /, arg)\n" +"--\n" +"\n"); + +#define PARAMSPEC_TYPING_SUBST_METHODDEF \ + {"__typing_subst__", _PyCFunction_CAST(paramspec_typing_subst), METH_FASTCALL|METH_KEYWORDS, paramspec_typing_subst__doc__}, + +static PyObject * +paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg); + +static PyObject * +paramspec_typing_subst(paramspecobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(arg), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"arg", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "__typing_subst__", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject *arg; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + arg = args[0]; + return_value = paramspec_typing_subst_impl(self, arg); + +exit: + return return_value; +} + PyDoc_STRVAR(typevartuple__doc__, "typevartuple(name)\n" "--\n" @@ -449,4 +503,58 @@ typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=5bec221c90526610 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(typevartuple_typing_subst__doc__, +"__typing_subst__($self, /, arg)\n" +"--\n" +"\n"); + +#define TYPEVARTUPLE_TYPING_SUBST_METHODDEF \ + {"__typing_subst__", _PyCFunction_CAST(typevartuple_typing_subst), METH_FASTCALL|METH_KEYWORDS, typevartuple_typing_subst__doc__}, + +static PyObject * +typevartuple_typing_subst_impl(typevartupleobject *self, PyObject *arg); + +static PyObject * +typevartuple_typing_subst(typevartupleobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(arg), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"arg", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "__typing_subst__", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + PyObject *arg; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); + if (!args) { + goto exit; + } + arg = args[0]; + return_value = typevartuple_typing_subst_impl(self, arg); + +exit: + return return_value; +} +/*[clinic end generated code: output=06d91d3e010cd9de input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 90b0f5930adcc9..1d7e01d0da5d92 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -23,6 +23,20 @@ typedef struct { bool autovariance; } typevarobject; +typedef struct { + PyObject_HEAD + const char *name; +} typevartupleobject; + +typedef struct { + PyObject_HEAD + const char *name; + PyObject *bound; + bool covariant; + bool contravariant; + bool autovariance; +} paramspecobject; + #include "clinic/typevarobject.c.h" static void typevarobject_dealloc(PyObject *self) @@ -217,6 +231,21 @@ static PyObject *paramspecargsobject_repr(PyObject *self) return PyUnicode_FromFormat("%R.args", psa->__origin__); } +static PyObject *paramspecargsobject_richcompare(PyObject *a, PyObject *b, int op) +{ + if (!Py_IS_TYPE(b, &_PyParamSpecArgs_Type)) { + Py_RETURN_NOTIMPLEMENTED; + } + if (op != Py_EQ && op != Py_NE) { + Py_RETURN_NOTIMPLEMENTED; + } + return PyObject_RichCompare( + ((paramspecargsobject *)a)->__origin__, + ((paramspecargsobject *)b)->__origin__, + op + ); +} + static PyMemberDef paramspecargs_members[] = { {"__origin__", T_OBJECT, offsetof(paramspecargsobject, __origin__), READONLY}, {0} @@ -257,6 +286,7 @@ PyTypeObject _PyParamSpecArgs_Type = { .tp_alloc = PyType_GenericAlloc, .tp_free = PyObject_GC_Del, .tp_repr = paramspecargsobject_repr, + .tp_richcompare = paramspecargsobject_richcompare, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = paramspecargsobject_traverse, .tp_members = paramspecargs_members, @@ -293,6 +323,21 @@ static PyObject *paramspeckwargsobject_repr(PyObject *self) return PyUnicode_FromFormat("%R.kwargs", psk->__origin__); } +static PyObject *paramspeckwargsobject_richcompare(PyObject *a, PyObject *b, int op) +{ + if (!Py_IS_TYPE(b, &_PyParamSpecKwargs_Type)) { + Py_RETURN_NOTIMPLEMENTED; + } + if (op != Py_EQ && op != Py_NE) { + Py_RETURN_NOTIMPLEMENTED; + } + return PyObject_RichCompare( + ((paramspeckwargsobject *)a)->__origin__, + ((paramspeckwargsobject *)b)->__origin__, + op + ); +} + static PyMemberDef paramspeckwargs_members[] = { {"__origin__", T_OBJECT, offsetof(paramspeckwargsobject, __origin__), READONLY}, {0} @@ -333,21 +378,13 @@ PyTypeObject _PyParamSpecKwargs_Type = { .tp_alloc = PyType_GenericAlloc, .tp_free = PyObject_GC_Del, .tp_repr = paramspeckwargsobject_repr, + .tp_richcompare = paramspeckwargsobject_richcompare, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = paramspeckwargsobject_traverse, .tp_members = paramspeckwargs_members, .tp_new = paramspeckwargs_new, }; -typedef struct { - PyObject_HEAD - const char *name; - PyObject *bound; - bool covariant; - bool contravariant; - bool autovariance; -} paramspecobject; - static void paramspecobject_dealloc(PyObject *self) { paramspecobject *ps = (paramspecobject *)self; @@ -455,6 +492,35 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, return (PyObject *)paramspecobject_alloc(name, bound, covariant, contravariant, autovariance); } + +/*[clinic input] +paramspec.__typing_subst__ as paramspec_typing_subst + + arg: object + +[clinic start generated code]*/ + +static PyObject * +paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg) +/*[clinic end generated code: output=803e1ade3f13b57d input=4e0005d24023e896]*/ +{ + if (PyTuple_Check(arg)) { + return Py_NewRef(arg); + } else if (PyList_Check(arg)) { + return PyList_AsTuple(arg); + } else { + // TODO: typing._is_param_expr + // (in particular _ConcatenateGenericAlias) + return Py_NewRef(arg); + } +} + +static PyMethodDef paramspec_methods[] = { + PARAMSPEC_TYPING_SUBST_METHODDEF + {0} +}; + + // TODO: // - args/kwargs // - pickling @@ -470,15 +536,11 @@ PyTypeObject _PyParamSpec_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = paramspecobject_traverse, .tp_members = paramspec_members, + .tp_methods = paramspec_methods, .tp_getset = paramspec_getset, .tp_new = paramspec_new, }; -typedef struct { - PyObject_HEAD - const char *name; -} typevartupleobject; - static void typevartupleobject_dealloc(PyObject *self) { typevartupleobject *tvt = (typevartupleobject *)self; @@ -487,6 +549,12 @@ static void typevartupleobject_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } +static PyObject *typevartupleobject_iter(PyObject *self) +{ + // TODO Unpack[] + return Py_NewRef(self); +} + static PyObject *typevartupleobject_repr(PyObject *self) { typevartupleobject *tvt = (typevartupleobject *)self; @@ -529,6 +597,26 @@ typevartuple_impl(PyTypeObject *type, const char *name) return (PyObject *)typevartupleobject_alloc(name); } +/*[clinic input] +typevartuple.__typing_subst__ as typevartuple_typing_subst + + arg: object + +[clinic start generated code]*/ + +static PyObject * +typevartuple_typing_subst_impl(typevartupleobject *self, PyObject *arg) +/*[clinic end generated code: output=814316519441cd76 input=670c4e0a36e5d8c0]*/ +{ + PyErr_SetString(PyExc_TypeError, "Substitution of bare TypeVarTuple is not supported"); + return NULL; +} + +static PyMethodDef typevartuple_methods[] = { + TYPEVARTUPLE_TYPING_SUBST_METHODDEF + {0} +}; + // TODO: // - Iterable (for Unpack) // - Pickling @@ -539,9 +627,11 @@ PyTypeObject _PyTypeVarTuple_Type = { .tp_basicsize = sizeof(typevartupleobject), .tp_dealloc = typevartupleobject_dealloc, .tp_alloc = PyType_GenericAlloc, + .tp_iter = typevartupleobject_iter, .tp_repr = typevartupleobject_repr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, .tp_members = typevartuple_members, + .tp_methods = typevartuple_methods, .tp_new = typevartuple, }; From 830b36ab49385e66a1eb778e7cfd926347ec1017 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 14 Apr 2023 11:27:39 -0700 Subject: [PATCH 009/200] Updated unit tests to reflect the latest PEP 695 spec. --- Lib/test/test_type_aliases.py | 17 +++----- Lib/test/test_type_params.py | 81 ++++++++++------------------------- 2 files changed, 27 insertions(+), 71 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index a7f77d69fb0e5f..09f817befeb113 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -5,26 +5,22 @@ class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): - code = """type TA1[A, A] = None""" + code = """type TA1[A, **A] = None""" with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): exec(code, {}, {}) - def test_name_collision_02(self): + def test_name_non_collision_02(self): code = """type TA1[A] = lambda A: None""" + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'A'"): - exec(code, {}, {}) - - def test_name_collision_03(self): + def test_name_non_collision_03(self): code = textwrap.dedent("""\ class Outer[A]: type TA1[A] = None """ ) - - with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): - exec(code, {}, {}) + exec(code, {}, {}) class TypeParamsAccessTest(unittest.TestCase): @@ -33,7 +29,6 @@ def test_alias_access_01(self): type TA1[A, B] = dict[A, B] """ ) - exec(code, {}, {}) def test_alias_access_02(self): @@ -41,7 +36,6 @@ def test_alias_access_02(self): type TA1[A, B] = TA1[A, B] | int """ ) - exec(code, {}, {}) def test_alias_access_03(self): @@ -51,7 +45,6 @@ def inner[B](self): type TA1[C] = TA1[A, B] | int """ ) - exec(code, {}, {}) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 03a2f652b1343d..cd9ac2a6d33188 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -6,108 +6,79 @@ class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): - code = """def func[A, A](): ...""" - + code = """def func[**A, A](): ...""" with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): exec(code, {}, {}) - def test_name_collision_02(self): + def test_name_non_collision_02(self): code = """def func[A](A): ...""" + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'A'"): - exec(code, {}, {}) - - def test_name_collision_03(self): + def test_name_non_collision_03(self): code = """def func[A](*A): ...""" + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'A'"): - exec(code, {}, {}) - - def test_name_collision_04(self): + def test_name_non_collision_04(self): # Mangled names should not cause a conflict. code = textwrap.dedent("""\ class ClassA: def func[__A](self, __A): ... """ ) - exec(code, {}, {}) - def test_name_collision_05(self): + def test_name_non_collision_05(self): code = textwrap.dedent("""\ class ClassA: def func[_ClassA__A](self, __A): ... """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter '__A'"): - exec(code, {}, {}) - - def test_name_collision_06(self): + def test_name_non_collision_06(self): code = textwrap.dedent("""\ class ClassA[X]: def func(self, X): ... """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_07(self): + def test_name_non_collision_07(self): code = textwrap.dedent("""\ class ClassA[X]: def func(self): X = 1 """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_08(self): + def test_name_non_collision_08(self): code = textwrap.dedent("""\ class ClassA[X]: def func(self): a = [X for X in []] """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_09(self): - code = textwrap.dedent("""\ - class ClassA[X]: - def func(self): - a = lambda X: None - """ - ) - - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_10(self): + def test_name_non_collision_9(self): code = textwrap.dedent("""\ class ClassA[X]: def func[X](self): ... """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_11(self): + def test_name_non_collision_10(self): code = textwrap.dedent("""\ class ClassA[X]: X: int """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_12(self): + def test_name_non_collision_11(self): code = textwrap.dedent("""\ def outer(): X = 1 @@ -115,11 +86,9 @@ def inner[X](): nonlocal X """ ) + exec(code, {}, {}) - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) - - def test_name_collision_13(self): + def test_name_non_collision_13(self): code = textwrap.dedent("""\ X = 1 def outer(): @@ -127,9 +96,7 @@ def inner[X](): global X """ ) - - with self.assertRaisesRegex(SyntaxError, "cannot overwrite type parameter 'X'"): - exec(code, {}, {}) + exec(code, {}, {}) class TypeParamsAccessTest(unittest.TestCase): @@ -139,7 +106,6 @@ class ClassA[A, B](dict[A, B]): ... """ ) - exec(code, {}, {}) def test_class_access_02(self): @@ -149,7 +115,6 @@ class ClassA[A, B](metaclass=MyMeta[A, B]): ... """ ) - exec(code, {}, {}) def test_class_access_03(self): @@ -171,7 +136,6 @@ def func[A, B](a: dict[A, B]): ... """ ) - exec(code, {}, {}) def test_function_access_02(self): @@ -206,7 +170,6 @@ def funcD[D](self): lambda : (A, B, C, D) """ ) - exec(code, {}, {}) def test_out_of_scope_01(self): From 6bb47956696abab038942fa3cb8f844dc68abab5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 14 Apr 2023 19:35:04 -0700 Subject: [PATCH 010/200] Make *Ts work --- Objects/typevarobject.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 1d7e01d0da5d92..e94de49fa2a5d3 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -551,8 +551,35 @@ static void typevartupleobject_dealloc(PyObject *self) static PyObject *typevartupleobject_iter(PyObject *self) { - // TODO Unpack[] - return Py_NewRef(self); + PyObject *typing = NULL; + PyObject *unpack = NULL; + PyObject *unpacked = NULL; + PyObject *tuple = NULL; + PyObject *result = NULL; + + typing = PyImport_ImportModule("typing"); + if (typing == NULL) { + goto exit; + } + unpack = PyObject_GetAttrString(typing, "Unpack"); + if (unpack == NULL) { + goto exit; + } + unpacked = PyObject_GetItem(unpack, self); + if (unpacked == NULL) { + goto exit; + } + tuple = PyTuple_Pack(1, unpacked); + if (tuple == NULL) { + goto exit; + } + result = PyObject_GetIter(tuple); +exit: + Py_XDECREF(typing); + Py_XDECREF(unpack); + Py_XDECREF(unpacked); + Py_XDECREF(tuple); + return result; } static PyObject *typevartupleobject_repr(PyObject *self) From c7c1618c50f7217bbc50f853c68a0acd12e55d3b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 14 Apr 2023 19:55:30 -0700 Subject: [PATCH 011/200] Just call typing.py --- .../pycore_global_objects_fini_generated.h | 2 + Include/internal/pycore_global_strings.h | 2 + .../internal/pycore_runtime_init_generated.h | 2 + .../internal/pycore_unicodeobject_generated.h | 6 + Lib/typing.py | 7 ++ Objects/clinic/typevarobject.c.h | 116 +++++++++++++++++- Objects/typevarobject.c | 102 ++++++++++++--- 7 files changed, 220 insertions(+), 17 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 8b6fd26141bca7..267a2792e3e2cc 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -780,9 +780,11 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_child)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(after_in_parent)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(aggregate_class)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(alias)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(append)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arg)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argdefs)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(args)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(arguments)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(argv)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(as_integer_ratio)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index abf2cb587bb960..359a18a3c97656 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -266,9 +266,11 @@ struct _Py_global_strings { STRUCT_FOR_ID(after_in_child) STRUCT_FOR_ID(after_in_parent) STRUCT_FOR_ID(aggregate_class) + STRUCT_FOR_ID(alias) STRUCT_FOR_ID(append) STRUCT_FOR_ID(arg) STRUCT_FOR_ID(argdefs) + STRUCT_FOR_ID(args) STRUCT_FOR_ID(arguments) STRUCT_FOR_ID(argv) STRUCT_FOR_ID(as_integer_ratio) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 707b438d253123..375f206b04871c 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -772,9 +772,11 @@ extern "C" { INIT_ID(after_in_child), \ INIT_ID(after_in_parent), \ INIT_ID(aggregate_class), \ + INIT_ID(alias), \ INIT_ID(append), \ INIT_ID(arg), \ INIT_ID(argdefs), \ + INIT_ID(args), \ INIT_ID(arguments), \ INIT_ID(argv), \ INIT_ID(as_integer_ratio), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 867d9a8b48e200..3ef42073c19bd4 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -651,6 +651,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(aggregate_class); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(alias); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(append); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); @@ -660,6 +663,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(argdefs); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(args); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(arguments); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Lib/typing.py b/Lib/typing.py index 505cccaf077948..ef5843b6abf876 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1070,6 +1070,8 @@ def __typing_subst__(self, arg): raise TypeError(f"{arg} is not valid as type argument") return arg +_typevar_subst = TypeVar.__typing_subst__ + class TypeVarTuple(_Final, _Immutable, _PickleUsingNameMixin, _root=True): """Type variable tuple. @@ -1152,6 +1154,8 @@ def __typing_prepare_subst__(self, alias, args): def __mro_entries__(self, bases): raise TypeError(f"Cannot subclass an instance of {type(self).__name__}") +_typevartuple_prepare_subst = TypeVarTuple.__typing_prepare_subst__ + class ParamSpecArgs(_Final, _Immutable, _root=True): """The args for a ParamSpec object. @@ -1292,6 +1296,9 @@ def __typing_prepare_subst__(self, alias, args): args = (*args[:i], tuple(args[i]), *args[i+1:]) return args +_paramspec_subst = ParamSpec.__typing_subst__ +_paramspec_prepare_subst = ParamSpec.__typing_prepare_subst__ + import builtins if hasattr(builtins, "TypeVar"): diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index 6cb9966fb8074b..0dc023c82bba2a 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -438,6 +438,63 @@ paramspec_typing_subst(paramspecobject *self, PyObject *const *args, Py_ssize_t return return_value; } +PyDoc_STRVAR(paramspec_typing_prepare_subst__doc__, +"__typing_prepare_subst__($self, /, alias, args)\n" +"--\n" +"\n"); + +#define PARAMSPEC_TYPING_PREPARE_SUBST_METHODDEF \ + {"__typing_prepare_subst__", _PyCFunction_CAST(paramspec_typing_prepare_subst), METH_FASTCALL|METH_KEYWORDS, paramspec_typing_prepare_subst__doc__}, + +static PyObject * +paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias, + PyObject *args); + +static PyObject * +paramspec_typing_prepare_subst(paramspecobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(alias), &_Py_ID(args), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"alias", "args", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "__typing_prepare_subst__", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject *alias; + PyObject *__clinic_args; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + alias = args[0]; + __clinic_args = args[1]; + return_value = paramspec_typing_prepare_subst_impl(self, alias, __clinic_args); + +exit: + return return_value; +} + PyDoc_STRVAR(typevartuple__doc__, "typevartuple(name)\n" "--\n" @@ -557,4 +614,61 @@ typevartuple_typing_subst(typevartupleobject *self, PyObject *const *args, Py_ss exit: return return_value; } -/*[clinic end generated code: output=06d91d3e010cd9de input=a9049054013a1b77]*/ + +PyDoc_STRVAR(typevartuple_typing_prepare_subst__doc__, +"__typing_prepare_subst__($self, /, alias, args)\n" +"--\n" +"\n"); + +#define TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF \ + {"__typing_prepare_subst__", _PyCFunction_CAST(typevartuple_typing_prepare_subst), METH_FASTCALL|METH_KEYWORDS, typevartuple_typing_prepare_subst__doc__}, + +static PyObject * +typevartuple_typing_prepare_subst_impl(typevartupleobject *self, + PyObject *alias, PyObject *args); + +static PyObject * +typevartuple_typing_prepare_subst(typevartupleobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 2 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(alias), &_Py_ID(args), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"alias", "args", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "__typing_prepare_subst__", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[2]; + PyObject *alias; + PyObject *__clinic_args; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); + if (!args) { + goto exit; + } + alias = args[0]; + __clinic_args = args[1]; + return_value = typevartuple_typing_prepare_subst_impl(self, alias, __clinic_args); + +exit: + return return_value; +} +/*[clinic end generated code: output=b2896de46c103443 input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index e94de49fa2a5d3..7bf3ea330afa96 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -39,6 +39,35 @@ typedef struct { #include "clinic/typevarobject.c.h" +static PyObject *call_typing_func_object(const char *name, PyObject *args) { + PyObject *typing = PyImport_ImportModule("typing"); + if (typing == NULL) { + return NULL; + } + PyObject *type_check = PyObject_GetAttrString(typing, name); + if (type_check == NULL) { + Py_DECREF(typing); + return NULL; + } + PyObject *result = PyObject_CallObject(type_check, args); + Py_DECREF(type_check); + Py_DECREF(typing); + return result; +} + +static PyObject *type_check(PyObject *arg) { + // Calling typing.py here leads to bootstrapping problems + if (Py_IsNone(arg)) { + return Py_NewRef(Py_TYPE(arg)); + } + // TODO: real error message + PyObject *args = PyTuple_Pack(2, arg, Py_None); + if (args == NULL) { + return NULL; + } + return call_typing_func_object("_type_check", args); +} + static void typevarobject_dealloc(PyObject *self) { typevarobject *tv = (typevarobject *)self; @@ -176,9 +205,11 @@ static PyObject * typevar_typing_subst_impl(typevarobject *self, PyObject *arg) /*[clinic end generated code: output=c76ced134ed8f4e1 input=6b70a4bb2da838de]*/ { - // TODO _type_check - // TODO reject Unpack[] - return Py_NewRef(arg); + PyObject *args = PyTuple_Pack(2, self, arg); + if (args == NULL) { + return NULL; + } + return call_typing_func_object("_typevar_subst", args); } static PyMethodDef typevar_methods[] = { @@ -488,7 +519,12 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with autovariance."); return NULL; } - // TODO typing._type_check on bound + if (bound != NULL) { + bound = type_check(bound); + if (bound == NULL) { + return NULL; + } + } return (PyObject *)paramspecobject_alloc(name, bound, covariant, contravariant, autovariance); } @@ -504,27 +540,42 @@ static PyObject * paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg) /*[clinic end generated code: output=803e1ade3f13b57d input=4e0005d24023e896]*/ { - if (PyTuple_Check(arg)) { - return Py_NewRef(arg); - } else if (PyList_Check(arg)) { - return PyList_AsTuple(arg); - } else { - // TODO: typing._is_param_expr - // (in particular _ConcatenateGenericAlias) - return Py_NewRef(arg); + PyObject *args = PyTuple_Pack(2, self, arg); + if (args == NULL) { + return NULL; + } + return call_typing_func_object("_paramspec_subst", args); +} + +/*[clinic input] +paramspec.__typing_prepare_subst__ as paramspec_typing_prepare_subst + + alias: object + args: object + +[clinic start generated code]*/ + +static PyObject * +paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias, + PyObject *args) +/*[clinic end generated code: output=95449d630a2adb9a input=4375e2ffcb2ad635]*/ +{ + PyObject *args_tuple = PyTuple_Pack(3, self, alias, args); + if (args_tuple == NULL) { + return NULL; } + return call_typing_func_object("_paramspec_prepare_subst", args_tuple); } static PyMethodDef paramspec_methods[] = { PARAMSPEC_TYPING_SUBST_METHODDEF + PARAMSPEC_TYPING_PREPARE_SUBST_METHODDEF {0} }; // TODO: -// - args/kwargs // - pickling -// - __typing_prepare_subst__ PyTypeObject _PyParamSpec_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.ParamSpec", @@ -639,15 +690,34 @@ typevartuple_typing_subst_impl(typevartupleobject *self, PyObject *arg) return NULL; } +/*[clinic input] +typevartuple.__typing_prepare_subst__ as typevartuple_typing_prepare_subst + + alias: object + args: object + +[clinic start generated code]*/ + +static PyObject * +typevartuple_typing_prepare_subst_impl(typevartupleobject *self, + PyObject *alias, PyObject *args) +/*[clinic end generated code: output=ff999bc5b02036c1 input=a211b05f2eeb4306]*/ +{ + PyObject *args_tuple = PyTuple_Pack(3, self, alias, args); + if (args_tuple == NULL) { + return NULL; + } + return call_typing_func_object("_typevartuple_prepare_subst", args_tuple); +} + static PyMethodDef typevartuple_methods[] = { TYPEVARTUPLE_TYPING_SUBST_METHODDEF + TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF {0} }; // TODO: -// - Iterable (for Unpack) // - Pickling -// - __typing_subst__/__typing_prepare_subst__ PyTypeObject _PyTypeVarTuple_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.TypeVarTuple", From 772920f1713d786dcb3121b0f64f527f924687de Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 14 Apr 2023 20:02:43 -0700 Subject: [PATCH 012/200] attempt at pickling --- Lib/typing.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Lib/typing.py b/Lib/typing.py index ef5843b6abf876..44de6c24954b2a 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1308,6 +1308,45 @@ def __typing_prepare_subst__(self, alias, args): ParamSpecArgs = type(ParamSpec("P").args) ParamSpecKwargs = type(ParamSpec("P").kwargs) + import copyreg + + def _make_typevar(name, bound, constraints, covariant, contravariant, autovariance): + return TypeVar(name, *constraints, bound=bound, + covariant=covariant, contravariant=contravariant, + autovariance=autovariance) + + def _pickle_tv(tv): + return _make_typevar, (tv.__name__, tv.__bound__, tv.__constraints__, + tv.__covariant__, tv.__contravariant__, tv.__autovariance__) + + copyreg.pickle(TypeVar, _pickle_tv) + + def _pickle_tvt(tvt): + return TypeVarTuple, (tvt.__name__,) + + copyreg.pickle(TypeVarTuple, _pickle_tvt) + + def _make_paramspec(name, bound, covariant, contravariant, autovariance): + return ParamSpec(name, bound=bound, + covariant=covariant, contravariant=contravariant, + autovariance=autovariance) + + def _pickle_ps(ps): + return _make_paramspec, (ps.__name__, ps.__bound__, + ps.__covariant__, ps.__contravariant__, ps.__autovariance__) + + copyreg.pickle(ParamSpec, _pickle_ps) + + def _pickle_psargs(psargs): + return ParamSpecArgs, (psargs.__origin__,) + + copyreg.pickle(ParamSpecArgs, _pickle_psargs) + + def _pickle_pskwargs(pskwargs): + return ParamSpecKwargs, (pskwargs.__origin__,) + + copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) + def _is_dunder(attr): return attr.startswith('__') and attr.endswith('__') From 6ff6f5a7df32da898e833027b68ce5df8d46a42f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 14 Apr 2023 20:08:15 -0700 Subject: [PATCH 013/200] better approach --- Lib/typing.py | 27 ---------------- Objects/clinic/typevarobject.c.h | 53 +++++++++++++++++++++++++++++++- Objects/typevarobject.c | 39 +++++++++++++++++++++++ 3 files changed, 91 insertions(+), 28 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index 44de6c24954b2a..8c26aa9a592bf0 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1310,33 +1310,6 @@ def __typing_prepare_subst__(self, alias, args): import copyreg - def _make_typevar(name, bound, constraints, covariant, contravariant, autovariance): - return TypeVar(name, *constraints, bound=bound, - covariant=covariant, contravariant=contravariant, - autovariance=autovariance) - - def _pickle_tv(tv): - return _make_typevar, (tv.__name__, tv.__bound__, tv.__constraints__, - tv.__covariant__, tv.__contravariant__, tv.__autovariance__) - - copyreg.pickle(TypeVar, _pickle_tv) - - def _pickle_tvt(tvt): - return TypeVarTuple, (tvt.__name__,) - - copyreg.pickle(TypeVarTuple, _pickle_tvt) - - def _make_paramspec(name, bound, covariant, contravariant, autovariance): - return ParamSpec(name, bound=bound, - covariant=covariant, contravariant=contravariant, - autovariance=autovariance) - - def _pickle_ps(ps): - return _make_paramspec, (ps.__name__, ps.__bound__, - ps.__covariant__, ps.__contravariant__, ps.__autovariance__) - - copyreg.pickle(ParamSpec, _pickle_ps) - def _pickle_psargs(psargs): return ParamSpecArgs, (psargs.__origin__,) diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index 0dc023c82bba2a..bf96d9815998a4 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -171,6 +171,23 @@ typevar_typing_subst(typevarobject *self, PyObject *const *args, Py_ssize_t narg return return_value; } +PyDoc_STRVAR(typevar_reduce__doc__, +"__reduce__($self, /)\n" +"--\n" +"\n"); + +#define TYPEVAR_REDUCE_METHODDEF \ + {"__reduce__", (PyCFunction)typevar_reduce, METH_NOARGS, typevar_reduce__doc__}, + +static PyObject * +typevar_reduce_impl(typevarobject *self); + +static PyObject * +typevar_reduce(typevarobject *self, PyObject *Py_UNUSED(ignored)) +{ + return typevar_reduce_impl(self); +} + PyDoc_STRVAR(paramspecargs_new__doc__, "paramspecargs(origin)\n" "--\n" @@ -495,6 +512,23 @@ paramspec_typing_prepare_subst(paramspecobject *self, PyObject *const *args, Py_ return return_value; } +PyDoc_STRVAR(paramspec_reduce__doc__, +"__reduce__($self, /)\n" +"--\n" +"\n"); + +#define PARAMSPEC_REDUCE_METHODDEF \ + {"__reduce__", (PyCFunction)paramspec_reduce, METH_NOARGS, paramspec_reduce__doc__}, + +static PyObject * +paramspec_reduce_impl(paramspecobject *self); + +static PyObject * +paramspec_reduce(paramspecobject *self, PyObject *Py_UNUSED(ignored)) +{ + return paramspec_reduce_impl(self); +} + PyDoc_STRVAR(typevartuple__doc__, "typevartuple(name)\n" "--\n" @@ -671,4 +705,21 @@ typevartuple_typing_prepare_subst(typevartupleobject *self, PyObject *const *arg exit: return return_value; } -/*[clinic end generated code: output=b2896de46c103443 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(typevartuple_reduce__doc__, +"__reduce__($self, /)\n" +"--\n" +"\n"); + +#define TYPEVARTUPLE_REDUCE_METHODDEF \ + {"__reduce__", (PyCFunction)typevartuple_reduce, METH_NOARGS, typevartuple_reduce__doc__}, + +static PyObject * +typevartuple_reduce_impl(typevartupleobject *self); + +static PyObject * +typevartuple_reduce(typevartupleobject *self, PyObject *Py_UNUSED(ignored)) +{ + return typevartuple_reduce_impl(self); +} +/*[clinic end generated code: output=ac9f83f64eee2f90 input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 7bf3ea330afa96..07b369f1a0236e 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -212,8 +212,21 @@ typevar_typing_subst_impl(typevarobject *self, PyObject *arg) return call_typing_func_object("_typevar_subst", args); } +/*[clinic input] +typevar.__reduce__ as typevar_reduce + +[clinic start generated code]*/ + +static PyObject * +typevar_reduce_impl(typevarobject *self) +/*[clinic end generated code: output=02e5c55d7cf8a08f input=de76bc95f04fb9ff]*/ +{ + return PyUnicode_FromString(self->name); +} + static PyMethodDef typevar_methods[] = { TYPEVAR_TYPING_SUBST_METHODDEF + TYPEVAR_REDUCE_METHODDEF {0} }; @@ -567,9 +580,22 @@ paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias, return call_typing_func_object("_paramspec_prepare_subst", args_tuple); } +/*[clinic input] +paramspec.__reduce__ as paramspec_reduce + +[clinic start generated code]*/ + +static PyObject * +paramspec_reduce_impl(paramspecobject *self) +/*[clinic end generated code: output=b83398674416db27 input=5bf349f0d5dd426c]*/ +{ + return PyUnicode_FromString(self->name); +} + static PyMethodDef paramspec_methods[] = { PARAMSPEC_TYPING_SUBST_METHODDEF PARAMSPEC_TYPING_PREPARE_SUBST_METHODDEF + PARAMSPEC_REDUCE_METHODDEF {0} }; @@ -710,9 +736,22 @@ typevartuple_typing_prepare_subst_impl(typevartupleobject *self, return call_typing_func_object("_typevartuple_prepare_subst", args_tuple); } +/*[clinic input] +typevartuple.__reduce__ as typevartuple_reduce + +[clinic start generated code]*/ + +static PyObject * +typevartuple_reduce_impl(typevartupleobject *self) +/*[clinic end generated code: output=3215bc0477913d20 input=3018a4d66147e807]*/ +{ + return PyUnicode_FromString(self->name); +} + static PyMethodDef typevartuple_methods[] = { TYPEVARTUPLE_TYPING_SUBST_METHODDEF TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF + TYPEVARTUPLE_REDUCE_METHODDEF {0} }; From 9fdf3737a5c514167bace3d62f97a297ee7eca01 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 14 Apr 2023 20:23:02 -0700 Subject: [PATCH 014/200] fix a few tests and refcount bugs --- Lib/test/test_typing.py | 11 ++++----- Objects/typevarobject.c | 49 +++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index b8eee9a570a301..c0060dac361cf7 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -53,6 +53,7 @@ CANNOT_SUBCLASS_TYPE = 'Cannot subclass special typing classes' +NOT_A_BASE_TYPE = "type 'typing.%s' is not an acceptable base type" CANNOT_SUBCLASS_INSTANCE = 'Cannot subclass an instance of %s' @@ -430,7 +431,7 @@ def test_no_redefinition(self): self.assertNotEqual(TypeVar('T', int, str), TypeVar('T', int, str)) def test_cannot_subclass(self): - with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE): + with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'TypeVar'): class V(TypeVar): pass T = TypeVar("T") with self.assertRaisesRegex(TypeError, @@ -1148,7 +1149,7 @@ class A(Generic[Unpack[Ts]]): pass self.assertEndsWith(repr(K[float, str]), 'A[float, str, *typing.Tuple[str, ...]]') def test_cannot_subclass(self): - with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE): + with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'TypeVarTuple'): class C(TypeVarTuple): pass Ts = TypeVarTuple('Ts') with self.assertRaisesRegex(TypeError, @@ -8008,11 +8009,11 @@ def test_paramspec_gets_copied(self): self.assertEqual(C2[Concatenate[T, P2]].__parameters__, (T, P2)) def test_cannot_subclass(self): - with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE): + with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'ParamSpec'): class C(ParamSpec): pass - with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE): + with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'ParamSpecArgs'): class C(ParamSpecArgs): pass - with self.assertRaisesRegex(TypeError, CANNOT_SUBCLASS_TYPE): + with self.assertRaisesRegex(TypeError, NOT_A_BASE_TYPE % 'ParamSpecKwargs'): class C(ParamSpecKwargs): pass P = ParamSpec('P') with self.assertRaisesRegex(TypeError, diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 07b369f1a0236e..b2d346cd1ec20b 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -44,13 +44,13 @@ static PyObject *call_typing_func_object(const char *name, PyObject *args) { if (typing == NULL) { return NULL; } - PyObject *type_check = PyObject_GetAttrString(typing, name); - if (type_check == NULL) { + PyObject *func = PyObject_GetAttrString(typing, name); + if (func == NULL) { Py_DECREF(typing); return NULL; } - PyObject *result = PyObject_CallObject(type_check, args); - Py_DECREF(type_check); + PyObject *result = PyObject_CallObject(func, args); + Py_DECREF(func); Py_DECREF(typing); return result; } @@ -171,6 +171,16 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, return NULL; } + if (Py_IsNone(bound)) { + bound = NULL; + } + if (bound != NULL) { + bound = type_check(bound); + if (bound == NULL) { + return NULL; + } + } + if (!PyTuple_CheckExact(constraints)) { PyErr_SetString(PyExc_TypeError, "constraints must be a tuple"); @@ -180,18 +190,22 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, if (n_constraints == 1) { PyErr_SetString(PyExc_TypeError, "A single constraint is not allowed"); + Py_XDECREF(bound); return NULL; } else if (n_constraints == 0) { constraints = NULL; + } else if (bound != NULL) { + PyErr_SetString(PyExc_TypeError, + "Constraints cannot be combined with bound=..."); + Py_XDECREF(bound); + return NULL; } - if (Py_IsNone(bound)) { - bound = NULL; - } - - return (PyObject *)typevarobject_alloc(name, bound, constraints, - covariant, contravariant, - autovariance); + PyObject *tv = (PyObject *)typevarobject_alloc(name, bound, constraints, + covariant, contravariant, + autovariance); + Py_XDECREF(bound); + return tv; } /*[clinic input] @@ -272,6 +286,10 @@ static PyObject *paramspecargsobject_repr(PyObject *self) { paramspecargsobject *psa = (paramspecargsobject *)self; + if (Py_IS_TYPE(psa->__origin__, &_PyParamSpec_Type)) { + return PyUnicode_FromFormat("%s.args", + ((paramspecobject *)psa->__origin__)->name); + } return PyUnicode_FromFormat("%R.args", psa->__origin__); } @@ -364,6 +382,10 @@ static PyObject *paramspeckwargsobject_repr(PyObject *self) { paramspeckwargsobject *psk = (paramspeckwargsobject *)self; + if (Py_IS_TYPE(psk->__origin__, &_PyParamSpec_Type)) { + return PyUnicode_FromFormat("%s.kwargs", + ((paramspecobject *)psk->__origin__)->name); + } return PyUnicode_FromFormat("%R.kwargs", psk->__origin__); } @@ -538,7 +560,10 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, return NULL; } } - return (PyObject *)paramspecobject_alloc(name, bound, covariant, contravariant, autovariance); + PyObject *ps = (PyObject *)paramspecobject_alloc( + name, bound, covariant, contravariant, autovariance); + Py_XDECREF(bound); + return ps; } From f7c513d269c4856f18246d990413429d53cb9a2e Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 16 Apr 2023 12:13:13 +0200 Subject: [PATCH 015/200] Use Name expr for TypeAlias --- Grammar/python.gram | 3 ++- Include/internal/pycore_ast.h | 8 ++++---- Lib/ast.py | 3 ++- Parser/Python.asdl | 2 +- Parser/parser.c | 2 +- Python/Python-ast.c | 14 +++++++------- Python/ast.c | 3 ++- Python/ast_opt.c | 2 ++ 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 1169ddbb7b5122..6ab09de4fc149a 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -634,7 +634,8 @@ keyword_pattern[KeyPatternPair*]: type_alias[stmt_ty]: | "type" n=NAME t=[type_params] '=' b=expression { - CHECK_VERSION(stmt_ty, 12, "Type statement is", _PyAST_TypeAlias(n->v.Name.id, t, b, EXTRA)) } + CHECK_VERSION(stmt_ty, 12, "Type statement is", + _PyAST_TypeAlias(CHECK(expr_ty, _PyPegen_set_expr_context(p, n, Store)), t, b, EXTRA)) } # Type parameter declaration # -------------------------- diff --git a/Include/internal/pycore_ast.h b/Include/internal/pycore_ast.h index caba84650e1eb9..9f1cef0541508c 100644 --- a/Include/internal/pycore_ast.h +++ b/Include/internal/pycore_ast.h @@ -239,7 +239,7 @@ struct _stmt { } Assign; struct { - identifier name; + expr_ty name; asdl_typeparam_seq *typeparams; expr_ty value; } TypeAlias; @@ -704,9 +704,9 @@ stmt_ty _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int stmt_ty _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); -stmt_ty _PyAST_TypeAlias(identifier name, asdl_typeparam_seq * typeparams, - expr_ty value, int lineno, int col_offset, int - end_lineno, int end_col_offset, PyArena *arena); +stmt_ty _PyAST_TypeAlias(expr_ty name, asdl_typeparam_seq * typeparams, expr_ty + value, int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena); stmt_ty _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); diff --git a/Lib/ast.py b/Lib/ast.py index 34122f04267a2c..93afa7d8035de8 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1070,7 +1070,8 @@ def visit_ParamSpec(self, node): self.write("**" + node.name) def visit_TypeAlias(self, node): - self.fill("type " + node.name) + self.fill("type ") + self.traverse(node.name) self._typeparams_helper(node.typeparams) self.write(" = ") self.traverse(node.value) diff --git a/Parser/Python.asdl b/Parser/Python.asdl index db0f12a5f46ebe..cfc41ef45b568b 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -25,7 +25,7 @@ module Python | Delete(expr* targets) | Assign(expr* targets, expr value, string? type_comment) - | TypeAlias(identifier name, typeparam* typeparams, expr value) + | TypeAlias(expr name, typeparam* typeparams, expr value) | AugAssign(expr target, operator op, expr value) -- 'simple' indicates that we annotate simple name without parens | AnnAssign(expr target, expr annotation, expr? value, int simple) diff --git a/Parser/parser.c b/Parser/parser.c index 091b12c11c094e..cf0a12f3eb6fb0 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -10563,7 +10563,7 @@ type_alias_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 = CHECK_VERSION ( stmt_ty , 12 , "Type statement is" , _PyAST_TypeAlias ( n -> v . Name . id , t , b , EXTRA ) ); + _res = CHECK_VERSION ( stmt_ty , 12 , "Type statement is" , _PyAST_TypeAlias ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , n , Store ) ) , t , b , EXTRA ) ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index c30f3f851e37cb..7124d6c0c25eb8 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -1175,7 +1175,7 @@ init_types(struct ast_state *state) " | Return(expr? value)\n" " | Delete(expr* targets)\n" " | Assign(expr* targets, expr value, string? type_comment)\n" - " | TypeAlias(identifier name, typeparam* typeparams, expr value)\n" + " | TypeAlias(expr name, typeparam* typeparams, expr value)\n" " | AugAssign(expr target, operator op, expr value)\n" " | AnnAssign(expr target, expr annotation, expr? value, int simple)\n" " | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n" @@ -1248,7 +1248,7 @@ init_types(struct ast_state *state) return 0; state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type, TypeAlias_fields, 3, - "TypeAlias(identifier name, typeparam* typeparams, expr value)"); + "TypeAlias(expr name, typeparam* typeparams, expr value)"); if (!state->TypeAlias_type) return 0; state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type, AugAssign_fields, 3, @@ -2192,8 +2192,8 @@ _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int } stmt_ty -_PyAST_TypeAlias(identifier name, asdl_typeparam_seq * typeparams, expr_ty - value, int lineno, int col_offset, int end_lineno, int +_PyAST_TypeAlias(expr_ty name, asdl_typeparam_seq * typeparams, expr_ty value, + int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) { stmt_ty p; @@ -4047,7 +4047,7 @@ ast2obj_stmt(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->TypeAlias_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_identifier(state, o->v.TypeAlias.name); + value = ast2obj_expr(state, o->v.TypeAlias.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -6846,7 +6846,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* return 1; } if (isinstance) { - identifier name; + expr_ty name; asdl_typeparam_seq* typeparams; expr_ty value; @@ -6862,7 +6862,7 @@ obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena* if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) { goto failed; } - res = obj2ast_identifier(state, tmp, &name, arena); + res = obj2ast_expr(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); diff --git a/Python/ast.c b/Python/ast.c index c3e202047f8705..9f616e4d87ca05 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -747,7 +747,8 @@ validate_stmt(struct validator *state, stmt_ty stmt) validate_expr(state, stmt->v.AnnAssign.annotation, Load); break; case TypeAlias_kind: - ret = validate_expr(state, stmt->v.TypeAlias.value, Load); + ret = validate_name(stmt->v.TypeAlias.name->v.Name.id) && + validate_expr(state, stmt->v.TypeAlias.value, Load); break; case For_kind: ret = validate_expr(state, stmt->v.For.target, Store) && diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 53984be7655c14..6d2a77b2676266 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -924,6 +924,8 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) CALL_OPT(astfold_expr, expr_ty, node_->v.AnnAssign.value); break; case TypeAlias_kind: + CALL(astfold_expr, expr_ty, node_->v.TypeAlias.name); + CALL_SEQ(astfold_stmt, typeparam, node_->v.TypeAlias.typeparams); CALL(astfold_expr, expr_ty, node_->v.TypeAlias.value); break; case For_kind: From 1d7b035d1673d8dbf83681d48365f01c5f9a35ef Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 16 Apr 2023 12:14:37 +0200 Subject: [PATCH 016/200] Add ast optimizer for typeparam --- Python/ast_opt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 6d2a77b2676266..3b27794e67239b 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -643,6 +643,7 @@ static int astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeStat static int astfold_excepthandler(excepthandler_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); static int astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); static int astfold_pattern(pattern_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); +static int astfold_typeparam(typeparam_ty node_, PyArena *ctx_, _PyASTOptimizeState *state); #define CALL(FUNC, TYPE, ARG) \ if (!FUNC((ARG), ctx_, state)) \ @@ -925,7 +926,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) break; case TypeAlias_kind: CALL(astfold_expr, expr_ty, node_->v.TypeAlias.name); - CALL_SEQ(astfold_stmt, typeparam, node_->v.TypeAlias.typeparams); + CALL_SEQ(astfold_typeparam, typeparam, node_->v.TypeAlias.typeparams); CALL(astfold_expr, expr_ty, node_->v.TypeAlias.value); break; case For_kind: @@ -1080,6 +1081,21 @@ astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *stat return 1; } +static int +astfold_typeparam(typeparam_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) +{ + switch (node_->kind) { + case TypeVar_kind: + CALL_OPT(astfold_expr, expr_ty, node_->v.TypeVar.bound); + break; + case ParamSpec_kind: + break; + case TypeVarTuple_kind: + break; + } + return 1; +} + #undef CALL #undef CALL_OPT #undef CALL_SEQ From 85a4409457ee31ec37932c46c1de47edd6799d05 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 16 Apr 2023 13:01:51 +0200 Subject: [PATCH 017/200] Use Name expr for TypeParameter --- Grammar/python.gram | 7 +++--- Include/internal/pycore_ast.h | 14 ++++++------ Lib/ast.py | 8 ++++--- Parser/Python.asdl | 6 ++--- Parser/parser.c | 6 ++--- Python/Python-ast.c | 40 +++++++++++++++++----------------- Python/ast.c | 41 +++++++++++++++++++++++++++++++++++ Python/ast_opt.c | 6 +++++ 8 files changed, 89 insertions(+), 39 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 6ab09de4fc149a..20ef9c1a3dafe5 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -645,9 +645,10 @@ type_params[asdl_typeparam_seq*]: '[' t=type_param_seq ']' { t } type_param_seq[asdl_typeparam_seq*]: a[asdl_typeparam_seq*]=','.type_param+ [','] { a } type_param[typeparam_ty] (memo): - | a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) } - | '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) } - | '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) } + | a=NAME b=[type_param_bound] { _PyAST_TypeVar( + CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, EXTRA) } + | '*' a=NAME { _PyAST_TypeVarTuple(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), EXTRA) } + | '**' a=NAME { _PyAST_ParamSpec(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), EXTRA) } type_param_bound[expr_ty]: ":" e=expression { e } diff --git a/Include/internal/pycore_ast.h b/Include/internal/pycore_ast.h index 9f1cef0541508c..8b61830ddd1eb6 100644 --- a/Include/internal/pycore_ast.h +++ b/Include/internal/pycore_ast.h @@ -654,16 +654,16 @@ struct _typeparam { enum _typeparam_kind kind; union { struct { - identifier name; + expr_ty name; expr_ty bound; } TypeVar; struct { - identifier name; + expr_ty name; } ParamSpec; struct { - identifier name; + expr_ty name; } TypeVarTuple; } v; @@ -891,13 +891,13 @@ pattern_ty _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); type_ignore_ty _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena); -typeparam_ty _PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int +typeparam_ty _PyAST_TypeVar(expr_ty name, expr_ty bound, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); -typeparam_ty _PyAST_ParamSpec(identifier name, int lineno, int col_offset, int +typeparam_ty _PyAST_ParamSpec(expr_ty name, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); -typeparam_ty _PyAST_TypeVarTuple(identifier name, int lineno, int col_offset, - int end_lineno, int end_col_offset, PyArena +typeparam_ty _PyAST_TypeVarTuple(expr_ty name, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena); diff --git a/Lib/ast.py b/Lib/ast.py index 93afa7d8035de8..560cf5c020bff7 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1058,16 +1058,18 @@ def _typeparams_helper(self, typeparams): self.interleave(lambda: self.write(", "), self.traverse, typeparams) def visit_TypeVar(self, node): - self.write(node.name) + self.traverse(node.name) if node.bound: self.write(": ") self.traverse(node.bound) def visit_TypeVarTuple(self, node): - self.write("*" + node.name) + self.write("*") + self.traverse(node.name) def visit_ParamSpec(self, node): - self.write("**" + node.name) + self.write("**") + self.traverse(node.name) def visit_TypeAlias(self, node): self.fill("type ") diff --git a/Parser/Python.asdl b/Parser/Python.asdl index cfc41ef45b568b..6b34b584568f7b 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -145,8 +145,8 @@ module Python type_ignore = TypeIgnore(int lineno, string tag) - typeparam = TypeVar(identifier name, expr? bound) - | ParamSpec(identifier name) - | TypeVarTuple(identifier name) + typeparam = TypeVar(expr name, expr? bound) + | ParamSpec(expr name) + | TypeVarTuple(expr name) attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) } diff --git a/Parser/parser.c b/Parser/parser.c index cf0a12f3eb6fb0..955da6b481cf39 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -10730,7 +10730,7 @@ type_param_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 = _PyAST_TypeVar ( a -> v . Name . id , b , EXTRA ); + _res = _PyAST_TypeVar ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -10766,7 +10766,7 @@ type_param_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 = _PyAST_TypeVarTuple ( a -> v . Name . id , EXTRA ); + _res = _PyAST_TypeVarTuple ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -10802,7 +10802,7 @@ type_param_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 = _PyAST_ParamSpec ( a -> v . Name . id , EXTRA ); + _res = _PyAST_ParamSpec ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 7124d6c0c25eb8..f00b710cb323b8 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -1896,9 +1896,9 @@ init_types(struct ast_state *state) if (!state->TypeIgnore_type) return 0; state->typeparam_type = make_type(state, "typeparam", state->AST_type, NULL, 0, - "typeparam = TypeVar(identifier name, expr? bound)\n" - " | ParamSpec(identifier name)\n" - " | TypeVarTuple(identifier name)"); + "typeparam = TypeVar(expr name, expr? bound)\n" + " | ParamSpec(expr name)\n" + " | TypeVarTuple(expr name)"); if (!state->typeparam_type) return 0; if (!add_attributes(state, state->typeparam_type, typeparam_attributes, 4)) return 0; @@ -1910,19 +1910,19 @@ init_types(struct ast_state *state) return 0; state->TypeVar_type = make_type(state, "TypeVar", state->typeparam_type, TypeVar_fields, 2, - "TypeVar(identifier name, expr? bound)"); + "TypeVar(expr name, expr? bound)"); if (!state->TypeVar_type) return 0; if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1) return 0; state->ParamSpec_type = make_type(state, "ParamSpec", state->typeparam_type, ParamSpec_fields, 1, - "ParamSpec(identifier name)"); + "ParamSpec(expr name)"); if (!state->ParamSpec_type) return 0; state->TypeVarTuple_type = make_type(state, "TypeVarTuple", state->typeparam_type, TypeVarTuple_fields, 1, - "TypeVarTuple(identifier name)"); + "TypeVarTuple(expr name)"); if (!state->TypeVarTuple_type) return 0; state->recursion_depth = 0; @@ -3714,7 +3714,7 @@ _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena) } typeparam_ty -_PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int col_offset, int +_PyAST_TypeVar(expr_ty name, expr_ty bound, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) { typeparam_ty p; @@ -3737,8 +3737,8 @@ _PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int col_offset, int } typeparam_ty -_PyAST_ParamSpec(identifier name, int lineno, int col_offset, int end_lineno, - int end_col_offset, PyArena *arena) +_PyAST_ParamSpec(expr_ty name, int lineno, int col_offset, int end_lineno, int + end_col_offset, PyArena *arena) { typeparam_ty p; if (!name) { @@ -3759,8 +3759,8 @@ _PyAST_ParamSpec(identifier name, int lineno, int col_offset, int end_lineno, } typeparam_ty -_PyAST_TypeVarTuple(identifier name, int lineno, int col_offset, int - end_lineno, int end_col_offset, PyArena *arena) +_PyAST_TypeVarTuple(expr_ty name, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena) { typeparam_ty p; if (!name) { @@ -5674,7 +5674,7 @@ ast2obj_typeparam(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->TypeVar_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_identifier(state, o->v.TypeVar.name); + value = ast2obj_expr(state, o->v.TypeVar.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -5689,7 +5689,7 @@ ast2obj_typeparam(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->ParamSpec_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_identifier(state, o->v.ParamSpec.name); + value = ast2obj_expr(state, o->v.ParamSpec.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -5699,7 +5699,7 @@ ast2obj_typeparam(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->TypeVarTuple_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_identifier(state, o->v.TypeVarTuple.name); + value = ast2obj_expr(state, o->v.TypeVarTuple.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -12383,7 +12383,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, return 1; } if (isinstance) { - identifier name; + expr_ty name; expr_ty bound; if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { @@ -12398,7 +12398,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) { goto failed; } - res = obj2ast_identifier(state, tmp, &name, arena); + res = obj2ast_expr(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); @@ -12431,7 +12431,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, return 1; } if (isinstance) { - identifier name; + expr_ty name; if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { return 1; @@ -12445,7 +12445,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) { goto failed; } - res = obj2ast_identifier(state, tmp, &name, arena); + res = obj2ast_expr(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); @@ -12461,7 +12461,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, return 1; } if (isinstance) { - identifier name; + expr_ty name; if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { return 1; @@ -12475,7 +12475,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) { goto failed; } - res = obj2ast_identifier(state, tmp, &name, arena); + res = obj2ast_expr(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); diff --git a/Python/ast.c b/Python/ast.c index 9f616e4d87ca05..66b03d1c7f0309 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -17,10 +17,12 @@ struct validator { static int validate_stmts(struct validator *, asdl_stmt_seq *); static int validate_exprs(struct validator *, asdl_expr_seq *, expr_context_ty, int); static int validate_patterns(struct validator *, asdl_pattern_seq *, int); +static int validate_typeparams(struct validator *, asdl_typeparam_seq *); static int _validate_nonempty_seq(asdl_seq *, const char *, const char *); static int validate_stmt(struct validator *, stmt_ty); static int validate_expr(struct validator *, expr_ty, expr_context_ty); static int validate_pattern(struct validator *, pattern_ty, int); +static int validate_typeparam(struct validator *, typeparam_ty); #define VALIDATE_POSITIONS(node) \ if (node->lineno > node->end_lineno) { \ @@ -672,6 +674,27 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok) return ret; } +static int +validate_typeparam(struct validator *state, typeparam_ty tp) +{ + VALIDATE_POSITIONS(tp); + int ret = -1; + switch (tp->kind) { + case TypeVar_kind: + ret = validate_expr(state, tp->v.TypeVar.name, Store) && + (!tp->v.TypeVar.bound || + validate_expr(state, tp->v.TypeVar.bound, Load)); + break; + case ParamSpec_kind: + ret = validate_expr(state, tp->v.ParamSpec.name, Store); + break; + case TypeVarTuple_kind: + ret = validate_expr(state, tp->v.TypeVarTuple.name, Store); + break; + } + return ret; +} + static int _validate_nonempty_seq(asdl_seq *seq, const char *what, const char *owner) { @@ -709,6 +732,7 @@ validate_stmt(struct validator *state, stmt_ty stmt) switch (stmt->kind) { case FunctionDef_kind: ret = validate_body(state, stmt->v.FunctionDef.body, "FunctionDef") && + validate_typeparams(state, stmt->v.FunctionDef.typeparams) && validate_arguments(state, stmt->v.FunctionDef.args) && validate_exprs(state, stmt->v.FunctionDef.decorator_list, Load, 0) && (!stmt->v.FunctionDef.returns || @@ -716,6 +740,7 @@ validate_stmt(struct validator *state, stmt_ty stmt) break; case ClassDef_kind: ret = validate_body(state, stmt->v.ClassDef.body, "ClassDef") && + validate_typeparams(state, stmt->v.ClassDef.typeparams) && validate_exprs(state, stmt->v.ClassDef.bases, Load, 0) && validate_keywords(state, stmt->v.ClassDef.keywords) && validate_exprs(state, stmt->v.ClassDef.decorator_list, Load, 0); @@ -748,6 +773,7 @@ validate_stmt(struct validator *state, stmt_ty stmt) break; case TypeAlias_kind: ret = validate_name(stmt->v.TypeAlias.name->v.Name.id) && + validate_typeparams(state, stmt->v.TypeAlias.typeparams) && validate_expr(state, stmt->v.TypeAlias.value, Load); break; case For_kind: @@ -897,6 +923,7 @@ validate_stmt(struct validator *state, stmt_ty stmt) break; case AsyncFunctionDef_kind: ret = validate_body(state, stmt->v.AsyncFunctionDef.body, "AsyncFunctionDef") && + validate_typeparams(state, stmt->v.AsyncFunctionDef.typeparams) && validate_arguments(state, stmt->v.AsyncFunctionDef.args) && validate_exprs(state, stmt->v.AsyncFunctionDef.decorator_list, Load, 0) && (!stmt->v.AsyncFunctionDef.returns || @@ -969,6 +996,20 @@ validate_patterns(struct validator *state, asdl_pattern_seq *patterns, int star_ return 1; } +static int +validate_typeparams(struct validator *state, asdl_typeparam_seq *tps) +{ + Py_ssize_t i; + for (i = 0; i < asdl_seq_LEN(tps); i++) { + typeparam_ty tp = asdl_seq_GET(tps, i); + if (tp) { + if (!validate_typeparam(state, tp)) + return 0; + } + } + return 1; +} + /* See comments in symtable.c. */ #define COMPILER_STACK_FRAME_SCALE 3 diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 3b27794e67239b..62aee085c5e0e5 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -882,6 +882,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) } switch (node_->kind) { case FunctionDef_kind: + CALL_SEQ(astfold_typeparam, typeparam, node_->v.FunctionDef.typeparams); CALL(astfold_arguments, arguments_ty, node_->v.FunctionDef.args); CALL(astfold_body, asdl_seq, node_->v.FunctionDef.body); CALL_SEQ(astfold_expr, expr, node_->v.FunctionDef.decorator_list); @@ -890,6 +891,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) } break; case AsyncFunctionDef_kind: + CALL_SEQ(astfold_typeparam, typeparam, node_->v.AsyncFunctionDef.typeparams); CALL(astfold_arguments, arguments_ty, node_->v.AsyncFunctionDef.args); CALL(astfold_body, asdl_seq, node_->v.AsyncFunctionDef.body); CALL_SEQ(astfold_expr, expr, node_->v.AsyncFunctionDef.decorator_list); @@ -898,6 +900,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) } break; case ClassDef_kind: + CALL_SEQ(astfold_typeparam, typeparam, node_->v.ClassDef.typeparams); CALL_SEQ(astfold_expr, expr, node_->v.ClassDef.bases); CALL_SEQ(astfold_keyword, keyword, node_->v.ClassDef.keywords); CALL(astfold_body, asdl_seq, node_->v.ClassDef.body); @@ -1086,11 +1089,14 @@ astfold_typeparam(typeparam_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { switch (node_->kind) { case TypeVar_kind: + CALL(astfold_expr, expr_ty, node_->v.TypeVar.name); CALL_OPT(astfold_expr, expr_ty, node_->v.TypeVar.bound); break; case ParamSpec_kind: + CALL(astfold_expr, expr_ty, node_->v.ParamSpec.name); break; case TypeVarTuple_kind: + CALL(astfold_expr, expr_ty, node_->v.TypeVarTuple.name); break; } return 1; From 55d0fd9b5cf22d8ec8ea3ccf5fbda79e70fd95d5 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:01:42 +0200 Subject: [PATCH 018/200] Revert AST changes for TypeParams --- Grammar/python.gram | 7 +++--- Include/internal/pycore_ast.h | 14 ++++++------ Lib/ast.py | 8 +++---- Parser/Python.asdl | 6 +++--- Parser/parser.c | 6 +++--- Python/Python-ast.c | 40 +++++++++++++++++------------------ Python/ast.c | 8 +++---- Python/ast_opt.c | 3 --- 8 files changed, 43 insertions(+), 49 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 20ef9c1a3dafe5..6ab09de4fc149a 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -645,10 +645,9 @@ type_params[asdl_typeparam_seq*]: '[' t=type_param_seq ']' { t } type_param_seq[asdl_typeparam_seq*]: a[asdl_typeparam_seq*]=','.type_param+ [','] { a } type_param[typeparam_ty] (memo): - | a=NAME b=[type_param_bound] { _PyAST_TypeVar( - CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, EXTRA) } - | '*' a=NAME { _PyAST_TypeVarTuple(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), EXTRA) } - | '**' a=NAME { _PyAST_ParamSpec(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), EXTRA) } + | a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) } + | '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) } + | '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) } type_param_bound[expr_ty]: ":" e=expression { e } diff --git a/Include/internal/pycore_ast.h b/Include/internal/pycore_ast.h index 8b61830ddd1eb6..9f1cef0541508c 100644 --- a/Include/internal/pycore_ast.h +++ b/Include/internal/pycore_ast.h @@ -654,16 +654,16 @@ struct _typeparam { enum _typeparam_kind kind; union { struct { - expr_ty name; + identifier name; expr_ty bound; } TypeVar; struct { - expr_ty name; + identifier name; } ParamSpec; struct { - expr_ty name; + identifier name; } TypeVarTuple; } v; @@ -891,13 +891,13 @@ pattern_ty _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); type_ignore_ty _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena); -typeparam_ty _PyAST_TypeVar(expr_ty name, expr_ty bound, int lineno, int +typeparam_ty _PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); -typeparam_ty _PyAST_ParamSpec(expr_ty name, int lineno, int col_offset, int +typeparam_ty _PyAST_ParamSpec(identifier name, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena); -typeparam_ty _PyAST_TypeVarTuple(expr_ty name, int lineno, int col_offset, int - end_lineno, int end_col_offset, PyArena +typeparam_ty _PyAST_TypeVarTuple(identifier name, int lineno, int col_offset, + int end_lineno, int end_col_offset, PyArena *arena); diff --git a/Lib/ast.py b/Lib/ast.py index 560cf5c020bff7..93afa7d8035de8 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -1058,18 +1058,16 @@ def _typeparams_helper(self, typeparams): self.interleave(lambda: self.write(", "), self.traverse, typeparams) def visit_TypeVar(self, node): - self.traverse(node.name) + self.write(node.name) if node.bound: self.write(": ") self.traverse(node.bound) def visit_TypeVarTuple(self, node): - self.write("*") - self.traverse(node.name) + self.write("*" + node.name) def visit_ParamSpec(self, node): - self.write("**") - self.traverse(node.name) + self.write("**" + node.name) def visit_TypeAlias(self, node): self.fill("type ") diff --git a/Parser/Python.asdl b/Parser/Python.asdl index 6b34b584568f7b..cfc41ef45b568b 100644 --- a/Parser/Python.asdl +++ b/Parser/Python.asdl @@ -145,8 +145,8 @@ module Python type_ignore = TypeIgnore(int lineno, string tag) - typeparam = TypeVar(expr name, expr? bound) - | ParamSpec(expr name) - | TypeVarTuple(expr name) + typeparam = TypeVar(identifier name, expr? bound) + | ParamSpec(identifier name) + | TypeVarTuple(identifier name) attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) } diff --git a/Parser/parser.c b/Parser/parser.c index 955da6b481cf39..cf0a12f3eb6fb0 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -10730,7 +10730,7 @@ type_param_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 = _PyAST_TypeVar ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); + _res = _PyAST_TypeVar ( a -> v . Name . id , b , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -10766,7 +10766,7 @@ type_param_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 = _PyAST_TypeVarTuple ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , EXTRA ); + _res = _PyAST_TypeVarTuple ( a -> v . Name . id , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; @@ -10802,7 +10802,7 @@ type_param_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 = _PyAST_ParamSpec ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , EXTRA ); + _res = _PyAST_ParamSpec ( a -> v . Name . id , EXTRA ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index f00b710cb323b8..7124d6c0c25eb8 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -1896,9 +1896,9 @@ init_types(struct ast_state *state) if (!state->TypeIgnore_type) return 0; state->typeparam_type = make_type(state, "typeparam", state->AST_type, NULL, 0, - "typeparam = TypeVar(expr name, expr? bound)\n" - " | ParamSpec(expr name)\n" - " | TypeVarTuple(expr name)"); + "typeparam = TypeVar(identifier name, expr? bound)\n" + " | ParamSpec(identifier name)\n" + " | TypeVarTuple(identifier name)"); if (!state->typeparam_type) return 0; if (!add_attributes(state, state->typeparam_type, typeparam_attributes, 4)) return 0; @@ -1910,19 +1910,19 @@ init_types(struct ast_state *state) return 0; state->TypeVar_type = make_type(state, "TypeVar", state->typeparam_type, TypeVar_fields, 2, - "TypeVar(expr name, expr? bound)"); + "TypeVar(identifier name, expr? bound)"); if (!state->TypeVar_type) return 0; if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1) return 0; state->ParamSpec_type = make_type(state, "ParamSpec", state->typeparam_type, ParamSpec_fields, 1, - "ParamSpec(expr name)"); + "ParamSpec(identifier name)"); if (!state->ParamSpec_type) return 0; state->TypeVarTuple_type = make_type(state, "TypeVarTuple", state->typeparam_type, TypeVarTuple_fields, 1, - "TypeVarTuple(expr name)"); + "TypeVarTuple(identifier name)"); if (!state->TypeVarTuple_type) return 0; state->recursion_depth = 0; @@ -3714,7 +3714,7 @@ _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena) } typeparam_ty -_PyAST_TypeVar(expr_ty name, expr_ty bound, int lineno, int col_offset, int +_PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int col_offset, int end_lineno, int end_col_offset, PyArena *arena) { typeparam_ty p; @@ -3737,8 +3737,8 @@ _PyAST_TypeVar(expr_ty name, expr_ty bound, int lineno, int col_offset, int } typeparam_ty -_PyAST_ParamSpec(expr_ty name, int lineno, int col_offset, int end_lineno, int - end_col_offset, PyArena *arena) +_PyAST_ParamSpec(identifier name, int lineno, int col_offset, int end_lineno, + int end_col_offset, PyArena *arena) { typeparam_ty p; if (!name) { @@ -3759,8 +3759,8 @@ _PyAST_ParamSpec(expr_ty name, int lineno, int col_offset, int end_lineno, int } typeparam_ty -_PyAST_TypeVarTuple(expr_ty name, int lineno, int col_offset, int end_lineno, - int end_col_offset, PyArena *arena) +_PyAST_TypeVarTuple(identifier name, int lineno, int col_offset, int + end_lineno, int end_col_offset, PyArena *arena) { typeparam_ty p; if (!name) { @@ -5674,7 +5674,7 @@ ast2obj_typeparam(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->TypeVar_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_expr(state, o->v.TypeVar.name); + value = ast2obj_identifier(state, o->v.TypeVar.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -5689,7 +5689,7 @@ ast2obj_typeparam(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->ParamSpec_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_expr(state, o->v.ParamSpec.name); + value = ast2obj_identifier(state, o->v.ParamSpec.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -5699,7 +5699,7 @@ ast2obj_typeparam(struct ast_state *state, void* _o) tp = (PyTypeObject *)state->TypeVarTuple_type; result = PyType_GenericNew(tp, NULL, NULL); if (!result) goto failed; - value = ast2obj_expr(state, o->v.TypeVarTuple.name); + value = ast2obj_identifier(state, o->v.TypeVarTuple.name); if (!value) goto failed; if (PyObject_SetAttr(result, state->name, value) == -1) goto failed; @@ -12383,7 +12383,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, return 1; } if (isinstance) { - expr_ty name; + identifier name; expr_ty bound; if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { @@ -12398,7 +12398,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) { goto failed; } - res = obj2ast_expr(state, tmp, &name, arena); + res = obj2ast_identifier(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); @@ -12431,7 +12431,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, return 1; } if (isinstance) { - expr_ty name; + identifier name; if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { return 1; @@ -12445,7 +12445,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) { goto failed; } - res = obj2ast_expr(state, tmp, &name, arena); + res = obj2ast_identifier(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); @@ -12461,7 +12461,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, return 1; } if (isinstance) { - expr_ty name; + identifier name; if (_PyObject_LookupAttr(obj, state->name, &tmp) < 0) { return 1; @@ -12475,7 +12475,7 @@ obj2ast_typeparam(struct ast_state *state, PyObject* obj, typeparam_ty* out, if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) { goto failed; } - res = obj2ast_expr(state, tmp, &name, arena); + res = obj2ast_identifier(state, tmp, &name, arena); _Py_LeaveRecursiveCall(); if (res != 0) goto failed; Py_CLEAR(tmp); diff --git a/Python/ast.c b/Python/ast.c index 66b03d1c7f0309..cb694ab2e77d76 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -681,15 +681,15 @@ validate_typeparam(struct validator *state, typeparam_ty tp) int ret = -1; switch (tp->kind) { case TypeVar_kind: - ret = validate_expr(state, tp->v.TypeVar.name, Store) && + ret = validate_name(tp->v.TypeVar.name) && (!tp->v.TypeVar.bound || validate_expr(state, tp->v.TypeVar.bound, Load)); break; case ParamSpec_kind: - ret = validate_expr(state, tp->v.ParamSpec.name, Store); + ret = validate_name(tp->v.ParamSpec.name); break; case TypeVarTuple_kind: - ret = validate_expr(state, tp->v.TypeVarTuple.name, Store); + ret = validate_name(tp->v.TypeVarTuple.name); break; } return ret; @@ -772,7 +772,7 @@ validate_stmt(struct validator *state, stmt_ty stmt) validate_expr(state, stmt->v.AnnAssign.annotation, Load); break; case TypeAlias_kind: - ret = validate_name(stmt->v.TypeAlias.name->v.Name.id) && + ret = validate_expr(state, stmt->v.TypeAlias.name, Store) && validate_typeparams(state, stmt->v.TypeAlias.typeparams) && validate_expr(state, stmt->v.TypeAlias.value, Load); break; diff --git a/Python/ast_opt.c b/Python/ast_opt.c index 62aee085c5e0e5..a296f86cf867fe 100644 --- a/Python/ast_opt.c +++ b/Python/ast_opt.c @@ -1089,14 +1089,11 @@ astfold_typeparam(typeparam_ty node_, PyArena *ctx_, _PyASTOptimizeState *state) { switch (node_->kind) { case TypeVar_kind: - CALL(astfold_expr, expr_ty, node_->v.TypeVar.name); CALL_OPT(astfold_expr, expr_ty, node_->v.TypeVar.bound); break; case ParamSpec_kind: - CALL(astfold_expr, expr_ty, node_->v.ParamSpec.name); break; case TypeVarTuple_kind: - CALL(astfold_expr, expr_ty, node_->v.TypeVarTuple.name); break; } return 1; From bef978f0dda295efce60762bade6bc0094fe7202 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 18 Apr 2023 11:14:09 -0700 Subject: [PATCH 019/200] broken compiler before merge --- Include/internal/pycore_symtable.h | 2 +- Python/compile.c | 32 +++++++++++++++++++++- Python/symtable.c | 44 ++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 512c4c931f73e4..248d80b3d25329 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -10,7 +10,7 @@ extern "C" { struct _mod; // Type defined in pycore_ast.h -typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, AnnotationBlock } +typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, AnnotationBlock, TypeParamBlock } _Py_block_ty; typedef enum _comprehension_type { diff --git a/Python/compile.c b/Python/compile.c index fed9ae7066e4f0..5d2fe82dcb5ab1 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -196,6 +196,7 @@ enum { COMPILER_SCOPE_ASYNC_FUNCTION, COMPILER_SCOPE_LAMBDA, COMPILER_SCOPE_COMPREHENSION, + COMPILER_SCOPE_TYPE_PARAMS, }; typedef struct { @@ -2119,6 +2120,21 @@ wrap_in_stopiteration_handler(struct compiler *c) return SUCCESS; } +static int +compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) +{ + if (!typeparams) { + return SUCCESS; + } + + for (Py_ssize_t i = 0; i < asdl_seq_LEN(typeparams); i++) { + typeparam_ty typeparam = asdl_seq_GET(typeparams, i); + RETURN_IF_ERROR(compiler_visit_expr(c, typeparam->constraint)); + RETURN_IF_ERROR(compiler_visit_expr(c, typeparam->bound)); + } + return SUCCESS; +} + static int compiler_function(struct compiler *c, stmt_ty s, int is_async) { @@ -2127,8 +2143,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) arguments_ty args; expr_ty returns; identifier name; - asdl_expr_seq* decos; + asdl_expr_seq *decos; asdl_stmt_seq *body; + asdl_typeparam_seq *typeparams; Py_ssize_t i, funcflags; int annotations; int scope_type; @@ -2142,6 +2159,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) decos = s->v.AsyncFunctionDef.decorator_list; name = s->v.AsyncFunctionDef.name; body = s->v.AsyncFunctionDef.body; + typeparams = s->v.AsyncFunctionDef.typeparams; scope_type = COMPILER_SCOPE_ASYNC_FUNCTION; } else { @@ -2152,6 +2170,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) decos = s->v.FunctionDef.decorator_list; name = s->v.FunctionDef.name; body = s->v.FunctionDef.body; + typeparams = s->v.FunctionDef.typeparams; scope_type = COMPILER_SCOPE_FUNCTION; } @@ -2169,6 +2188,14 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) if (funcflags == -1) { return ERROR; } + + if (typeparams) { + RETURN_IF_ERROR( + compiler_enter_scope(c, name, COMPILER_SCOPE_TYPE_PARAMS, (void *)typeparams, firstlineno) + ); + RETURN_IF_ERROR(compiler_type_params(c, typeparams)); + } + annotations = compiler_visit_annotations(c, loc, args, returns); RETURN_IF_ERROR(annotations); if (annotations > 0) { @@ -2200,6 +2227,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } } co = assemble(c, 1); + if (typeparams) { + compiler_exit_scope(c); + } compiler_exit_scope(c); if (co == NULL) { Py_XDECREF(co); diff --git a/Python/symtable.c b/Python/symtable.c index df7473943f3fc1..41591c4d130ad8 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -207,6 +207,7 @@ static int symtable_enter_block(struct symtable *st, identifier name, static int symtable_exit_block(struct symtable *st); static int symtable_visit_stmt(struct symtable *st, stmt_ty s); static int symtable_visit_expr(struct symtable *st, expr_ty s); +static int symtable_visit_typeparam(struct symtable *st, typeparam_ty s); static int symtable_visit_genexp(struct symtable *st, expr_ty s); static int symtable_visit_listcomp(struct symtable *st, expr_ty s); static int symtable_visit_setcomp(struct symtable *st, expr_ty s); @@ -1195,11 +1196,19 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ(st, expr, s->v.FunctionDef.args->defaults); if (s->v.FunctionDef.args->kw_defaults) VISIT_SEQ_WITH_NULL(st, expr, s->v.FunctionDef.args->kw_defaults); + if (s->v.FunctionDef.decorator_list) + VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); + if (s->v.FunctionDef.typeparams) { + if (!symtable_enter_block(st, s->v.FunctionDef.name, + TypeParamBlock, (void *)s, + LOCATION(s))) { + VISIT_QUIT(st, 0); + } + VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); + } if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args, s->v.FunctionDef.returns)) VISIT_QUIT(st, 0); - if (s->v.FunctionDef.decorator_list) - VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); if (!symtable_enter_block(st, s->v.FunctionDef.name, FunctionBlock, (void *)s, LOCATION(s))) @@ -1208,6 +1217,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ(st, stmt, s->v.FunctionDef.body); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); + if (s->v.FunctionDef.typeparams && + !symtable_exit_block(st)) { + VISIT_QUIT(st, 0); + } break; case ClassDef_kind: { PyObject *tmp; @@ -1726,6 +1739,33 @@ symtable_visit_expr(struct symtable *st, expr_ty e) VISIT_QUIT(st, 1); } +static int +symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) +{ + if (++st->recursion_depth > st->recursion_limit) { + PyErr_SetString(PyExc_RecursionError, + "maximum recursion depth exceeded during compilation"); + VISIT_QUIT(st, 0); + } + switch(tp->kind) { + case TypeVar_kind: + if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_PARAM, LOCATION(tp))) + VISIT_QUIT(st, 0); + if (tp->v.TypeVar.bound) + VISIT(st, expr, tp->v.TypeVar.bound); + break; + case TypeVarTuple_kind: + if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_PARAM, LOCATION(tp))) + VISIT_QUIT(st, 0); + break; + case ParamSpec_kind: + if (!symtable_add_def(st, tp->v.ParamSpec.name, DEF_PARAM, LOCATION(tp))) + VISIT_QUIT(st, 0); + break; + } + VISIT_QUIT(st, 1); +} + static int symtable_visit_pattern(struct symtable *st, pattern_ty p) { From b12663dc7a7262f017132bda3effd8b93e916f99 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 18 Apr 2023 14:39:27 -0700 Subject: [PATCH 020/200] Works for functions --- Include/internal/pycore_symtable.h | 4 + Python/compile.c | 29 ++++++-- Python/symtable.c | 116 +++++++++++++++++++++++++++-- 3 files changed, 134 insertions(+), 15 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 248d80b3d25329..428c44660fc0c4 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -49,6 +49,10 @@ typedef struct _symtable_entry { PyObject *ste_varnames; /* list of function parameters */ PyObject *ste_children; /* list of child blocks */ PyObject *ste_directives;/* locations of global and nonlocal statements */ + PyObject *ste_typeparam_overlays; /* dict: map AST node addresses to symtable entries + that represent typeparam overlays */ + PyObject *ste_current_typeparam_overlay; /* active typeparam overlay + (key in ste_typeparam_overlays) */ _Py_block_ty ste_type; /* module, class, function or annotation */ int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ diff --git a/Python/compile.c b/Python/compile.c index 5d2fe82dcb5ab1..c7d52fe6159500 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2129,8 +2129,19 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) for (Py_ssize_t i = 0; i < asdl_seq_LEN(typeparams); i++) { typeparam_ty typeparam = asdl_seq_GET(typeparams, i); - RETURN_IF_ERROR(compiler_visit_expr(c, typeparam->constraint)); - RETURN_IF_ERROR(compiler_visit_expr(c, typeparam->bound)); + // TODO(PEP 695): Actually emit a TypeVar + ADDOP_LOAD_CONST(c, LOC(typeparam), Py_None); + switch(typeparam->kind) { + case TypeVar_kind: + compiler_nameop(c, LOC(typeparam), typeparam->v.TypeVar.name, Store); + break; + case TypeVarTuple_kind: + compiler_nameop(c, LOC(typeparam), typeparam->v.TypeVarTuple.name, Store); + break; + case ParamSpec_kind: + compiler_nameop(c, LOC(typeparam), typeparam->v.ParamSpec.name, Store); + break; + } } return SUCCESS; } @@ -2190,9 +2201,12 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } if (typeparams) { - RETURN_IF_ERROR( - compiler_enter_scope(c, name, COMPILER_SCOPE_TYPE_PARAMS, (void *)typeparams, firstlineno) - ); + assert(c->u->u_ste->ste_current_typeparam_overlay == NULL); + PyObject *ptr = PyLong_FromVoidPtr((void *)typeparams); + if (ptr == NULL) { + return ERROR; + } + c->u->u_ste->ste_current_typeparam_overlay = ptr; RETURN_IF_ERROR(compiler_type_params(c, typeparams)); } @@ -2227,10 +2241,10 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } } co = assemble(c, 1); + compiler_exit_scope(c); if (typeparams) { - compiler_exit_scope(c); + Py_CLEAR(c->u->u_ste->ste_current_typeparam_overlay); } - compiler_exit_scope(c); if (co == NULL) { Py_XDECREF(co); return ERROR; @@ -2242,6 +2256,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) Py_DECREF(co); RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); + assert(c->u->u_ste->ste_current_typeparam_overlay == NULL); return compiler_nameop(c, loc, name, Store); } diff --git a/Python/symtable.c b/Python/symtable.c index 41591c4d130ad8..d5221a1a4b2093 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -78,6 +78,8 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_symbols = NULL; ste->ste_varnames = NULL; ste->ste_children = NULL; + ste->ste_current_typeparam_overlay = NULL; + ste->ste_typeparam_overlays = NULL; ste->ste_directives = NULL; @@ -141,6 +143,8 @@ ste_dealloc(PySTEntryObject *ste) Py_XDECREF(ste->ste_varnames); Py_XDECREF(ste->ste_children); Py_XDECREF(ste->ste_directives); + Py_XDECREF(ste->ste_typeparam_overlays); + Py_XDECREF(ste->ste_current_typeparam_overlay); PyObject_Free(ste); } @@ -389,7 +393,21 @@ PySymtable_Lookup(struct symtable *st, void *key) long _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) { - PyObject *v = PyDict_GetItemWithError(ste->ste_symbols, name); + PyObject *v; + if (ste->ste_current_typeparam_overlay) { + assert(ste->ste_typeparam_overlays != NULL); + PyObject *inner_ste = PyDict_GetItemWithError(ste->ste_typeparam_overlays, + ste->ste_current_typeparam_overlay); + if (inner_ste == NULL) { + assert(PyErr_Occurred()); + return 0; + } + v = PyDict_GetItemWithError(((PySTEntryObject *)inner_ste)->ste_symbols, name); + assert(v != NULL); + } + else { + v = PyDict_GetItemWithError(ste->ste_symbols, name); + } if (!v) return 0; assert(PyLong_Check(v)); @@ -400,6 +418,7 @@ int _PyST_GetScope(PySTEntryObject *ste, PyObject *name) { long symbol = _PyST_GetSymbol(ste, name); + assert(!PyErr_Occurred()); return (symbol >> SCOPE_OFFSET) & SCOPE_MASK; } @@ -959,6 +978,46 @@ symtable_exit_block(struct symtable *st) return 1; } +static int +symtable_enter_typeparam_overlay(struct symtable *st, identifier name, + void *ast, int lineno, int col_offset, + int end_lineno, int end_col_offset) +{ + PySTEntryObject *ste = ste_new(st, name, TypeParamBlock, ast, lineno, col_offset, + end_lineno, end_col_offset); + if (ste == NULL) { + return 0; + } + PyObject *key = PyLong_FromVoidPtr(ast); + if (key == NULL) { + Py_DECREF(ste); + return 0; + } + struct _symtable_entry *cur = st->st_cur; + cur->ste_current_typeparam_overlay = Py_NewRef(key); + if (cur->ste_typeparam_overlays == NULL) { + cur->ste_typeparam_overlays = PyDict_New(); + if (cur->ste_typeparam_overlays == NULL) { + Py_DECREF(key); + Py_DECREF(ste); + return 0; + } + } + if (PyDict_SetItem(cur->ste_typeparam_overlays, key, (PyObject *)ste) < 0) { + Py_DECREF(key); + Py_DECREF(ste); + return 0; + } + Py_DECREF(key); + Py_DECREF(ste); + return 1; +} + +static int symtable_leave_typeparam_overlay(struct symtable *st) { + Py_CLEAR(st->st_cur->ste_current_typeparam_overlay); + return 1; +} + static int symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block, void *ast, int lineno, int col_offset, @@ -1014,6 +1073,47 @@ symtable_lookup(struct symtable *st, PyObject *name) return ret; } +static int +symtable_add_typeparam(struct symtable *st, PyObject *name, + int lineno, int col_offset, int end_lineno, int end_col_offset) +{ + PyObject *typeparams; + PyObject *current; + if (!(typeparams = PyDict_GetItemWithError(st->st_cur->ste_typeparam_overlays, + st->st_cur->ste_current_typeparam_overlay))) { + if (PyErr_Occurred()) { + return 0; + } + else { + PyErr_SetString(PyExc_SystemError, "Invalid typeparam overlay"); + return 0; + } + } + assert(Py_IS_TYPE(typeparams, &PySTEntry_Type)); + struct _symtable_entry *ste = (struct _symtable_entry *)typeparams; + PyObject *dict = ste->ste_symbols; + if ((current = PyDict_GetItemWithError(dict, name))) { + PyErr_Format(PyExc_SyntaxError, "duplicate type parameter '%U'", name); + PyErr_RangedSyntaxLocationObject(st->st_filename, + lineno, col_offset + 1, + end_lineno, end_col_offset + 1); + return 0; + } + else if (PyErr_Occurred()) { + return 0; + } + PyObject *flags = PyLong_FromLong(CELL << SCOPE_OFFSET); + if (flags == NULL) { + return 0; + } + if (PyDict_SetItem(dict, name, flags) < 0) { + Py_DECREF(flags); + return 0; + } + Py_DECREF(flags); + return 1; +} + static int symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _symtable_entry *ste, int lineno, int col_offset, int end_lineno, int end_col_offset) @@ -1199,9 +1299,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); if (s->v.FunctionDef.typeparams) { - if (!symtable_enter_block(st, s->v.FunctionDef.name, - TypeParamBlock, (void *)s, - LOCATION(s))) { + if (!symtable_enter_typeparam_overlay(st, s->v.FunctionDef.name, + (void *)s->v.FunctionDef.typeparams, + LOCATION(s))) { VISIT_QUIT(st, 0); } VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); @@ -1218,7 +1318,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); if (s->v.FunctionDef.typeparams && - !symtable_exit_block(st)) { + !symtable_leave_typeparam_overlay(st)) { VISIT_QUIT(st, 0); } break; @@ -1749,17 +1849,17 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) } switch(tp->kind) { case TypeVar_kind: - if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_PARAM, LOCATION(tp))) + if (!symtable_add_typeparam(st, tp->v.TypeVar.name, LOCATION(tp))) VISIT_QUIT(st, 0); if (tp->v.TypeVar.bound) VISIT(st, expr, tp->v.TypeVar.bound); break; case TypeVarTuple_kind: - if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_PARAM, LOCATION(tp))) + if (!symtable_add_typeparam(st, tp->v.TypeVarTuple.name, LOCATION(tp))) VISIT_QUIT(st, 0); break; case ParamSpec_kind: - if (!symtable_add_def(st, tp->v.ParamSpec.name, DEF_PARAM, LOCATION(tp))) + if (!symtable_add_typeparam(st, tp->v.ParamSpec.name, LOCATION(tp))) VISIT_QUIT(st, 0); break; } From bb9c43c6992a80b0e81b5163471aac3097835898 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 18 Apr 2023 14:46:20 -0700 Subject: [PATCH 021/200] fall back to normal scope --- Python/symtable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/symtable.c b/Python/symtable.c index d5221a1a4b2093..9c96d32f1f971a 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -393,7 +393,7 @@ PySymtable_Lookup(struct symtable *st, void *key) long _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) { - PyObject *v; + PyObject *v = NULL; if (ste->ste_current_typeparam_overlay) { assert(ste->ste_typeparam_overlays != NULL); PyObject *inner_ste = PyDict_GetItemWithError(ste->ste_typeparam_overlays, @@ -403,9 +403,9 @@ _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) return 0; } v = PyDict_GetItemWithError(((PySTEntryObject *)inner_ste)->ste_symbols, name); - assert(v != NULL); + assert(!PyErr_Occurred()); } - else { + if (v == NULL) { v = PyDict_GetItemWithError(ste->ste_symbols, name); } if (!v) From 037ddfa1df24daf657702fa6fc00841e886947a7 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 19 Apr 2023 09:10:44 -0600 Subject: [PATCH 022/200] does not exactly work --- Include/internal/pycore_symtable.h | 1 + Python/compile.c | 6 +++-- Python/symtable.c | 39 ++++++++++++++++++++++-------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 428c44660fc0c4..8d302e6a8994d2 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -53,6 +53,7 @@ typedef struct _symtable_entry { that represent typeparam overlays */ PyObject *ste_current_typeparam_overlay; /* active typeparam overlay (key in ste_typeparam_overlays) */ + struct _symtable_entry *ste_parent_typeparam_overlay; _Py_block_ty ste_type; /* module, class, function or annotation */ int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ diff --git a/Python/compile.c b/Python/compile.c index c7d52fe6159500..7cdd6905fcdcf6 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2129,16 +2129,18 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) for (Py_ssize_t i = 0; i < asdl_seq_LEN(typeparams); i++) { typeparam_ty typeparam = asdl_seq_GET(typeparams, i); - // TODO(PEP 695): Actually emit a TypeVar - ADDOP_LOAD_CONST(c, LOC(typeparam), Py_None); switch(typeparam->kind) { case TypeVar_kind: + // TODO(PEP 695): Actually emit a TypeVar + ADDOP_LOAD_CONST(c, LOC(typeparam), typeparam->v.TypeVar.name); compiler_nameop(c, LOC(typeparam), typeparam->v.TypeVar.name, Store); break; case TypeVarTuple_kind: + ADDOP_LOAD_CONST(c, LOC(typeparam), typeparam->v.TypeVarTuple.name); compiler_nameop(c, LOC(typeparam), typeparam->v.TypeVarTuple.name, Store); break; case ParamSpec_kind: + ADDOP_LOAD_CONST(c, LOC(typeparam), typeparam->v.ParamSpec.name); compiler_nameop(c, LOC(typeparam), typeparam->v.ParamSpec.name, Store); break; } diff --git a/Python/symtable.c b/Python/symtable.c index 9c96d32f1f971a..2467ae58fddb3e 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -80,6 +80,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_children = NULL; ste->ste_current_typeparam_overlay = NULL; ste->ste_typeparam_overlays = NULL; + ste->ste_parent_typeparam_overlay = NULL; ste->ste_directives = NULL; @@ -145,6 +146,7 @@ ste_dealloc(PySTEntryObject *ste) Py_XDECREF(ste->ste_directives); Py_XDECREF(ste->ste_typeparam_overlays); Py_XDECREF(ste->ste_current_typeparam_overlay); + Py_XDECREF(ste->ste_parent_typeparam_overlay); PyObject_Free(ste); } @@ -913,6 +915,16 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, temp_bound = PySet_New(bound); if (!temp_bound) goto error; + if (entry->ste_parent_typeparam_overlay) { + PySTEntryObject *inner_ste = entry->ste_parent_typeparam_overlay; + PyObject *name; + Py_ssize_t pos = 0; + while (PyDict_Next(inner_ste->ste_symbols, &pos, &name, NULL)) { + if (PySet_Add(temp_bound, name) < 0) { + goto error; + } + } + } temp_free = PySet_New(free); if (!temp_free) goto error; @@ -978,7 +990,7 @@ symtable_exit_block(struct symtable *st) return 1; } -static int +static PySTEntryObject * symtable_enter_typeparam_overlay(struct symtable *st, identifier name, void *ast, int lineno, int col_offset, int end_lineno, int end_col_offset) @@ -986,12 +998,12 @@ symtable_enter_typeparam_overlay(struct symtable *st, identifier name, PySTEntryObject *ste = ste_new(st, name, TypeParamBlock, ast, lineno, col_offset, end_lineno, end_col_offset); if (ste == NULL) { - return 0; + return NULL; } PyObject *key = PyLong_FromVoidPtr(ast); if (key == NULL) { Py_DECREF(ste); - return 0; + return NULL; } struct _symtable_entry *cur = st->st_cur; cur->ste_current_typeparam_overlay = Py_NewRef(key); @@ -1000,17 +1012,17 @@ symtable_enter_typeparam_overlay(struct symtable *st, identifier name, if (cur->ste_typeparam_overlays == NULL) { Py_DECREF(key); Py_DECREF(ste); - return 0; + return NULL; } } if (PyDict_SetItem(cur->ste_typeparam_overlays, key, (PyObject *)ste) < 0) { Py_DECREF(key); Py_DECREF(ste); - return 0; + return NULL; } Py_DECREF(key); Py_DECREF(ste); - return 1; + return ste; } static int symtable_leave_typeparam_overlay(struct symtable *st) { @@ -1289,7 +1301,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); } switch (s->kind) { - case FunctionDef_kind: + case FunctionDef_kind: { if (!symtable_add_def(st, s->v.FunctionDef.name, DEF_LOCAL, LOCATION(s))) VISIT_QUIT(st, 0); if (s->v.FunctionDef.args->defaults) @@ -1298,10 +1310,12 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ_WITH_NULL(st, expr, s->v.FunctionDef.args->kw_defaults); if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); + PySTEntryObject *ste = NULL; if (s->v.FunctionDef.typeparams) { - if (!symtable_enter_typeparam_overlay(st, s->v.FunctionDef.name, - (void *)s->v.FunctionDef.typeparams, - LOCATION(s))) { + ste = symtable_enter_typeparam_overlay(st, s->v.FunctionDef.name, + (void *)s->v.FunctionDef.typeparams, + LOCATION(s)); + if (ste == NULL) { VISIT_QUIT(st, 0); } VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); @@ -1313,6 +1327,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) FunctionBlock, (void *)s, LOCATION(s))) VISIT_QUIT(st, 0); + if (ste != NULL) { + Py_INCREF(ste); + st->st_cur->ste_parent_typeparam_overlay = ste; + } VISIT(st, arguments, s->v.FunctionDef.args); VISIT_SEQ(st, stmt, s->v.FunctionDef.body); if (!symtable_exit_block(st)) @@ -1322,6 +1340,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); } break; + } case ClassDef_kind: { PyObject *tmp; if (!symtable_add_def(st, s->v.ClassDef.name, DEF_LOCAL, LOCATION(s))) From a62f0c26218ef0c9b7b70aba76b548da6da6ec2d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 04:30:15 -0600 Subject: [PATCH 023/200] commit before new approach --- Python/compile.c | 17 +++++++++++++ Python/symtable.c | 63 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 7cdd6905fcdcf6..925e095149d2e5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1281,6 +1281,19 @@ compiler_enter_scope(struct compiler *c, identifier name, compiler_unit_free(u); return ERROR; } + // if (u->u_ste->ste_parent_typeparam_overlay) { + // PySTEntryObject *ste = u->u_ste->ste_parent_typeparam_overlay; + // Py_ssize_t size = PyDict_Size(u->u_cellvars); + // Py_ssize_t pos = 0; + // while (PyDict_Next(ste->ste_symbols, &pos, &name, NULL)) { + // PyObject *val = PyLong_FromLong(size); + // size++; + // if (PyDict_SetItem(u->u_cellvars, name, val) < 0) { + // compiler_unit_free(u); + // return ERROR; + // } + // } + // } if (u->u_ste->ste_needs_class_closure) { /* Cook up an implicit __class__ cell. */ int res; @@ -1803,6 +1816,10 @@ compiler_make_closure(struct compiler *c, location loc, return ERROR; } int arg; + if (c->u->u_ste->ste_current_typeparam_overlay) { + PyObject *inner_ste = PyDict_GetItem(c->u->u_ste->ste_typeparam_overlays, + c->u->u_ste->ste_current_typeparam_overlay); + } if (reftype == CELL) { arg = compiler_lookup_arg(c->u->u_cellvars, name); } diff --git a/Python/symtable.c b/Python/symtable.c index 2467ae58fddb3e..7f375d63dff29b 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -640,7 +640,8 @@ drop_class_free(PySTEntryObject *ste, PyObject *free) * All arguments are dicts. Modifies symbols, others are read-only. */ static int -update_symbols(PyObject *symbols, PyObject *scopes, +update_symbols(PyObject *symbols, PySTEntryObject *parent_typeparam_overlay, + PyObject *scopes, PyObject *bound, PyObject *free, int classflag) { PyObject *name = NULL, *itr = NULL; @@ -665,6 +666,25 @@ update_symbols(PyObject *symbols, PyObject *scopes, } Py_DECREF(v_new); } + // if (parent_typeparam_overlay) { + // while (PyDict_Next(parent_typeparam_overlay->ste_symbols, &pos, &name, &v)) { + // long scope, flags; + // assert(PyLong_Check(v)); + // flags = PyLong_AS_LONG(v); + // v_scope = PyDict_GetItemWithError(scopes, name); + // assert(v_scope && PyLong_Check(v_scope)); + // scope = PyLong_AS_LONG(v_scope); + // flags |= (scope << SCOPE_OFFSET); + // v_new = PyLong_FromLong(flags); + // if (!v_new) + // return 0; + // if (PyDict_SetItem(symbols, name, v_new) < 0) { + // Py_DECREF(v_new); + // return 0; + // } + // Py_DECREF(v_new); + // } + // } /* Record not yet resolved free variables from children (if any) */ v_free = PyLong_FromLong(FREE << SCOPE_OFFSET); @@ -757,6 +777,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, { PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL; PyObject *newglobal = NULL, *newfree = NULL, *allfree = NULL; + PyObject *newbound_with_type_params = NULL; PyObject *temp; int i, success = 0; Py_ssize_t pos = 0; @@ -858,9 +879,26 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, PySTEntryObject* entry; assert(c && PySTEntry_Check(c)); entry = (PySTEntryObject*)c; - if (!analyze_child_block(entry, newbound, newfree, newglobal, - allfree)) - goto error; + if (entry->ste_parent_typeparam_overlay) { + assert(newbound_with_type_params == NULL); + newbound_with_type_params = PySet_New(newbound); + Py_ssize_t pos = 0; + PyObject *name; + while (PyDict_Next(entry->ste_parent_typeparam_overlay->ste_symbols, &pos, &name, NULL)) { + if (PySet_Add(newbound_with_type_params, name) < 0) { + goto error; + } + } + if (!analyze_child_block(entry, newbound_with_type_params, newfree, newglobal, + allfree)) + goto error; + Py_CLEAR(newbound_with_type_params); + } + else { + if (!analyze_child_block(entry, newbound, newfree, newglobal, + allfree)) + goto error; + } /* Check if any children have free variables */ if (entry->ste_free || entry->ste_child_free) ste->ste_child_free = 1; @@ -877,7 +915,8 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, else if (ste->ste_type == ClassBlock && !drop_class_free(ste, newfree)) goto error; /* Records the results of the analysis in the symbol table entry */ - if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, + if (!update_symbols(ste->ste_symbols, ste->ste_parent_typeparam_overlay, + scopes, bound, newfree, ste->ste_type == ClassBlock)) goto error; @@ -893,6 +932,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_XDECREF(newglobal); Py_XDECREF(newfree); Py_XDECREF(allfree); + Py_XDECREF(newbound_with_type_params); if (!success) assert(PyErr_Occurred()); return success; @@ -1114,7 +1154,7 @@ symtable_add_typeparam(struct symtable *st, PyObject *name, else if (PyErr_Occurred()) { return 0; } - PyObject *flags = PyLong_FromLong(CELL << SCOPE_OFFSET); + PyObject *flags = PyLong_FromLong(LOCAL << SCOPE_OFFSET); if (flags == NULL) { return 0; } @@ -1330,6 +1370,17 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (ste != NULL) { Py_INCREF(ste); st->st_cur->ste_parent_typeparam_overlay = ste; + // Py_ssize_t pos = 0; + // PyObject *name; + // PyObject *cell_v = PyLong_FromLong(CELL << SCOPE_OFFSET); + // if (cell_v == NULL) { + // VISIT_QUIT(st, 0); + // } + // while (PyDict_Next(ste->ste_symbols, &pos, &name, NULL)) { + // if (PyDict_SetItem(st->st_cur->ste_symbols, name, cell_v) < 0) { + // VISIT_QUIT(st, 0); + // } + // } } VISIT(st, arguments, s->v.FunctionDef.args); VISIT_SEQ(st, stmt, s->v.FunctionDef.body); From 9c7a153194db904e3abe50af7c0e6552088baa42 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 04:50:49 -0600 Subject: [PATCH 024/200] New approach --- Include/internal/pycore_symtable.h | 7 +- Python/compile.c | 16 +-- Python/symtable.c | 173 ++++++----------------------- 3 files changed, 41 insertions(+), 155 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 8d302e6a8994d2..f84f06d9c227ae 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -49,11 +49,8 @@ typedef struct _symtable_entry { PyObject *ste_varnames; /* list of function parameters */ PyObject *ste_children; /* list of child blocks */ PyObject *ste_directives;/* locations of global and nonlocal statements */ - PyObject *ste_typeparam_overlays; /* dict: map AST node addresses to symtable entries - that represent typeparam overlays */ - PyObject *ste_current_typeparam_overlay; /* active typeparam overlay - (key in ste_typeparam_overlays) */ - struct _symtable_entry *ste_parent_typeparam_overlay; + int ste_active_typeparam_scope; /* 0 if no active typeparam scope */ + int ste_num_typeparam_scopes; /* number of typeparam scopes encountered */ _Py_block_ty ste_type; /* module, class, function or annotation */ int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ diff --git a/Python/compile.c b/Python/compile.c index 925e095149d2e5..ff4cd4f79facc3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1816,10 +1816,6 @@ compiler_make_closure(struct compiler *c, location loc, return ERROR; } int arg; - if (c->u->u_ste->ste_current_typeparam_overlay) { - PyObject *inner_ste = PyDict_GetItem(c->u->u_ste->ste_typeparam_overlays, - c->u->u_ste->ste_current_typeparam_overlay); - } if (reftype == CELL) { arg = compiler_lookup_arg(c->u->u_cellvars, name); } @@ -2220,12 +2216,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } if (typeparams) { - assert(c->u->u_ste->ste_current_typeparam_overlay == NULL); - PyObject *ptr = PyLong_FromVoidPtr((void *)typeparams); - if (ptr == NULL) { - return ERROR; - } - c->u->u_ste->ste_current_typeparam_overlay = ptr; + assert(c->u->u_ste->ste_active_typeparam_scope == 0); + c->u->u_ste->ste_num_typeparam_scopes += 1; + c->u->u_ste->ste_active_typeparam_scope = c->u->u_ste->ste_num_typeparam_scopes; RETURN_IF_ERROR(compiler_type_params(c, typeparams)); } @@ -2262,7 +2255,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) co = assemble(c, 1); compiler_exit_scope(c); if (typeparams) { - Py_CLEAR(c->u->u_ste->ste_current_typeparam_overlay); + c->u->u_ste->ste_active_typeparam_scope = 0; } if (co == NULL) { Py_XDECREF(co); @@ -2275,7 +2268,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) Py_DECREF(co); RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); - assert(c->u->u_ste->ste_current_typeparam_overlay == NULL); return compiler_nameop(c, loc, name, Store); } diff --git a/Python/symtable.c b/Python/symtable.c index 7f375d63dff29b..07cd59fb5e8d2e 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -78,9 +78,8 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_symbols = NULL; ste->ste_varnames = NULL; ste->ste_children = NULL; - ste->ste_current_typeparam_overlay = NULL; - ste->ste_typeparam_overlays = NULL; - ste->ste_parent_typeparam_overlay = NULL; + ste->ste_num_typeparam_scopes = 0; + ste->ste_active_typeparam_scope = 0; ste->ste_directives = NULL; @@ -144,9 +143,6 @@ ste_dealloc(PySTEntryObject *ste) Py_XDECREF(ste->ste_varnames); Py_XDECREF(ste->ste_children); Py_XDECREF(ste->ste_directives); - Py_XDECREF(ste->ste_typeparam_overlays); - Py_XDECREF(ste->ste_current_typeparam_overlay); - Py_XDECREF(ste->ste_parent_typeparam_overlay); PyObject_Free(ste); } @@ -392,19 +388,24 @@ PySymtable_Lookup(struct symtable *st, void *key) return (PySTEntryObject *)Py_XNewRef(v); } +PyObject * +_PyST_MangleTypeParam(PySTEntryObject *ste, PyObject *name) +{ + return PyUnicode_FromFormat("%d.%U", ste->ste_active_typeparam_scope, name); +} + long _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) { PyObject *v = NULL; - if (ste->ste_current_typeparam_overlay) { - assert(ste->ste_typeparam_overlays != NULL); - PyObject *inner_ste = PyDict_GetItemWithError(ste->ste_typeparam_overlays, - ste->ste_current_typeparam_overlay); - if (inner_ste == NULL) { + if (ste->ste_active_typeparam_scope) { + PyObject *mangled = _PyST_MangleTypeParam(ste, name); + if (mangled == NULL) { assert(PyErr_Occurred()); return 0; } - v = PyDict_GetItemWithError(((PySTEntryObject *)inner_ste)->ste_symbols, name); + v = PyDict_GetItemWithError(ste->ste_symbols, mangled); + Py_DECREF(mangled); assert(!PyErr_Occurred()); } if (v == NULL) { @@ -640,8 +641,7 @@ drop_class_free(PySTEntryObject *ste, PyObject *free) * All arguments are dicts. Modifies symbols, others are read-only. */ static int -update_symbols(PyObject *symbols, PySTEntryObject *parent_typeparam_overlay, - PyObject *scopes, +update_symbols(PyObject *symbols, PyObject *scopes, PyObject *bound, PyObject *free, int classflag) { PyObject *name = NULL, *itr = NULL; @@ -666,25 +666,6 @@ update_symbols(PyObject *symbols, PySTEntryObject *parent_typeparam_overlay, } Py_DECREF(v_new); } - // if (parent_typeparam_overlay) { - // while (PyDict_Next(parent_typeparam_overlay->ste_symbols, &pos, &name, &v)) { - // long scope, flags; - // assert(PyLong_Check(v)); - // flags = PyLong_AS_LONG(v); - // v_scope = PyDict_GetItemWithError(scopes, name); - // assert(v_scope && PyLong_Check(v_scope)); - // scope = PyLong_AS_LONG(v_scope); - // flags |= (scope << SCOPE_OFFSET); - // v_new = PyLong_FromLong(flags); - // if (!v_new) - // return 0; - // if (PyDict_SetItem(symbols, name, v_new) < 0) { - // Py_DECREF(v_new); - // return 0; - // } - // Py_DECREF(v_new); - // } - // } /* Record not yet resolved free variables from children (if any) */ v_free = PyLong_FromLong(FREE << SCOPE_OFFSET); @@ -879,26 +860,9 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, PySTEntryObject* entry; assert(c && PySTEntry_Check(c)); entry = (PySTEntryObject*)c; - if (entry->ste_parent_typeparam_overlay) { - assert(newbound_with_type_params == NULL); - newbound_with_type_params = PySet_New(newbound); - Py_ssize_t pos = 0; - PyObject *name; - while (PyDict_Next(entry->ste_parent_typeparam_overlay->ste_symbols, &pos, &name, NULL)) { - if (PySet_Add(newbound_with_type_params, name) < 0) { - goto error; - } - } - if (!analyze_child_block(entry, newbound_with_type_params, newfree, newglobal, - allfree)) - goto error; - Py_CLEAR(newbound_with_type_params); - } - else { - if (!analyze_child_block(entry, newbound, newfree, newglobal, - allfree)) - goto error; - } + if (!analyze_child_block(entry, newbound, newfree, newglobal, + allfree)) + goto error; /* Check if any children have free variables */ if (entry->ste_free || entry->ste_child_free) ste->ste_child_free = 1; @@ -915,8 +879,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, else if (ste->ste_type == ClassBlock && !drop_class_free(ste, newfree)) goto error; /* Records the results of the analysis in the symbol table entry */ - if (!update_symbols(ste->ste_symbols, ste->ste_parent_typeparam_overlay, - scopes, bound, newfree, + if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, ste->ste_type == ClassBlock)) goto error; @@ -955,16 +918,6 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, temp_bound = PySet_New(bound); if (!temp_bound) goto error; - if (entry->ste_parent_typeparam_overlay) { - PySTEntryObject *inner_ste = entry->ste_parent_typeparam_overlay; - PyObject *name; - Py_ssize_t pos = 0; - while (PyDict_Next(inner_ste->ste_symbols, &pos, &name, NULL)) { - if (PySet_Add(temp_bound, name) < 0) { - goto error; - } - } - } temp_free = PySet_New(free); if (!temp_free) goto error; @@ -1030,44 +983,17 @@ symtable_exit_block(struct symtable *st) return 1; } -static PySTEntryObject * -symtable_enter_typeparam_overlay(struct symtable *st, identifier name, - void *ast, int lineno, int col_offset, - int end_lineno, int end_col_offset) +static void +symtable_enter_typeparam_overlay(struct symtable *st) { - PySTEntryObject *ste = ste_new(st, name, TypeParamBlock, ast, lineno, col_offset, - end_lineno, end_col_offset); - if (ste == NULL) { - return NULL; - } - PyObject *key = PyLong_FromVoidPtr(ast); - if (key == NULL) { - Py_DECREF(ste); - return NULL; - } struct _symtable_entry *cur = st->st_cur; - cur->ste_current_typeparam_overlay = Py_NewRef(key); - if (cur->ste_typeparam_overlays == NULL) { - cur->ste_typeparam_overlays = PyDict_New(); - if (cur->ste_typeparam_overlays == NULL) { - Py_DECREF(key); - Py_DECREF(ste); - return NULL; - } - } - if (PyDict_SetItem(cur->ste_typeparam_overlays, key, (PyObject *)ste) < 0) { - Py_DECREF(key); - Py_DECREF(ste); - return NULL; - } - Py_DECREF(key); - Py_DECREF(ste); - return ste; + cur->ste_num_typeparam_scopes += 1; + cur->ste_active_typeparam_scope = cur->ste_num_typeparam_scopes; } -static int symtable_leave_typeparam_overlay(struct symtable *st) { - Py_CLEAR(st->st_cur->ste_current_typeparam_overlay); - return 1; +static void +symtable_leave_typeparam_overlay(struct symtable *st) { + st->st_cur->ste_active_typeparam_scope = 0; } static int @@ -1129,21 +1055,14 @@ static int symtable_add_typeparam(struct symtable *st, PyObject *name, int lineno, int col_offset, int end_lineno, int end_col_offset) { - PyObject *typeparams; - PyObject *current; - if (!(typeparams = PyDict_GetItemWithError(st->st_cur->ste_typeparam_overlays, - st->st_cur->ste_current_typeparam_overlay))) { - if (PyErr_Occurred()) { - return 0; - } - else { - PyErr_SetString(PyExc_SystemError, "Invalid typeparam overlay"); - return 0; - } + struct _symtable_entry *ste = st->st_cur; + assert(ste->ste_active_typeparam_scope != 0); + PyObject *mangled = _PyST_MangleTypeParam(ste, name); + if (mangled == NULL) { + return 0; } - assert(Py_IS_TYPE(typeparams, &PySTEntry_Type)); - struct _symtable_entry *ste = (struct _symtable_entry *)typeparams; PyObject *dict = ste->ste_symbols; + PyObject *current; if ((current = PyDict_GetItemWithError(dict, name))) { PyErr_Format(PyExc_SyntaxError, "duplicate type parameter '%U'", name); PyErr_RangedSyntaxLocationObject(st->st_filename, @@ -1154,7 +1073,7 @@ symtable_add_typeparam(struct symtable *st, PyObject *name, else if (PyErr_Occurred()) { return 0; } - PyObject *flags = PyLong_FromLong(LOCAL << SCOPE_OFFSET); + PyObject *flags = PyLong_FromLong(CELL << SCOPE_OFFSET); if (flags == NULL) { return 0; } @@ -1350,14 +1269,8 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ_WITH_NULL(st, expr, s->v.FunctionDef.args->kw_defaults); if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); - PySTEntryObject *ste = NULL; if (s->v.FunctionDef.typeparams) { - ste = symtable_enter_typeparam_overlay(st, s->v.FunctionDef.name, - (void *)s->v.FunctionDef.typeparams, - LOCATION(s)); - if (ste == NULL) { - VISIT_QUIT(st, 0); - } + symtable_enter_typeparam_overlay(st); VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); } if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args, @@ -1367,28 +1280,12 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) FunctionBlock, (void *)s, LOCATION(s))) VISIT_QUIT(st, 0); - if (ste != NULL) { - Py_INCREF(ste); - st->st_cur->ste_parent_typeparam_overlay = ste; - // Py_ssize_t pos = 0; - // PyObject *name; - // PyObject *cell_v = PyLong_FromLong(CELL << SCOPE_OFFSET); - // if (cell_v == NULL) { - // VISIT_QUIT(st, 0); - // } - // while (PyDict_Next(ste->ste_symbols, &pos, &name, NULL)) { - // if (PyDict_SetItem(st->st_cur->ste_symbols, name, cell_v) < 0) { - // VISIT_QUIT(st, 0); - // } - // } - } VISIT(st, arguments, s->v.FunctionDef.args); VISIT_SEQ(st, stmt, s->v.FunctionDef.body); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - if (s->v.FunctionDef.typeparams && - !symtable_leave_typeparam_overlay(st)) { - VISIT_QUIT(st, 0); + if (s->v.FunctionDef.typeparams) { + symtable_leave_typeparam_overlay(st); } break; } From aa8ea68d85e6fb40bcb5751777c6991a9d7428b7 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 08:15:33 -0600 Subject: [PATCH 025/200] correctly make it a cellvar --- Include/internal/pycore_symtable.h | 2 ++ Python/compile.c | 14 +------- Python/symtable.c | 53 ++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index f84f06d9c227ae..60706d995b4634 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -51,6 +51,7 @@ typedef struct _symtable_entry { PyObject *ste_directives;/* locations of global and nonlocal statements */ int ste_active_typeparam_scope; /* 0 if no active typeparam scope */ int ste_num_typeparam_scopes; /* number of typeparam scopes encountered */ + PyObject *ste_typeparam_names; /* set of typeparam names */ _Py_block_ty ste_type; /* module, class, function or annotation */ int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ @@ -106,6 +107,7 @@ extern PyObject* _Py_Mangle(PyObject *p, PyObject *name); #define DEF_IMPORT 2<<6 /* assignment occurred via import */ #define DEF_ANNOT 2<<7 /* this name is annotated */ #define DEF_COMP_ITER 2<<8 /* this name is a comprehension iteration variable */ +#define DEF_TYPE_PARAM 2<<9 /* this name is a type parameter */ #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) diff --git a/Python/compile.c b/Python/compile.c index ff4cd4f79facc3..2e12f7ecab058f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1274,6 +1274,7 @@ compiler_enter_scope(struct compiler *c, identifier name, compiler_unit_free(u); return ERROR; } + u->u_ste->ste_num_typeparam_scopes = 0; u->u_name = Py_NewRef(name); u->u_varnames = list2dict(u->u_ste->ste_varnames); u->u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, 0, 0); @@ -1281,19 +1282,6 @@ compiler_enter_scope(struct compiler *c, identifier name, compiler_unit_free(u); return ERROR; } - // if (u->u_ste->ste_parent_typeparam_overlay) { - // PySTEntryObject *ste = u->u_ste->ste_parent_typeparam_overlay; - // Py_ssize_t size = PyDict_Size(u->u_cellvars); - // Py_ssize_t pos = 0; - // while (PyDict_Next(ste->ste_symbols, &pos, &name, NULL)) { - // PyObject *val = PyLong_FromLong(size); - // size++; - // if (PyDict_SetItem(u->u_cellvars, name, val) < 0) { - // compiler_unit_free(u); - // return ERROR; - // } - // } - // } if (u->u_ste->ste_needs_class_closure) { /* Cook up an implicit __class__ cell. */ int res; diff --git a/Python/symtable.c b/Python/symtable.c index 07cd59fb5e8d2e..2d22105af1f767 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -80,6 +80,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_children = NULL; ste->ste_num_typeparam_scopes = 0; ste->ste_active_typeparam_scope = 0; + ste->ste_typeparam_names = NULL; ste->ste_directives = NULL; @@ -143,6 +144,7 @@ ste_dealloc(PySTEntryObject *ste) Py_XDECREF(ste->ste_varnames); Py_XDECREF(ste->ste_children); Py_XDECREF(ste->ste_directives); + Py_XDECREF(ste->ste_typeparam_names); PyObject_Free(ste); } @@ -405,6 +407,10 @@ _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) return 0; } v = PyDict_GetItemWithError(ste->ste_symbols, mangled); + if (v) { + printf("Look for mangled %s in %p: %p %d %d\n", PyUnicode_AsUTF8(mangled), ste->ste_symbols, v, + PyLong_AS_LONG(v), (PyLong_AS_LONG(v) >> SCOPE_OFFSET) & SCOPE_MASK); + } Py_DECREF(mangled); assert(!PyErr_Occurred()); } @@ -653,6 +659,9 @@ update_symbols(PyObject *symbols, PyObject *scopes, long scope, flags; assert(PyLong_Check(v)); flags = PyLong_AS_LONG(v); + if (flags & DEF_TYPE_PARAM) { + continue; + } v_scope = PyDict_GetItemWithError(scopes, name); assert(v_scope && PyLong_Check(v_scope)); scope = PyLong_AS_LONG(v_scope); @@ -983,17 +992,23 @@ symtable_exit_block(struct symtable *st) return 1; } -static void +static int symtable_enter_typeparam_overlay(struct symtable *st) { struct _symtable_entry *cur = st->st_cur; cur->ste_num_typeparam_scopes += 1; cur->ste_active_typeparam_scope = cur->ste_num_typeparam_scopes; + cur->ste_typeparam_names = PySet_New(NULL); + if (cur->ste_typeparam_names == NULL) { + return 0; + } + return 1; } static void symtable_leave_typeparam_overlay(struct symtable *st) { st->st_cur->ste_active_typeparam_scope = 0; + Py_CLEAR(st->st_cur->ste_typeparam_names); } static int @@ -1063,24 +1078,34 @@ symtable_add_typeparam(struct symtable *st, PyObject *name, } PyObject *dict = ste->ste_symbols; PyObject *current; - if ((current = PyDict_GetItemWithError(dict, name))) { + if ((current = PyDict_GetItemWithError(dict, mangled))) { PyErr_Format(PyExc_SyntaxError, "duplicate type parameter '%U'", name); PyErr_RangedSyntaxLocationObject(st->st_filename, lineno, col_offset + 1, end_lineno, end_col_offset + 1); + Py_DECREF(mangled); return 0; } else if (PyErr_Occurred()) { + Py_DECREF(mangled); return 0; } - PyObject *flags = PyLong_FromLong(CELL << SCOPE_OFFSET); + PyObject *flags = PyLong_FromLong((CELL << SCOPE_OFFSET) | DEF_TYPE_PARAM); if (flags == NULL) { + Py_DECREF(mangled); return 0; } - if (PyDict_SetItem(dict, name, flags) < 0) { + if (PyDict_SetItem(dict, mangled, flags) < 0) { + Py_DECREF(mangled); Py_DECREF(flags); return 0; } + if (PySet_Add(ste->ste_typeparam_names, name) < 0) { + Py_DECREF(mangled); + Py_DECREF(flags); + return 0; + } + Py_DECREF(mangled); Py_DECREF(flags); return 1; } @@ -1094,9 +1119,23 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s long val; PyObject *mangled = _Py_Mangle(st->st_private, name); - if (!mangled) return 0; + if (ste->ste_active_typeparam_scope != 0) { + int result = PySet_Contains(ste->ste_typeparam_names, name); + if (result == -1) { + goto error; + } + if (result) { + PyObject *new_mangled = _PyST_MangleTypeParam(ste, name); + if (new_mangled == NULL) { + goto error; + } + printf("Mangled %s to %s\n", PyUnicode_AsUTF8(name), PyUnicode_AsUTF8(new_mangled)); + flag = CELL << SCOPE_OFFSET; + Py_SETREF(mangled, new_mangled); + } + } dict = ste->ste_symbols; if ((o = PyDict_GetItemWithError(dict, mangled))) { val = PyLong_AS_LONG(o); @@ -1270,7 +1309,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); if (s->v.FunctionDef.typeparams) { - symtable_enter_typeparam_overlay(st); + if (!symtable_enter_typeparam_overlay(st)) { + VISIT_QUIT(st, 0); + } VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); } if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args, From ab6b7189d22c016fa2ae76841846c3ba07b0bec0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 11:46:40 -0600 Subject: [PATCH 026/200] Now it works --- Include/internal/pycore_symtable.h | 4 +- Python/compile.c | 23 ++++-- Python/symtable.c | 115 ++--------------------------- 3 files changed, 28 insertions(+), 114 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 60706d995b4634..43c04a453d05a5 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -51,7 +51,9 @@ typedef struct _symtable_entry { PyObject *ste_directives;/* locations of global and nonlocal statements */ int ste_active_typeparam_scope; /* 0 if no active typeparam scope */ int ste_num_typeparam_scopes; /* number of typeparam scopes encountered */ - PyObject *ste_typeparam_names; /* set of typeparam names */ + PyObject *ste_typeparam_map; /* map of typeparam names to mangled names, + only exists while we're in ste_active_typeparam_scope */ + PyObject *ste_parent_typeparam_map; /* same, but represents typeparams present in parents */ _Py_block_ty ste_type; /* module, class, function or annotation */ int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ diff --git a/Python/compile.c b/Python/compile.c index 2e12f7ecab058f..f1707fd95b167f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2204,9 +2204,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } if (typeparams) { - assert(c->u->u_ste->ste_active_typeparam_scope == 0); - c->u->u_ste->ste_num_typeparam_scopes += 1; - c->u->u_ste->ste_active_typeparam_scope = c->u->u_ste->ste_num_typeparam_scopes; + ADDOP(c, loc, PUSH_NULL); + RETURN_IF_ERROR( + compiler_enter_scope(c, name, scope_type, (void *)typeparams, firstlineno)); RETURN_IF_ERROR(compiler_type_params(c, typeparams)); } @@ -2242,9 +2242,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } co = assemble(c, 1); compiler_exit_scope(c); - if (typeparams) { - c->u->u_ste->ste_active_typeparam_scope = 0; - } if (co == NULL) { Py_XDECREF(co); return ERROR; @@ -2254,6 +2251,19 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); + if (typeparams) { + PyCodeObject *co = assemble(c, 0); + compiler_exit_scope(c); + if (co == NULL) { + return ERROR; + } + if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + ADDOP_I(c, loc, CALL, 0); + } RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); return compiler_nameop(c, loc, name, Store); @@ -7105,6 +7115,7 @@ compute_localsplus_info(struct compiler_unit *u, int nlocalsplus, { PyObject *k, *v; Py_ssize_t pos = 0; + // printf("compute_localsplus_info %d %s\n", nlocalsplus, PyUnicode_AsUTF8(u->u_name)); while (PyDict_Next(u->u_varnames, &pos, &k, &v)) { int offset = (int)PyLong_AS_LONG(v); assert(offset >= 0); diff --git a/Python/symtable.c b/Python/symtable.c index 2d22105af1f767..609e6e34323270 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -78,9 +78,6 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_symbols = NULL; ste->ste_varnames = NULL; ste->ste_children = NULL; - ste->ste_num_typeparam_scopes = 0; - ste->ste_active_typeparam_scope = 0; - ste->ste_typeparam_names = NULL; ste->ste_directives = NULL; @@ -144,7 +141,6 @@ ste_dealloc(PySTEntryObject *ste) Py_XDECREF(ste->ste_varnames); Py_XDECREF(ste->ste_children); Py_XDECREF(ste->ste_directives); - Py_XDECREF(ste->ste_typeparam_names); PyObject_Free(ste); } @@ -390,30 +386,10 @@ PySymtable_Lookup(struct symtable *st, void *key) return (PySTEntryObject *)Py_XNewRef(v); } -PyObject * -_PyST_MangleTypeParam(PySTEntryObject *ste, PyObject *name) -{ - return PyUnicode_FromFormat("%d.%U", ste->ste_active_typeparam_scope, name); -} - long _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) { PyObject *v = NULL; - if (ste->ste_active_typeparam_scope) { - PyObject *mangled = _PyST_MangleTypeParam(ste, name); - if (mangled == NULL) { - assert(PyErr_Occurred()); - return 0; - } - v = PyDict_GetItemWithError(ste->ste_symbols, mangled); - if (v) { - printf("Look for mangled %s in %p: %p %d %d\n", PyUnicode_AsUTF8(mangled), ste->ste_symbols, v, - PyLong_AS_LONG(v), (PyLong_AS_LONG(v) >> SCOPE_OFFSET) & SCOPE_MASK); - } - Py_DECREF(mangled); - assert(!PyErr_Occurred()); - } if (v == NULL) { v = PyDict_GetItemWithError(ste->ste_symbols, name); } @@ -992,25 +968,6 @@ symtable_exit_block(struct symtable *st) return 1; } -static int -symtable_enter_typeparam_overlay(struct symtable *st) -{ - struct _symtable_entry *cur = st->st_cur; - cur->ste_num_typeparam_scopes += 1; - cur->ste_active_typeparam_scope = cur->ste_num_typeparam_scopes; - cur->ste_typeparam_names = PySet_New(NULL); - if (cur->ste_typeparam_names == NULL) { - return 0; - } - return 1; -} - -static void -symtable_leave_typeparam_overlay(struct symtable *st) { - st->st_cur->ste_active_typeparam_scope = 0; - Py_CLEAR(st->st_cur->ste_typeparam_names); -} - static int symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block, void *ast, int lineno, int col_offset, @@ -1066,50 +1023,6 @@ symtable_lookup(struct symtable *st, PyObject *name) return ret; } -static int -symtable_add_typeparam(struct symtable *st, PyObject *name, - int lineno, int col_offset, int end_lineno, int end_col_offset) -{ - struct _symtable_entry *ste = st->st_cur; - assert(ste->ste_active_typeparam_scope != 0); - PyObject *mangled = _PyST_MangleTypeParam(ste, name); - if (mangled == NULL) { - return 0; - } - PyObject *dict = ste->ste_symbols; - PyObject *current; - if ((current = PyDict_GetItemWithError(dict, mangled))) { - PyErr_Format(PyExc_SyntaxError, "duplicate type parameter '%U'", name); - PyErr_RangedSyntaxLocationObject(st->st_filename, - lineno, col_offset + 1, - end_lineno, end_col_offset + 1); - Py_DECREF(mangled); - return 0; - } - else if (PyErr_Occurred()) { - Py_DECREF(mangled); - return 0; - } - PyObject *flags = PyLong_FromLong((CELL << SCOPE_OFFSET) | DEF_TYPE_PARAM); - if (flags == NULL) { - Py_DECREF(mangled); - return 0; - } - if (PyDict_SetItem(dict, mangled, flags) < 0) { - Py_DECREF(mangled); - Py_DECREF(flags); - return 0; - } - if (PySet_Add(ste->ste_typeparam_names, name) < 0) { - Py_DECREF(mangled); - Py_DECREF(flags); - return 0; - } - Py_DECREF(mangled); - Py_DECREF(flags); - return 1; -} - static int symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _symtable_entry *ste, int lineno, int col_offset, int end_lineno, int end_col_offset) @@ -1121,21 +1034,6 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s if (!mangled) return 0; - if (ste->ste_active_typeparam_scope != 0) { - int result = PySet_Contains(ste->ste_typeparam_names, name); - if (result == -1) { - goto error; - } - if (result) { - PyObject *new_mangled = _PyST_MangleTypeParam(ste, name); - if (new_mangled == NULL) { - goto error; - } - printf("Mangled %s to %s\n", PyUnicode_AsUTF8(name), PyUnicode_AsUTF8(new_mangled)); - flag = CELL << SCOPE_OFFSET; - Py_SETREF(mangled, new_mangled); - } - } dict = ste->ste_symbols; if ((o = PyDict_GetItemWithError(dict, mangled))) { val = PyLong_AS_LONG(o); @@ -1309,7 +1207,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); if (s->v.FunctionDef.typeparams) { - if (!symtable_enter_typeparam_overlay(st)) { + if (!symtable_enter_block(st, s->v.FunctionDef.name, + FunctionBlock, (void *)s->v.FunctionDef.typeparams, + LOCATION(s))) { VISIT_QUIT(st, 0); } VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); @@ -1326,7 +1226,8 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); if (s->v.FunctionDef.typeparams) { - symtable_leave_typeparam_overlay(st); + if (!symtable_exit_block(st)) + VISIT_QUIT(st, 0); } break; } @@ -1857,17 +1758,17 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) } switch(tp->kind) { case TypeVar_kind: - if (!symtable_add_typeparam(st, tp->v.TypeVar.name, LOCATION(tp))) + if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); if (tp->v.TypeVar.bound) VISIT(st, expr, tp->v.TypeVar.bound); break; case TypeVarTuple_kind: - if (!symtable_add_typeparam(st, tp->v.TypeVarTuple.name, LOCATION(tp))) + if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); break; case ParamSpec_kind: - if (!symtable_add_typeparam(st, tp->v.ParamSpec.name, LOCATION(tp))) + if (!symtable_add_def(st, tp->v.ParamSpec.name, DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); break; } From dba4293fa553d8d4197c0d504353dc4be72efe64 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 14:09:04 -0600 Subject: [PATCH 027/200] fix defaults --- Python/compile.c | 42 +++++++++++++++++++++++++++++++++++++----- Python/symtable.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index f1707fd95b167f..34b019f9f83de6 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2198,15 +2198,33 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } location loc = LOC(s); + + if (typeparams) { + ADDOP(c, loc, PUSH_NULL); + } + funcflags = compiler_default_arguments(c, loc, args); if (funcflags == -1) { return ERROR; } if (typeparams) { - ADDOP(c, loc, PUSH_NULL); - RETURN_IF_ERROR( - compiler_enter_scope(c, name, scope_type, (void *)typeparams, firstlineno)); + PyObject *typeparams_name = PyUnicode_FromFormat("", name); + if (!typeparams_name) { + return ERROR; + } + if (compiler_enter_scope(c, typeparams_name, scope_type, + (void *)typeparams, firstlineno) == -1) { + Py_DECREF(typeparams_name); + return ERROR; + } + Py_DECREF(typeparams_name); + if ((funcflags & 0x01) || (funcflags & 0x02)) { + ADDOP_I(c, loc, LOAD_FAST, 0); + } + if ((funcflags & 0x01) && (funcflags & 0x02)) { + ADDOP_I(c, loc, LOAD_FAST, 1); + } RETURN_IF_ERROR(compiler_type_params(c, typeparams)); } @@ -2252,6 +2270,12 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } Py_DECREF(co); if (typeparams) { + if (funcflags & 0x02) { + c->u->u_argcount += 1; + } + if (funcflags & 0x01) { + c->u->u_argcount += 1; + } PyCodeObject *co = assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2262,7 +2286,16 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); - ADDOP_I(c, loc, CALL, 0); + int oparg = 0; + if ((funcflags & 0x01) && (funcflags & 0x02)) { + ADDOP_I(c, loc, SWAP, 3); + oparg = 2; + } + else if ((funcflags & 0x01) || (funcflags & 0x02)) { + ADDOP_I(c, loc, SWAP, 2); + oparg = 1; + } + ADDOP_I(c, loc, CALL, oparg); } RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); @@ -7115,7 +7148,6 @@ compute_localsplus_info(struct compiler_unit *u, int nlocalsplus, { PyObject *k, *v; Py_ssize_t pos = 0; - // printf("compute_localsplus_info %d %s\n", nlocalsplus, PyUnicode_AsUTF8(u->u_name)); while (PyDict_Next(u->u_varnames, &pos, &k, &v)) { int offset = (int)PyLong_AS_LONG(v); assert(offset >= 0); diff --git a/Python/symtable.c b/Python/symtable.c index 609e6e34323270..8ed7577bf42f67 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1187,6 +1187,17 @@ symtable_record_directive(struct symtable *st, identifier name, int lineno, return res == 0; } +static int +has_kwonlydefaults(asdl_arg_seq *kwonlyargs, asdl_expr_seq *kw_defaults) +{ + for (int i = 0; i < asdl_seq_LEN(kwonlyargs); i++) { + expr_ty default_ = asdl_seq_GET(kw_defaults, i); + if (default_) { + return 1; + } + } + return 0; +} static int symtable_visit_stmt(struct symtable *st, stmt_ty s) @@ -1212,6 +1223,29 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) LOCATION(s))) { VISIT_QUIT(st, 0); } + if (s->v.FunctionDef.args->defaults) { + PyObject *defaults_name = PyUnicode_FromString(".defaults"); + if (defaults_name == NULL) { + VISIT_QUIT(st, 0); + } + if (!symtable_add_def(st, defaults_name, DEF_PARAM, LOCATION(s))) { + Py_DECREF(defaults_name); + VISIT_QUIT(st, 0); + } + Py_DECREF(defaults_name); + } + if (has_kwonlydefaults(s->v.FunctionDef.args->kwonlyargs, + s->v.FunctionDef.args->kw_defaults)) { + PyObject *kwonly_name = PyUnicode_FromString(".kwonlydefaults"); + if (kwonly_name == NULL) { + VISIT_QUIT(st, 0); + } + if (!symtable_add_def(st, kwonly_name, DEF_PARAM, LOCATION(s))) { + Py_DECREF(kwonly_name); + VISIT_QUIT(st, 0); + } + Py_DECREF(kwonly_name); + } VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); } if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args, From e36c5f53858fdde59f1d4194fe9874b091c75810 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 14:11:56 -0600 Subject: [PATCH 028/200] undo some unnecessary changes --- Include/internal/pycore_symtable.h | 8 +------- Python/compile.c | 2 -- Python/symtable.c | 3 --- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 43c04a453d05a5..512c4c931f73e4 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -10,7 +10,7 @@ extern "C" { struct _mod; // Type defined in pycore_ast.h -typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, AnnotationBlock, TypeParamBlock } +typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, AnnotationBlock } _Py_block_ty; typedef enum _comprehension_type { @@ -49,11 +49,6 @@ typedef struct _symtable_entry { PyObject *ste_varnames; /* list of function parameters */ PyObject *ste_children; /* list of child blocks */ PyObject *ste_directives;/* locations of global and nonlocal statements */ - int ste_active_typeparam_scope; /* 0 if no active typeparam scope */ - int ste_num_typeparam_scopes; /* number of typeparam scopes encountered */ - PyObject *ste_typeparam_map; /* map of typeparam names to mangled names, - only exists while we're in ste_active_typeparam_scope */ - PyObject *ste_parent_typeparam_map; /* same, but represents typeparams present in parents */ _Py_block_ty ste_type; /* module, class, function or annotation */ int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ @@ -109,7 +104,6 @@ extern PyObject* _Py_Mangle(PyObject *p, PyObject *name); #define DEF_IMPORT 2<<6 /* assignment occurred via import */ #define DEF_ANNOT 2<<7 /* this name is annotated */ #define DEF_COMP_ITER 2<<8 /* this name is a comprehension iteration variable */ -#define DEF_TYPE_PARAM 2<<9 /* this name is a type parameter */ #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) diff --git a/Python/compile.c b/Python/compile.c index 34b019f9f83de6..9890c1151449d9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -196,7 +196,6 @@ enum { COMPILER_SCOPE_ASYNC_FUNCTION, COMPILER_SCOPE_LAMBDA, COMPILER_SCOPE_COMPREHENSION, - COMPILER_SCOPE_TYPE_PARAMS, }; typedef struct { @@ -1274,7 +1273,6 @@ compiler_enter_scope(struct compiler *c, identifier name, compiler_unit_free(u); return ERROR; } - u->u_ste->ste_num_typeparam_scopes = 0; u->u_name = Py_NewRef(name); u->u_varnames = list2dict(u->u_ste->ste_varnames); u->u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, 0, 0); diff --git a/Python/symtable.c b/Python/symtable.c index 8ed7577bf42f67..0bcba93da5c153 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -635,9 +635,6 @@ update_symbols(PyObject *symbols, PyObject *scopes, long scope, flags; assert(PyLong_Check(v)); flags = PyLong_AS_LONG(v); - if (flags & DEF_TYPE_PARAM) { - continue; - } v_scope = PyDict_GetItemWithError(scopes, name); assert(v_scope && PyLong_Check(v_scope)); scope = PyLong_AS_LONG(v_scope); From 21e1b1ac5bf3c9e479a027d48ea59039ea9bb4ca Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 16:13:14 -0600 Subject: [PATCH 029/200] support async def --- Python/compile.c | 2 +- Python/symtable.c | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 9890c1151449d9..e8443b3387fa2b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2211,7 +2211,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) if (!typeparams_name) { return ERROR; } - if (compiler_enter_scope(c, typeparams_name, scope_type, + if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_FUNCTION, (void *)typeparams, firstlineno) == -1) { Py_DECREF(typeparams_name); return ERROR; diff --git a/Python/symtable.c b/Python/symtable.c index 0bcba93da5c153..7b5181920aaab3 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1488,11 +1488,42 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.AsyncFunctionDef.args->kw_defaults) VISIT_SEQ_WITH_NULL(st, expr, s->v.AsyncFunctionDef.args->kw_defaults); + if (s->v.AsyncFunctionDef.decorator_list) + VISIT_SEQ(st, expr, s->v.AsyncFunctionDef.decorator_list); + if (s->v.AsyncFunctionDef.typeparams) { + if (!symtable_enter_block(st, s->v.AsyncFunctionDef.name, + FunctionBlock, (void *)s->v.AsyncFunctionDef.typeparams, + LOCATION(s))) { + VISIT_QUIT(st, 0); + } + if (s->v.AsyncFunctionDef.args->defaults) { + PyObject *defaults_name = PyUnicode_FromString(".defaults"); + if (defaults_name == NULL) { + VISIT_QUIT(st, 0); + } + if (!symtable_add_def(st, defaults_name, DEF_PARAM, LOCATION(s))) { + Py_DECREF(defaults_name); + VISIT_QUIT(st, 0); + } + Py_DECREF(defaults_name); + } + if (has_kwonlydefaults(s->v.AsyncFunctionDef.args->kwonlyargs, + s->v.AsyncFunctionDef.args->kw_defaults)) { + PyObject *kwonly_name = PyUnicode_FromString(".kwonlydefaults"); + if (kwonly_name == NULL) { + VISIT_QUIT(st, 0); + } + if (!symtable_add_def(st, kwonly_name, DEF_PARAM, LOCATION(s))) { + Py_DECREF(kwonly_name); + VISIT_QUIT(st, 0); + } + Py_DECREF(kwonly_name); + } + VISIT_SEQ(st, typeparam, s->v.AsyncFunctionDef.typeparams); + } if (!symtable_visit_annotations(st, s, s->v.AsyncFunctionDef.args, s->v.AsyncFunctionDef.returns)) VISIT_QUIT(st, 0); - if (s->v.AsyncFunctionDef.decorator_list) - VISIT_SEQ(st, expr, s->v.AsyncFunctionDef.decorator_list); if (!symtable_enter_block(st, s->v.AsyncFunctionDef.name, FunctionBlock, (void *)s, s->lineno, s->col_offset, @@ -1503,6 +1534,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ(st, stmt, s->v.AsyncFunctionDef.body); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); + if (s->v.AsyncFunctionDef.typeparams) { + if (!symtable_exit_block(st)) + VISIT_QUIT(st, 0); + } break; case AsyncWith_kind: VISIT_SEQ(st, withitem, s->v.AsyncWith.items); From 85051347b17fe6c2339977603a7a4b75c450c2d6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 17:21:48 -0600 Subject: [PATCH 030/200] start class support --- Python/compile.c | 33 ++++++++++++++++++++++++++++++++- Python/symtable.c | 16 ++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index e8443b3387fa2b..6e7161508fd0e2 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2313,6 +2313,24 @@ compiler_class(struct compiler *c, stmt_ty s) if (asdl_seq_LEN(decos)) { firstlineno = ((expr_ty)asdl_seq_GET(decos, 0))->lineno; } + location loc = LOC(s); + + asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; + if (typeparams) { + ADDOP(c, loc, PUSH_NULL); + PyObject *typeparams_name = PyUnicode_FromFormat("", + s->v.ClassDef.name); + if (!typeparams_name) { + return ERROR; + } + if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_FUNCTION, + (void *)typeparams, firstlineno) == -1) { + Py_DECREF(typeparams_name); + return ERROR; + } + Py_DECREF(typeparams_name); + RETURN_IF_ERROR(compiler_type_params(c, typeparams)); + } /* ultimately generate code for: = __build_class__(, , *, **) @@ -2387,7 +2405,6 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } - location loc = LOC(s); /* 2. load the 'build_class' function */ ADDOP(c, loc, PUSH_NULL); ADDOP(c, loc, LOAD_BUILD_CLASS); @@ -2407,6 +2424,20 @@ compiler_class(struct compiler *c, stmt_ty s) s->v.ClassDef.bases, s->v.ClassDef.keywords)); + if (typeparams) { + PyCodeObject *co = assemble(c, 0); + compiler_exit_scope(c); + if (co == NULL) { + return ERROR; + } + if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + ADDOP_I(c, loc, CALL, 0); + } + /* 6. apply decorators */ RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); diff --git a/Python/symtable.c b/Python/symtable.c index 7b5181920aaab3..caa5fe069cfa61 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1266,10 +1266,18 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) PyObject *tmp; if (!symtable_add_def(st, s->v.ClassDef.name, DEF_LOCAL, LOCATION(s))) VISIT_QUIT(st, 0); - VISIT_SEQ(st, expr, s->v.ClassDef.bases); - VISIT_SEQ(st, keyword, s->v.ClassDef.keywords); if (s->v.ClassDef.decorator_list) VISIT_SEQ(st, expr, s->v.ClassDef.decorator_list); + if (s->v.ClassDef.typeparams) { + if (!symtable_enter_block(st, s->v.ClassDef.name, + FunctionBlock, (void *)s->v.ClassDef.typeparams, + LOCATION(s))) { + VISIT_QUIT(st, 0); + } + VISIT_SEQ(st, typeparam, s->v.ClassDef.typeparams); + } + VISIT_SEQ(st, expr, s->v.ClassDef.bases); + VISIT_SEQ(st, keyword, s->v.ClassDef.keywords); if (!symtable_enter_block(st, s->v.ClassDef.name, ClassBlock, (void *)s, s->lineno, s->col_offset, s->end_lineno, s->end_col_offset)) @@ -1280,6 +1288,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) st->st_private = tmp; if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); + if (s->v.ClassDef.typeparams) { + if (!symtable_exit_block(st)) + VISIT_QUIT(st, 0); + } break; } case Return_kind: From 338b97884237c6ed63d2a980954fb64f89440d07 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 17:29:22 -0600 Subject: [PATCH 031/200] detect duplicate type params --- Include/internal/pycore_symtable.h | 1 + Python/symtable.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 512c4c931f73e4..c6d61805b39b22 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -104,6 +104,7 @@ extern PyObject* _Py_Mangle(PyObject *p, PyObject *name); #define DEF_IMPORT 2<<6 /* assignment occurred via import */ #define DEF_ANNOT 2<<7 /* this name is annotated */ #define DEF_COMP_ITER 2<<8 /* this name is a comprehension iteration variable */ +#define DEF_TYPE_PARAM 2<<9 /* this name is a type parameter */ #define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) diff --git a/Python/symtable.c b/Python/symtable.c index caa5fe069cfa61..7a57f48686b271 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -47,6 +47,9 @@ #define ANNOTATION_NOT_ALLOWED \ "'%s' can not be used within an annotation" +#define DUPLICATE_TYPE_PARAM \ +"duplicate type parameter '%U'" + #define LOCATION(x) \ (x)->lineno, (x)->col_offset, (x)->end_lineno, (x)->end_col_offset @@ -1042,6 +1045,13 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s end_lineno, end_col_offset + 1); goto error; } + if ((flag & DEF_TYPE_PARAM) && (val & DEF_TYPE_PARAM)) { + PyErr_Format(PyExc_SyntaxError, DUPLICATE_TYPE_PARAM, name); + PyErr_RangedSyntaxLocationObject(st->st_filename, + lineno, col_offset + 1, + end_lineno, end_col_offset + 1); + goto error; + } val |= flag; } else if (PyErr_Occurred()) { @@ -1836,17 +1846,17 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) } switch(tp->kind) { case TypeVar_kind: - if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_LOCAL, LOCATION(tp))) + if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); if (tp->v.TypeVar.bound) VISIT(st, expr, tp->v.TypeVar.bound); break; case TypeVarTuple_kind: - if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_LOCAL, LOCATION(tp))) + if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); break; case ParamSpec_kind: - if (!symtable_add_def(st, tp->v.ParamSpec.name, DEF_LOCAL, LOCATION(tp))) + if (!symtable_add_def(st, tp->v.ParamSpec.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); break; } From 04bc911e33f4b31b371848602c9336638d8c7be1 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 23:18:17 -0600 Subject: [PATCH 032/200] clean up some whitespace --- Lib/test/test_type_params.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index cd9ac2a6d33188..61b206372a2159 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -231,12 +231,11 @@ def func[T](a: T, b: S) -> T | S: exec(code, {}, {}) - class TypeParamsTypeVarTest(unittest.TestCase): def test_typevar_01(self): def func1[A: str, B: str | int, C: (int, str)](): return (A, B, C) - + a, b, c = func1() self.assertIsInstance(a, TypeVar) @@ -257,7 +256,7 @@ def func1[A: str, B: str | int, C: (int, str)](): self.assertTrue(c.__autovariance__) self.assertFalse(c.__covariant__) self.assertFalse(c.__contravariant__) - + def test_typevar_generator(self): def get_generator[A](): def generator1[C](): @@ -268,7 +267,7 @@ def generator2[B](): yield B yield from generator1() return generator2 - + gen = get_generator() a, b, c = [x for x in gen()] @@ -285,7 +284,7 @@ def get_coroutine[A](): async def coroutine[B](): return (A, B) return coroutine - + co = get_coroutine() a, b = asyncio.run(co()) @@ -306,11 +305,11 @@ def func1[*A: str](): with self.assertRaisesRegex(SyntaxError, r"expected '\('"): exec(code, {}, {}) - + def test_typevartuple_02(self): def func1[*A](): return A - + a = func1() self.assertIsInstance(a, TypeVarTuple) @@ -325,11 +324,11 @@ def func1[**A: str](): with self.assertRaisesRegex(SyntaxError, r"expected '\('"): exec(code, {}, {}) - + def test_paramspec_02(self): def func1[**A](): return A - + a = func1() self.assertIsInstance(a, ParamSpec) self.assertTrue(a.__autovariance__) @@ -345,7 +344,7 @@ class Inner[C, D]: @staticmethod def get_typeparams(): return A, B, C, D - + a, b, c, d = Outer.Inner.get_typeparams() self.assertEqual(Outer.__type_variables__, (a, b)) self.assertEqual(Outer.Inner.__type_variables__, (a, b, c, d)) @@ -356,7 +355,7 @@ def get_typeparams(): def test_typeparams_dunder_class_02(self): class ClassA: pass - + self.assertEqual(ClassA.__type_variables__, ()) def test_typeparams_dunder_class_03(self): @@ -374,9 +373,9 @@ def test_typeparams_dunder_function_01(self): def outer[A, B](): def inner[C, D](): return A, B, C, D - + return inner - + inner = outer() a, b, c, d = inner() self.assertEqual(outer.__type_variables__, (a, b)) @@ -385,7 +384,7 @@ def inner[C, D](): def test_typeparams_dunder_function_02(self): def func1(): pass - + self.assertEqual(func1.__type_variables__, ()) def test_typeparams_dunder_function_03(self): From 521bd813a04d8874626e5b6b6ec6ea97ff5892e6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 23:46:26 -0600 Subject: [PATCH 033/200] Improve some tests --- Lib/test/test_type_params.py | 67 +++++++++++++++++------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 61b206372a2159..1e48e5d0ae19cf 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -8,15 +8,15 @@ class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): code = """def func[**A, A](): ...""" with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_02(self): code = """def func[A](A): ...""" - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_03(self): code = """def func[A](*A): ...""" - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_04(self): # Mangled names should not cause a conflict. @@ -25,7 +25,7 @@ class ClassA: def func[__A](self, __A): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_05(self): code = textwrap.dedent("""\ @@ -33,7 +33,7 @@ class ClassA: def func[_ClassA__A](self, __A): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_06(self): code = textwrap.dedent("""\ @@ -41,7 +41,7 @@ class ClassA[X]: def func(self, X): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_07(self): code = textwrap.dedent("""\ @@ -50,7 +50,7 @@ def func(self): X = 1 """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_08(self): code = textwrap.dedent("""\ @@ -59,7 +59,7 @@ def func(self): a = [X for X in []] """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_9(self): code = textwrap.dedent("""\ @@ -68,7 +68,7 @@ def func[X](self): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_10(self): code = textwrap.dedent("""\ @@ -76,7 +76,7 @@ class ClassA[X]: X: int """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_11(self): code = textwrap.dedent("""\ @@ -86,7 +86,7 @@ def inner[X](): nonlocal X """ ) - exec(code, {}, {}) + exec(code, {}) def test_name_non_collision_13(self): code = textwrap.dedent("""\ @@ -96,7 +96,7 @@ def inner[X](): global X """ ) - exec(code, {}, {}) + exec(code, {}) class TypeParamsAccessTest(unittest.TestCase): @@ -106,7 +106,7 @@ class ClassA[A, B](dict[A, B]): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_class_access_02(self): code = textwrap.dedent("""\ @@ -115,7 +115,7 @@ class ClassA[A, B](metaclass=MyMeta[A, B]): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_class_access_03(self): code = textwrap.dedent("""\ @@ -128,7 +128,7 @@ class ClassA[A, B](): ) with self.assertRaisesRegex(NameError, "name 'A' is not defined"): - exec(code, {}, {}) + exec(code, {}) def test_function_access_01(self): code = textwrap.dedent("""\ @@ -136,7 +136,7 @@ def func[A, B](a: dict[A, B]): ... """ ) - exec(code, {}, {}) + exec(code, {}) def test_function_access_02(self): code = textwrap.dedent("""\ @@ -146,7 +146,7 @@ def func[A](a = list[A]()): ) with self.assertRaisesRegex(NameError, "name 'A' is not defined"): - exec(code, {}, {}) + exec(code, {}) def test_function_access_03(self): code = textwrap.dedent("""\ @@ -159,7 +159,7 @@ def func[A](): ) with self.assertRaisesRegex(NameError, "name 'A' is not defined"): - exec(code, {}, {}) + exec(code, {}) def test_nested_access_01(self): code = textwrap.dedent("""\ @@ -170,7 +170,7 @@ def funcD[D](self): lambda : (A, B, C, D) """ ) - exec(code, {}, {}) + exec(code, {}) def test_out_of_scope_01(self): code = textwrap.dedent("""\ @@ -180,7 +180,7 @@ class ClassA[T]: ... ) with self.assertRaisesRegex(NameError, "name 'T' is not defined"): - exec(code, {}, {}) + exec(code, {}) def test_out_of_scope_02(self): code = textwrap.dedent("""\ @@ -192,7 +192,7 @@ def funcB[B](self): ... ) with self.assertRaisesRegex(NameError, "name 'B' is not defined"): - exec(code, {}, {}) + exec(code, {}) class TypeParamsTraditionalTypeVars(unittest.TestCase): @@ -204,7 +204,7 @@ class ClassA[T](Generic[T]): ... ) with self.assertRaisesRegex(TypeError, r"Cannot inherit from Generic\[...\] multiple types."): - exec(code, {}, {}) + exec(code, {}) def test_traditional_02(self): code = textwrap.dedent("""\ @@ -215,20 +215,15 @@ class ClassA[T](dict[T, S]): ... ) with self.assertRaisesRegex(TypeError, r"Some type variables \(~S\) are not listed in Generic\[T\]"): - exec(code, {}, {}) + exec(code, {}) def test_traditional_03(self): - code = textwrap.dedent("""\ - from typing import TypeVar - S = TypeVar("S") - def func[T](a: T, b: S) -> T | S: - return a - """ - ) - # This does not generate a runtime error, but it should be # flagged as an error by type checkers. - exec(code, {}, {}) + from typing import TypeVar + S = TypeVar("S") + def func[T](a: T, b: S) -> T | S: + return a class TypeParamsTypeVarTest(unittest.TestCase): @@ -304,7 +299,7 @@ def func1[*A: str](): ) with self.assertRaisesRegex(SyntaxError, r"expected '\('"): - exec(code, {}, {}) + exec(code, {}) def test_typevartuple_02(self): def func1[*A](): @@ -323,7 +318,7 @@ def func1[**A: str](): ) with self.assertRaisesRegex(SyntaxError, r"expected '\('"): - exec(code, {}, {}) + exec(code, {}) def test_paramspec_02(self): def func1[**A](): @@ -367,7 +362,7 @@ class ClassA[A](): ) with self.assertRaisesRegex(AttributeError, "attribute '__type_variables__' of 'type' objects is not writable"): - exec(code, {}, {}) + exec(code, {}) def test_typeparams_dunder_function_01(self): def outer[A, B](): @@ -396,4 +391,4 @@ def func[A](): ) with self.assertRaisesRegex(AttributeError, "attribute '__type_variables__' of 'function' objects is not writable"): - exec(code, {}, {}) + exec(code, {}) From f2d91b0bb6d6bcb0b5584cdefec6581cf0e716ef Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 21 Apr 2023 23:48:22 -0600 Subject: [PATCH 034/200] No runtime error there --- Lib/test/test_type_params.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 1e48e5d0ae19cf..15024dc95d1968 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -207,15 +207,11 @@ class ClassA[T](Generic[T]): ... exec(code, {}) def test_traditional_02(self): - code = textwrap.dedent("""\ - from typing import TypeVar - S = TypeVar("S") - class ClassA[T](dict[T, S]): ... - """ - ) - - with self.assertRaisesRegex(TypeError, r"Some type variables \(~S\) are not listed in Generic\[T\]"): - exec(code, {}) + # This does not generate a runtime error, but it should be + # flagged as an error by type checkers. + from typing import TypeVar + S = TypeVar("S") + class ClassA[T](dict[T, S]): ... def test_traditional_03(self): # This does not generate a runtime error, but it should be From ccf68d9dc6922318e6ca89159d24471f1bfab451 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 00:08:39 -0600 Subject: [PATCH 035/200] actually generate a typevar --- Include/internal/pycore_intrinsics.h | 5 ++++- Objects/typevarobject.c | 4 ++-- Python/compile.c | 17 ++++++++++------- Python/intrinsics.c | 25 +++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index 46a52740eb8a0c..cfd1c04ef76e9a 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -7,8 +7,11 @@ #define INTRINSIC_ASYNC_GEN_WRAP 4 #define INTRINSIC_UNARY_POSITIVE 5 #define INTRINSIC_LIST_TO_TUPLE 6 +#define INTRINSIC_TYPEVAR 7 +#define INTRINSIC_PARAMSPEC 8 +#define INTRINSIC_TYPEVARTUPLE 9 -#define MAX_INTRINSIC_1 6 +#define MAX_INTRINSIC_1 9 /* Binary Functions: */ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index b2d346cd1ec20b..d511f79c7dc38e 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -519,7 +519,7 @@ static paramspecobject *paramspecobject_alloc(const char *name, PyObject *bound, Py_DECREF(ps); return NULL; } - ps->bound = Py_NewRef(bound); + ps->bound = Py_XNewRef(bound); ps->covariant = covariant; ps->contravariant = contravariant; ps->autovariance = autovariance; @@ -797,7 +797,7 @@ PyTypeObject _PyTypeVarTuple_Type = { }; PyObject *_Py_make_typevar(const char *name, PyObject *bound_or_constraints) { - if (PyTuple_CheckExact(bound_or_constraints)) { + if (bound_or_constraints != NULL && PyTuple_CheckExact(bound_or_constraints)) { return (PyObject *)typevarobject_alloc(name, NULL, bound_or_constraints, false, false, true); } else { return (PyObject *)typevarobject_alloc(name, bound_or_constraints, NULL, false, false, true); diff --git a/Python/compile.c b/Python/compile.c index 6e7161508fd0e2..0024cf8be13128 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2128,19 +2128,22 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) for (Py_ssize_t i = 0; i < asdl_seq_LEN(typeparams); i++) { typeparam_ty typeparam = asdl_seq_GET(typeparams, i); + location loc = LOC(typeparam); switch(typeparam->kind) { case TypeVar_kind: - // TODO(PEP 695): Actually emit a TypeVar - ADDOP_LOAD_CONST(c, LOC(typeparam), typeparam->v.TypeVar.name); - compiler_nameop(c, LOC(typeparam), typeparam->v.TypeVar.name, Store); + ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVar.name); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVAR); + compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store); break; case TypeVarTuple_kind: - ADDOP_LOAD_CONST(c, LOC(typeparam), typeparam->v.TypeVarTuple.name); - compiler_nameop(c, LOC(typeparam), typeparam->v.TypeVarTuple.name, Store); + ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVarTuple.name); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVARTUPLE); + compiler_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store); break; case ParamSpec_kind: - ADDOP_LOAD_CONST(c, LOC(typeparam), typeparam->v.ParamSpec.name); - compiler_nameop(c, LOC(typeparam), typeparam->v.ParamSpec.name, Store); + ADDOP_LOAD_CONST(c, loc, typeparam->v.ParamSpec.name); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_PARAMSPEC); + compiler_nameop(c, loc, typeparam->v.ParamSpec.name, Store); break; } } diff --git a/Python/intrinsics.c b/Python/intrinsics.c index cca29d859902a4..a5a3e47d325d92 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -7,6 +7,7 @@ #include "pycore_global_objects.h" #include "pycore_intrinsics.h" #include "pycore_pyerrors.h" +#include "pycore_typevarobject.h" /******** Unary functions ********/ @@ -199,6 +200,27 @@ list_to_tuple(PyThreadState* unused, PyObject *v) return _PyTuple_FromArray(((PyListObject *)v)->ob_item, Py_SIZE(v)); } +static PyObject * +make_typevar(PyThreadState* unused, PyObject *v) +{ + assert(PyUnicode_Check(v)); + return _Py_make_typevar(PyUnicode_AsUTF8(v), NULL); +} + +static PyObject * +make_paramspec(PyThreadState* unused, PyObject *v) +{ + assert(PyUnicode_Check(v)); + return _Py_make_paramspec(PyUnicode_AsUTF8(v)); +} + +static PyObject * +make_typevartuple(PyThreadState* unused, PyObject *v) +{ + assert(PyUnicode_Check(v)); + return _Py_make_typevartuple(PyUnicode_AsUTF8(v)); +} + const instrinsic_func1 _PyIntrinsics_UnaryFunctions[] = { [0] = no_intrinsic, @@ -208,6 +230,9 @@ _PyIntrinsics_UnaryFunctions[] = { [INTRINSIC_ASYNC_GEN_WRAP] = _PyAsyncGenValueWrapperNew, [INTRINSIC_UNARY_POSITIVE] = unary_pos, [INTRINSIC_LIST_TO_TUPLE] = list_to_tuple, + [INTRINSIC_TYPEVAR] = make_typevar, + [INTRINSIC_PARAMSPEC] = make_paramspec, + [INTRINSIC_TYPEVARTUPLE] = make_typevartuple, }; From 6159d75c932e0c059c3347b2d16f3183c8e84209 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 07:01:04 -0600 Subject: [PATCH 036/200] refactor typeparam blocks --- Include/internal/pycore_symtable.h | 2 + Lib/test/test_type_params.py | 12 +++ Python/symtable.c | 123 ++++++++++++++++------------- 3 files changed, 82 insertions(+), 55 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index c6d61805b39b22..827c46a1d88b67 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -65,6 +65,8 @@ typedef struct _symtable_entry { closure over __class__ should be created */ unsigned ste_comp_iter_target : 1; /* true if visiting comprehension target */ + unsigned ste_type_params_in_class : 1; /* true if this is a type parameters block + inside a class */ int ste_comp_iter_expr; /* non-zero if visiting a comprehension range expression */ int ste_lineno; /* first line of block */ int ste_col_offset; /* offset of first line of block */ diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 15024dc95d1968..7302399369a00b 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -161,6 +161,18 @@ def func[A](): with self.assertRaisesRegex(NameError, "name 'A' is not defined"): exec(code, {}) + def test_method_access_01(self): + code = textwrap.dedent("""\ + class ClassA: + x = int + def func[T](self, a: x, b: T): + ... + + assert Class.func.__annotations__["a"] is int + """ + ) + exec(code, {}) + def test_nested_access_01(self): code = textwrap.dedent("""\ class ClassA[A]: diff --git a/Python/symtable.c b/Python/symtable.c index 7a57f48686b271..c69af8eb6d9fc6 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1123,6 +1123,56 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag, lineno, col_offset, end_lineno, end_col_offset); } +static int +symtable_add_param(const char *name, struct symtable *st, + int lineno, int col_offset, int end_lineno, int end_col_offset) +{ + PyObject *name_obj = PyUnicode_FromString(name); + if (name_obj == NULL) { + return 0; + } + if (!symtable_add_def(st, name_obj, DEF_PARAM, + lineno, col_offset, end_lineno, end_col_offset)) { + Py_DECREF(name_obj); + return 0; + } + Py_DECREF(name_obj); + return 1; +} + +static int +symtable_enter_typeparam_block(struct symtable *st, identifier name, + void *ast, int has_defaults, int has_kwdefaults, + int lineno, int col_offset, + int end_lineno, int end_col_offset) +{ + _Py_block_ty current_type = st->st_cur->ste_type; + if(!symtable_enter_block(st, name, FunctionBlock, ast, lineno, + col_offset, end_lineno, end_col_offset)) { + return 0; + } + if (current_type == ClassBlock) { + st->st_cur->ste_type_params_in_class = 1; + if (!symtable_add_param(".namespace", st, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + } + if (has_defaults) { + if (!symtable_add_param(".defaults", st, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + } + if (has_kwdefaults) { + if (!symtable_add_param(".kwdefaults", st, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + } + return 1; +} + /* VISIT, VISIT_SEQ and VIST_SEQ_TAIL take an ASDL type as their second argument. They use the ASDL name to synthesize the name of the C type and the visit function. @@ -1225,34 +1275,15 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); if (s->v.FunctionDef.typeparams) { - if (!symtable_enter_block(st, s->v.FunctionDef.name, - FunctionBlock, (void *)s->v.FunctionDef.typeparams, - LOCATION(s))) { + if (!symtable_enter_typeparam_block( + st, s->v.FunctionDef.name, + (void *)s->v.FunctionDef.typeparams, + s->v.FunctionDef.args->defaults != NULL, + has_kwonlydefaults(s->v.FunctionDef.args->kwonlyargs, + s->v.FunctionDef.args->kw_defaults), + LOCATION(s))) { VISIT_QUIT(st, 0); } - if (s->v.FunctionDef.args->defaults) { - PyObject *defaults_name = PyUnicode_FromString(".defaults"); - if (defaults_name == NULL) { - VISIT_QUIT(st, 0); - } - if (!symtable_add_def(st, defaults_name, DEF_PARAM, LOCATION(s))) { - Py_DECREF(defaults_name); - VISIT_QUIT(st, 0); - } - Py_DECREF(defaults_name); - } - if (has_kwonlydefaults(s->v.FunctionDef.args->kwonlyargs, - s->v.FunctionDef.args->kw_defaults)) { - PyObject *kwonly_name = PyUnicode_FromString(".kwonlydefaults"); - if (kwonly_name == NULL) { - VISIT_QUIT(st, 0); - } - if (!symtable_add_def(st, kwonly_name, DEF_PARAM, LOCATION(s))) { - Py_DECREF(kwonly_name); - VISIT_QUIT(st, 0); - } - Py_DECREF(kwonly_name); - } VISIT_SEQ(st, typeparam, s->v.FunctionDef.typeparams); } if (!symtable_visit_annotations(st, s, s->v.FunctionDef.args, @@ -1279,9 +1310,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.ClassDef.decorator_list) VISIT_SEQ(st, expr, s->v.ClassDef.decorator_list); if (s->v.ClassDef.typeparams) { - if (!symtable_enter_block(st, s->v.ClassDef.name, - FunctionBlock, (void *)s->v.ClassDef.typeparams, - LOCATION(s))) { + if (!symtable_enter_typeparam_block(st, s->v.ClassDef.name, + (void *)s->v.ClassDef.typeparams, + false, false, + LOCATION(s))) { VISIT_QUIT(st, 0); } VISIT_SEQ(st, typeparam, s->v.ClassDef.typeparams); @@ -1513,34 +1545,15 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.AsyncFunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.AsyncFunctionDef.decorator_list); if (s->v.AsyncFunctionDef.typeparams) { - if (!symtable_enter_block(st, s->v.AsyncFunctionDef.name, - FunctionBlock, (void *)s->v.AsyncFunctionDef.typeparams, - LOCATION(s))) { + if (!symtable_enter_typeparam_block( + st, s->v.AsyncFunctionDef.name, + (void *)s->v.AsyncFunctionDef.typeparams, + s->v.AsyncFunctionDef.args->defaults != NULL, + has_kwonlydefaults(s->v.AsyncFunctionDef.args->kwonlyargs, + s->v.AsyncFunctionDef.args->kw_defaults), + LOCATION(s))) { VISIT_QUIT(st, 0); } - if (s->v.AsyncFunctionDef.args->defaults) { - PyObject *defaults_name = PyUnicode_FromString(".defaults"); - if (defaults_name == NULL) { - VISIT_QUIT(st, 0); - } - if (!symtable_add_def(st, defaults_name, DEF_PARAM, LOCATION(s))) { - Py_DECREF(defaults_name); - VISIT_QUIT(st, 0); - } - Py_DECREF(defaults_name); - } - if (has_kwonlydefaults(s->v.AsyncFunctionDef.args->kwonlyargs, - s->v.AsyncFunctionDef.args->kw_defaults)) { - PyObject *kwonly_name = PyUnicode_FromString(".kwonlydefaults"); - if (kwonly_name == NULL) { - VISIT_QUIT(st, 0); - } - if (!symtable_add_def(st, kwonly_name, DEF_PARAM, LOCATION(s))) { - Py_DECREF(kwonly_name); - VISIT_QUIT(st, 0); - } - Py_DECREF(kwonly_name); - } VISIT_SEQ(st, typeparam, s->v.AsyncFunctionDef.typeparams); } if (!symtable_visit_annotations(st, s, s->v.AsyncFunctionDef.args, From d9c0d907b625475d118b12446860f96b6d9c953d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 09:31:37 -0600 Subject: [PATCH 037/200] Fix nested class scopes (functions) --- Include/internal/pycore_opcode.h | 28 +- Include/opcode.h | 25 +- Lib/opcode.py | 4 + Python/bytecodes.c | 77 ++- Python/compile.c | 48 +- Python/generated_cases.c.h | 908 +++++++++++++++++-------------- Python/opcode_metadata.h | 15 + Python/opcode_targets.h | 22 +- 8 files changed, 669 insertions(+), 458 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index 81ca91465950b7..ed5aabdb8e6a41 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -162,6 +162,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, [LOAD_CLASSDEREF] = LOAD_CLASSDEREF, + [LOAD_CLASS_OR_GLOBAL] = LOAD_CLASS_OR_GLOBAL, [LOAD_CLOSURE] = LOAD_CLOSURE, [LOAD_CONST] = LOAD_CONST, [LOAD_CONST__LOAD_FAST] = LOAD_CONST, @@ -173,6 +174,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_GLOBAL] = LOAD_GLOBAL, [LOAD_GLOBAL_BUILTIN] = LOAD_GLOBAL, [LOAD_GLOBAL_MODULE] = LOAD_GLOBAL, + [LOAD_LOCALS] = LOAD_LOCALS, [LOAD_NAME] = LOAD_NAME, [MAKE_CELL] = MAKE_CELL, [MAKE_FUNCTION] = MAKE_FUNCTION, @@ -187,6 +189,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [POP_JUMP_IF_NONE] = POP_JUMP_IF_NONE, [POP_JUMP_IF_NOT_NONE] = POP_JUMP_IF_NOT_NONE, [POP_JUMP_IF_TRUE] = POP_JUMP_IF_TRUE, + [POP_NULL] = POP_NULL, [POP_TOP] = POP_TOP, [PUSH_EXC_INFO] = PUSH_EXC_INFO, [PUSH_NULL] = PUSH_NULL, @@ -317,9 +320,9 @@ static const char *const _PyOpcode_OpName[263] = { [RETURN_VALUE] = "RETURN_VALUE", [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", [SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS", + [POP_NULL] = "POP_NULL", + [LOAD_LOCALS] = "LOAD_LOCALS", [STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE", - [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", - [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", [POP_EXCEPT] = "POP_EXCEPT", [STORE_NAME] = "STORE_NAME", [DELETE_NAME] = "DELETE_NAME", @@ -342,9 +345,9 @@ static const char *const _PyOpcode_OpName[263] = { [IMPORT_NAME] = "IMPORT_NAME", [IMPORT_FROM] = "IMPORT_FROM", [JUMP_FORWARD] = "JUMP_FORWARD", + [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", + [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", - [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", - [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE", [POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE", [LOAD_GLOBAL] = "LOAD_GLOBAL", @@ -372,9 +375,9 @@ static const char *const _PyOpcode_OpName[263] = { [STORE_DEREF] = "STORE_DEREF", [DELETE_DEREF] = "DELETE_DEREF", [JUMP_BACKWARD] = "JUMP_BACKWARD", - [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", + [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", - [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", + [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [EXTENDED_ARG] = "EXTENDED_ARG", [LIST_APPEND] = "LIST_APPEND", [SET_ADD] = "SET_ADD", @@ -384,14 +387,14 @@ static const char *const _PyOpcode_OpName[263] = { [YIELD_VALUE] = "YIELD_VALUE", [RESUME] = "RESUME", [MATCH_CLASS] = "MATCH_CLASS", - [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", - [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", + [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", + [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [FORMAT_VALUE] = "FORMAT_VALUE", [BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP", [BUILD_STRING] = "BUILD_STRING", + [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", + [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [SEND_GEN] = "SEND_GEN", - [159] = "<159>", - [160] = "<160>", [161] = "<161>", [LIST_EXTEND] = "LIST_EXTEND", [SET_UPDATE] = "SET_UPDATE", @@ -406,7 +409,7 @@ static const char *const _PyOpcode_OpName[263] = { [KW_NAMES] = "KW_NAMES", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", - [175] = "<175>", + [LOAD_CLASS_OR_GLOBAL] = "LOAD_CLASS_OR_GLOBAL", [176] = "<176>", [177] = "<177>", [178] = "<178>", @@ -498,15 +501,12 @@ static const char *const _PyOpcode_OpName[263] = { #endif #define EXTRA_CASES \ - case 159: \ - case 160: \ case 161: \ case 166: \ case 167: \ case 168: \ case 169: \ case 170: \ - case 175: \ case 176: \ case 177: \ case 178: \ diff --git a/Include/opcode.h b/Include/opcode.h index 0ff84dc5a551a0..3315a40a3c31ed 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -43,6 +43,8 @@ extern "C" { #define RETURN_GENERATOR 75 #define RETURN_VALUE 83 #define SETUP_ANNOTATIONS 85 +#define POP_NULL 86 +#define LOAD_LOCALS 87 #define POP_EXCEPT 89 #define HAVE_ARGUMENT 90 #define STORE_NAME 90 @@ -114,6 +116,7 @@ extern "C" { #define KW_NAMES 172 #define CALL_INTRINSIC_1 173 #define CALL_INTRINSIC_2 174 +#define LOAD_CLASS_OR_GLOBAL 175 #define MIN_PSEUDO_OPCODE 256 #define SETUP_FINALLY 256 #define SETUP_CLEANUP 257 @@ -174,17 +177,17 @@ extern "C" { #define LOAD_FAST__LOAD_FAST 81 #define LOAD_GLOBAL_BUILTIN 82 #define LOAD_GLOBAL_MODULE 84 -#define STORE_ATTR_INSTANCE_VALUE 86 -#define STORE_ATTR_SLOT 87 -#define STORE_ATTR_WITH_HINT 88 -#define STORE_FAST__LOAD_FAST 111 -#define STORE_FAST__STORE_FAST 112 -#define STORE_SUBSCR_DICT 113 -#define STORE_SUBSCR_LIST_INT 141 -#define UNPACK_SEQUENCE_LIST 143 -#define UNPACK_SEQUENCE_TUPLE 153 -#define UNPACK_SEQUENCE_TWO_TUPLE 154 -#define SEND_GEN 158 +#define STORE_ATTR_INSTANCE_VALUE 88 +#define STORE_ATTR_SLOT 111 +#define STORE_ATTR_WITH_HINT 112 +#define STORE_FAST__LOAD_FAST 113 +#define STORE_FAST__STORE_FAST 141 +#define STORE_SUBSCR_DICT 143 +#define STORE_SUBSCR_LIST_INT 153 +#define UNPACK_SEQUENCE_LIST 154 +#define UNPACK_SEQUENCE_TUPLE 158 +#define UNPACK_SEQUENCE_TWO_TUPLE 159 +#define SEND_GEN 160 #define DO_TRACING 255 #define HAS_ARG(op) ((((op) >= HAVE_ARGUMENT) && (!IS_PSEUDO_OPCODE(op)))\ diff --git a/Lib/opcode.py b/Lib/opcode.py index b62dfa1bcb42c5..49da1c8373a33a 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -126,6 +126,8 @@ def pseudo_op(name, op, real_ops): def_op('RETURN_VALUE', 83) def_op('SETUP_ANNOTATIONS', 85) +def_op('POP_NULL', 86) +def_op('LOAD_LOCALS', 87) def_op('POP_EXCEPT', 89) @@ -221,6 +223,8 @@ def pseudo_op(name, op, real_ops): def_op('CALL_INTRINSIC_1', 173) def_op('CALL_INTRINSIC_2', 174) +name_op('LOAD_CLASS_OR_GLOBAL', 175) + hasarg.extend([op for op in opmap.values() if op >= HAVE_ARGUMENT]) MIN_PSEUDO_OPCODE = 256 diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 72f85cc92b0c92..070d13607f3604 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -54,7 +54,7 @@ static PyObject *value, *value1, *value2, *left, *right, *res, *sum, *prod, *sub static PyObject *container, *start, *stop, *v, *lhs, *rhs, *res2; static PyObject *list, *tuple, *dict, *owner, *set, *str, *tup, *map, *keys; static PyObject *exit_func, *lasti, *val, *retval, *obj, *iter; -static PyObject *aiter, *awaitable, *iterable, *w, *exc_value, *bc; +static PyObject *aiter, *awaitable, *iterable, *w, *exc_value, *bc, *locals; static PyObject *orig, *excs, *update, *b, *fromlist, *level, *from; static PyObject **pieces, **values; static size_t jump; @@ -181,6 +181,10 @@ dummy_func( res = NULL; } + inst(POP_NULL, (value --)) { + assert(value == NULL); + } + macro(END_FOR) = POP_TOP + POP_TOP; inst(UNARY_NEGATIVE, (value -- res)) { @@ -882,6 +886,16 @@ dummy_func( } } + inst(LOAD_LOCALS, ( -- locals)) { + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found when loading locals()"); + ERROR_IF(true, error); + } + Py_INCREF(locals); + } + inst(STORE_NAME, (v -- )) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); @@ -1040,6 +1054,67 @@ dummy_func( } } + inst(LOAD_CLASS_OR_GLOBAL, (-- v)) { + PyObject *name = GETITEM(frame->f_code->co_names, oparg); + PyObject *locals = GETLOCAL(0); + if (locals == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no locals when loading %R", name); + goto error; + } + if (PyDict_CheckExact(locals)) { + v = PyDict_GetItemWithError(locals, name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + } + else { + v = PyObject_GetItem(locals, name); + if (v == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + goto error; + _PyErr_Clear(tstate); + } + } + if (v == NULL) { + v = PyDict_GetItemWithError(GLOBALS(), name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + else { + if (PyDict_CheckExact(BUILTINS())) { + v = PyDict_GetItemWithError(BUILTINS(), name); + if (v == NULL) { + if (!_PyErr_Occurred(tstate)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + Py_INCREF(v); + } + else { + v = PyObject_GetItem(BUILTINS(), name); + if (v == NULL) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + } + } + } + } + inst(LOAD_NAME, ( -- v)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = LOCALS(); diff --git a/Python/compile.c b/Python/compile.c index 0024cf8be13128..f3ddf4f2d3a9af 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2200,8 +2200,21 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) location loc = LOC(s); + int is_typeparams_in_class = 0; + if (typeparams) { ADDOP(c, loc, PUSH_NULL); + // We'll swap in the callable here later. + ADDOP(c, loc, PUSH_NULL); + PySTEntryObject *ste = PySymtable_Lookup(c->c_st, (void *)typeparams); + if (ste == NULL) { + return ERROR; + } + is_typeparams_in_class = ste->ste_type_params_in_class; + if (is_typeparams_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + } + Py_DECREF(ste); } funcflags = compiler_default_arguments(c, loc, args); @@ -2209,6 +2222,8 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } + int num_typeparam_args = 0; + if (typeparams) { PyObject *typeparams_name = PyUnicode_FromFormat("", name); if (!typeparams_name) { @@ -2220,11 +2235,16 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(typeparams_name); + if (is_typeparams_in_class) { + num_typeparam_args += 1; + } if ((funcflags & 0x01) || (funcflags & 0x02)) { - ADDOP_I(c, loc, LOAD_FAST, 0); + ADDOP_I(c, loc, LOAD_FAST, 0 + is_typeparams_in_class); + num_typeparam_args += 1; } if ((funcflags & 0x01) && (funcflags & 0x02)) { - ADDOP_I(c, loc, LOAD_FAST, 1); + ADDOP_I(c, loc, LOAD_FAST, 1 + is_typeparams_in_class); + num_typeparam_args += 1; } RETURN_IF_ERROR(compiler_type_params(c, typeparams)); } @@ -2271,6 +2291,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } Py_DECREF(co); if (typeparams) { + if (is_typeparams_in_class) { + c->u->u_argcount += 1; + } if (funcflags & 0x02) { c->u->u_argcount += 1; } @@ -2287,16 +2310,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); - int oparg = 0; - if ((funcflags & 0x01) && (funcflags & 0x02)) { - ADDOP_I(c, loc, SWAP, 3); - oparg = 2; - } - else if ((funcflags & 0x01) || (funcflags & 0x02)) { - ADDOP_I(c, loc, SWAP, 2); - oparg = 1; - } - ADDOP_I(c, loc, CALL, oparg); + ADDOP_I(c, loc, SWAP, num_typeparam_args + 2); + ADDOP(c, loc, POP_NULL); + ADDOP_I(c, loc, CALL, num_typeparam_args); } RETURN_IF_ERROR(compiler_apply_decorators(c, decos)); @@ -3903,7 +3919,13 @@ compiler_nameop(struct compiler *c, location loc, return SUCCESS; case OP_GLOBAL: switch (ctx) { - case Load: op = LOAD_GLOBAL; break; + case Load: + if (c->u->u_ste->ste_type_params_in_class) { + op = LOAD_CLASS_OR_GLOBAL; + } else { + op = LOAD_GLOBAL; + } + break; case Store: op = STORE_GLOBAL; break; case Del: op = DELETE_GLOBAL; break; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 420d136bb98158..bfec53c8c27d8d 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -219,19 +219,28 @@ DISPATCH(); } + TARGET(POP_NULL) { + PyObject *value = stack_pointer[-1]; + #line 185 "Python/bytecodes.c" + assert(value == NULL); + #line 227 "Python/generated_cases.c.h" + STACK_SHRINK(1); + DISPATCH(); + } + TARGET(END_FOR) { PyObject *_tmp_1 = stack_pointer[-1]; PyObject *_tmp_2 = stack_pointer[-2]; { PyObject *value = _tmp_1; #line 177 "Python/bytecodes.c" - #line 229 "Python/generated_cases.c.h" + #line 238 "Python/generated_cases.c.h" Py_DECREF(value); } { PyObject *value = _tmp_2; #line 177 "Python/bytecodes.c" - #line 235 "Python/generated_cases.c.h" + #line 244 "Python/generated_cases.c.h" Py_DECREF(value); } STACK_SHRINK(2); @@ -241,13 +250,13 @@ TARGET(UNARY_NEGATIVE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 187 "Python/bytecodes.c" + #line 191 "Python/bytecodes.c" res = PyNumber_Negative(value); - #line 247 "Python/generated_cases.c.h" + #line 256 "Python/generated_cases.c.h" Py_DECREF(value); - #line 189 "Python/bytecodes.c" + #line 193 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; - #line 251 "Python/generated_cases.c.h" + #line 260 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -255,11 +264,11 @@ TARGET(UNARY_NOT) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 193 "Python/bytecodes.c" + #line 197 "Python/bytecodes.c" int err = PyObject_IsTrue(value); - #line 261 "Python/generated_cases.c.h" + #line 270 "Python/generated_cases.c.h" Py_DECREF(value); - #line 195 "Python/bytecodes.c" + #line 199 "Python/bytecodes.c" if (err < 0) goto pop_1_error; if (err == 0) { res = Py_True; @@ -268,7 +277,7 @@ res = Py_False; } Py_INCREF(res); - #line 272 "Python/generated_cases.c.h" + #line 281 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -276,13 +285,13 @@ TARGET(UNARY_INVERT) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 206 "Python/bytecodes.c" + #line 210 "Python/bytecodes.c" res = PyNumber_Invert(value); - #line 282 "Python/generated_cases.c.h" + #line 291 "Python/generated_cases.c.h" Py_DECREF(value); - #line 208 "Python/bytecodes.c" + #line 212 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; - #line 286 "Python/generated_cases.c.h" + #line 295 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -291,7 +300,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; - #line 225 "Python/bytecodes.c" + #line 229 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); @@ -300,7 +309,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (prod == NULL) goto pop_2_error; - #line 304 "Python/generated_cases.c.h" + #line 313 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = prod; next_instr += 1; @@ -311,7 +320,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; - #line 236 "Python/bytecodes.c" + #line 240 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); @@ -319,7 +328,7 @@ double dprod = ((PyFloatObject *)left)->ob_fval * ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dprod, prod); - #line 323 "Python/generated_cases.c.h" + #line 332 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = prod; next_instr += 1; @@ -330,7 +339,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; - #line 246 "Python/bytecodes.c" + #line 250 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); @@ -339,7 +348,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (sub == NULL) goto pop_2_error; - #line 343 "Python/generated_cases.c.h" + #line 352 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sub; next_instr += 1; @@ -350,14 +359,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; - #line 257 "Python/bytecodes.c" + #line 261 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); double dsub = ((PyFloatObject *)left)->ob_fval - ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsub, sub); - #line 361 "Python/generated_cases.c.h" + #line 370 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sub; next_instr += 1; @@ -368,7 +377,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 266 "Python/bytecodes.c" + #line 270 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -377,7 +386,7 @@ _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc); _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc); if (res == NULL) goto pop_2_error; - #line 381 "Python/generated_cases.c.h" + #line 390 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -387,7 +396,7 @@ TARGET(BINARY_OP_INPLACE_ADD_UNICODE) { PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; - #line 283 "Python/bytecodes.c" + #line 287 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -415,7 +424,7 @@ if (*target_local == NULL) goto pop_2_error; // The STORE_FAST is already done. JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1); - #line 419 "Python/generated_cases.c.h" + #line 428 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -424,7 +433,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; - #line 313 "Python/bytecodes.c" + #line 317 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -432,7 +441,7 @@ double dsum = ((PyFloatObject *)left)->ob_fval + ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsum, sum); - #line 436 "Python/generated_cases.c.h" + #line 445 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sum; next_instr += 1; @@ -443,7 +452,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; - #line 323 "Python/bytecodes.c" + #line 327 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -452,7 +461,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (sum == NULL) goto pop_2_error; - #line 456 "Python/generated_cases.c.h" + #line 465 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sum; next_instr += 1; @@ -465,7 +474,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; PyObject *res; - #line 342 "Python/bytecodes.c" + #line 346 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -478,12 +487,12 @@ DECREMENT_ADAPTIVE_COUNTER(cache->counter); #endif /* ENABLE_SPECIALIZATION */ res = PyObject_GetItem(container, sub); - #line 482 "Python/generated_cases.c.h" + #line 491 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); - #line 355 "Python/bytecodes.c" + #line 359 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 487 "Python/generated_cases.c.h" + #line 496 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -495,7 +504,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *res; - #line 359 "Python/bytecodes.c" + #line 363 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); // Can't use ERROR_IF() here, because we haven't // DECREF'ed container yet, and we still own slice. @@ -508,7 +517,7 @@ } Py_DECREF(container); if (res == NULL) goto pop_3_error; - #line 512 "Python/generated_cases.c.h" + #line 521 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = res; DISPATCH(); @@ -519,7 +528,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *v = stack_pointer[-4]; - #line 374 "Python/bytecodes.c" + #line 378 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); int err; if (slice == NULL) { @@ -532,7 +541,7 @@ Py_DECREF(v); Py_DECREF(container); if (err) goto pop_4_error; - #line 536 "Python/generated_cases.c.h" + #line 545 "Python/generated_cases.c.h" STACK_SHRINK(4); DISPATCH(); } @@ -541,7 +550,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *res; - #line 389 "Python/bytecodes.c" + #line 393 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR); @@ -556,7 +565,7 @@ Py_INCREF(res); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(list); - #line 560 "Python/generated_cases.c.h" + #line 569 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -567,7 +576,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *tuple = stack_pointer[-2]; PyObject *res; - #line 406 "Python/bytecodes.c" + #line 410 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR); @@ -582,7 +591,7 @@ Py_INCREF(res); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(tuple); - #line 586 "Python/generated_cases.c.h" + #line 595 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -593,7 +602,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *res; - #line 423 "Python/bytecodes.c" + #line 427 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR); STAT_INC(BINARY_SUBSCR, hit); @@ -602,14 +611,14 @@ if (!_PyErr_Occurred(tstate)) { _PyErr_SetKeyError(sub); } - #line 606 "Python/generated_cases.c.h" + #line 615 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); - #line 432 "Python/bytecodes.c" + #line 436 "Python/bytecodes.c" if (true) goto pop_2_error; } Py_INCREF(res); // Do this before DECREF'ing dict, sub - #line 613 "Python/generated_cases.c.h" + #line 622 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); STACK_SHRINK(1); @@ -621,7 +630,7 @@ TARGET(BINARY_SUBSCR_GETITEM) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; - #line 439 "Python/bytecodes.c" + #line 443 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(container); DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR); PyHeapTypeObject *ht = (PyHeapTypeObject *)tp; @@ -642,15 +651,15 @@ new_frame->localsplus[1] = sub; JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR); DISPATCH_INLINED(new_frame); - #line 646 "Python/generated_cases.c.h" + #line 655 "Python/generated_cases.c.h" } TARGET(LIST_APPEND) { PyObject *v = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 462 "Python/bytecodes.c" + #line 466 "Python/bytecodes.c" if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error; - #line 654 "Python/generated_cases.c.h" + #line 663 "Python/generated_cases.c.h" STACK_SHRINK(1); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -659,13 +668,13 @@ TARGET(SET_ADD) { PyObject *v = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 467 "Python/bytecodes.c" + #line 471 "Python/bytecodes.c" int err = PySet_Add(set, v); - #line 665 "Python/generated_cases.c.h" + #line 674 "Python/generated_cases.c.h" Py_DECREF(v); - #line 469 "Python/bytecodes.c" + #line 473 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 669 "Python/generated_cases.c.h" + #line 678 "Python/generated_cases.c.h" STACK_SHRINK(1); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -678,7 +687,7 @@ PyObject *container = stack_pointer[-2]; PyObject *v = stack_pointer[-3]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 480 "Python/bytecodes.c" + #line 484 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { assert(cframe.use_tracing == 0); @@ -694,13 +703,13 @@ #endif /* ENABLE_SPECIALIZATION */ /* container[sub] = v */ int err = PyObject_SetItem(container, sub, v); - #line 698 "Python/generated_cases.c.h" + #line 707 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(container); Py_DECREF(sub); - #line 496 "Python/bytecodes.c" + #line 500 "Python/bytecodes.c" if (err) goto pop_3_error; - #line 704 "Python/generated_cases.c.h" + #line 713 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -710,7 +719,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; - #line 500 "Python/bytecodes.c" + #line 504 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR); @@ -728,7 +737,7 @@ Py_DECREF(old_value); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(list); - #line 732 "Python/generated_cases.c.h" + #line 741 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -738,14 +747,14 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; - #line 520 "Python/bytecodes.c" + #line 524 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR); STAT_INC(STORE_SUBSCR, hit); int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value); Py_DECREF(dict); if (err) goto pop_3_error; - #line 749 "Python/generated_cases.c.h" + #line 758 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -754,15 +763,15 @@ TARGET(DELETE_SUBSCR) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; - #line 529 "Python/bytecodes.c" + #line 533 "Python/bytecodes.c" /* del container[sub] */ int err = PyObject_DelItem(container, sub); - #line 761 "Python/generated_cases.c.h" + #line 770 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); - #line 532 "Python/bytecodes.c" + #line 536 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 766 "Python/generated_cases.c.h" + #line 775 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -770,14 +779,14 @@ TARGET(CALL_INTRINSIC_1) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 536 "Python/bytecodes.c" + #line 540 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_1); res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value); - #line 777 "Python/generated_cases.c.h" + #line 786 "Python/generated_cases.c.h" Py_DECREF(value); - #line 539 "Python/bytecodes.c" + #line 543 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; - #line 781 "Python/generated_cases.c.h" + #line 790 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -786,15 +795,15 @@ PyObject *value1 = stack_pointer[-1]; PyObject *value2 = stack_pointer[-2]; PyObject *res; - #line 543 "Python/bytecodes.c" + #line 547 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_2); res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1); - #line 793 "Python/generated_cases.c.h" + #line 802 "Python/generated_cases.c.h" Py_DECREF(value2); Py_DECREF(value1); - #line 546 "Python/bytecodes.c" + #line 550 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 798 "Python/generated_cases.c.h" + #line 807 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -802,7 +811,7 @@ TARGET(RAISE_VARARGS) { PyObject **args = (stack_pointer - oparg); - #line 550 "Python/bytecodes.c" + #line 554 "Python/bytecodes.c" PyObject *cause = NULL, *exc = NULL; switch (oparg) { case 2: @@ -820,12 +829,12 @@ break; } if (true) { STACK_SHRINK(oparg); goto error; } - #line 824 "Python/generated_cases.c.h" + #line 833 "Python/generated_cases.c.h" } TARGET(INTERPRETER_EXIT) { PyObject *retval = stack_pointer[-1]; - #line 570 "Python/bytecodes.c" + #line 574 "Python/bytecodes.c" assert(frame == &entry_frame); assert(_PyFrame_IsIncomplete(frame)); STACK_SHRINK(1); // Since we're not going to DISPATCH() @@ -837,12 +846,12 @@ assert(!_PyErr_Occurred(tstate)); _Py_LeaveRecursiveCallTstate(tstate); return retval; - #line 841 "Python/generated_cases.c.h" + #line 850 "Python/generated_cases.c.h" } TARGET(RETURN_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 584 "Python/bytecodes.c" + #line 588 "Python/bytecodes.c" STACK_SHRINK(1); assert(EMPTY()); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -856,11 +865,11 @@ _PyEvalFrameClearAndPop(tstate, dying); _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 860 "Python/generated_cases.c.h" + #line 869 "Python/generated_cases.c.h" } TARGET(RETURN_CONST) { - #line 600 "Python/bytecodes.c" + #line 604 "Python/bytecodes.c" PyObject *retval = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(retval); assert(EMPTY()); @@ -875,13 +884,13 @@ _PyEvalFrameClearAndPop(tstate, dying); _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 879 "Python/generated_cases.c.h" + #line 888 "Python/generated_cases.c.h" } TARGET(GET_AITER) { PyObject *obj = stack_pointer[-1]; PyObject *iter; - #line 617 "Python/bytecodes.c" + #line 621 "Python/bytecodes.c" unaryfunc getter = NULL; PyTypeObject *type = Py_TYPE(obj); @@ -894,16 +903,16 @@ "'async for' requires an object with " "__aiter__ method, got %.100s", type->tp_name); - #line 898 "Python/generated_cases.c.h" + #line 907 "Python/generated_cases.c.h" Py_DECREF(obj); - #line 630 "Python/bytecodes.c" + #line 634 "Python/bytecodes.c" if (true) goto pop_1_error; } iter = (*getter)(obj); - #line 905 "Python/generated_cases.c.h" + #line 914 "Python/generated_cases.c.h" Py_DECREF(obj); - #line 635 "Python/bytecodes.c" + #line 639 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; if (Py_TYPE(iter)->tp_as_async == NULL || @@ -916,7 +925,7 @@ Py_DECREF(iter); if (true) goto pop_1_error; } - #line 920 "Python/generated_cases.c.h" + #line 929 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -924,7 +933,7 @@ TARGET(GET_ANEXT) { PyObject *aiter = stack_pointer[-1]; PyObject *awaitable; - #line 650 "Python/bytecodes.c" + #line 654 "Python/bytecodes.c" unaryfunc getter = NULL; PyObject *next_iter = NULL; PyTypeObject *type = Py_TYPE(aiter); @@ -968,7 +977,7 @@ } } - #line 972 "Python/generated_cases.c.h" + #line 981 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = awaitable; PREDICT(LOAD_CONST); @@ -979,16 +988,16 @@ PREDICTED(GET_AWAITABLE); PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 697 "Python/bytecodes.c" + #line 701 "Python/bytecodes.c" iter = _PyCoro_GetAwaitableIter(iterable); if (iter == NULL) { format_awaitable_error(tstate, Py_TYPE(iterable), oparg); } - #line 990 "Python/generated_cases.c.h" + #line 999 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 704 "Python/bytecodes.c" + #line 708 "Python/bytecodes.c" if (iter != NULL && PyCoro_CheckExact(iter)) { PyObject *yf = _PyGen_yf((PyGenObject*)iter); @@ -1006,7 +1015,7 @@ if (iter == NULL) goto pop_1_error; - #line 1010 "Python/generated_cases.c.h" + #line 1019 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -1017,7 +1026,7 @@ PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; PyObject *retval; - #line 730 "Python/bytecodes.c" + #line 734 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PySendCache *cache = (_PySendCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1053,7 +1062,7 @@ assert(retval != NULL); } Py_DECREF(v); - #line 1057 "Python/generated_cases.c.h" + #line 1066 "Python/generated_cases.c.h" stack_pointer[-1] = retval; next_instr += 1; DISPATCH(); @@ -1062,7 +1071,7 @@ TARGET(SEND_GEN) { PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; - #line 768 "Python/bytecodes.c" + #line 772 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyGenObject *gen = (PyGenObject *)receiver; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type && @@ -1078,12 +1087,12 @@ tstate->exc_info = &gen->gi_exc_state; JUMPBY(INLINE_CACHE_ENTRIES_SEND + oparg); DISPATCH_INLINED(gen_frame); - #line 1082 "Python/generated_cases.c.h" + #line 1091 "Python/generated_cases.c.h" } TARGET(YIELD_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 786 "Python/bytecodes.c" + #line 790 "Python/bytecodes.c" // NOTE: It's important that YIELD_VALUE never raises an exception! // The compiler treats any exception raised here as a failed close() // or throw() call. @@ -1102,15 +1111,15 @@ frame->prev_instr -= frame->yield_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 1106 "Python/generated_cases.c.h" + #line 1115 "Python/generated_cases.c.h" } TARGET(POP_EXCEPT) { PyObject *exc_value = stack_pointer[-1]; - #line 807 "Python/bytecodes.c" + #line 811 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; Py_XSETREF(exc_info->exc_value, exc_value); - #line 1114 "Python/generated_cases.c.h" + #line 1123 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -1118,7 +1127,7 @@ TARGET(RERAISE) { PyObject *exc = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); - #line 812 "Python/bytecodes.c" + #line 816 "Python/bytecodes.c" assert(oparg >= 0 && oparg <= 2); if (oparg) { PyObject *lasti = values[0]; @@ -1136,26 +1145,26 @@ Py_INCREF(exc); _PyErr_SetRaisedException(tstate, exc); goto exception_unwind; - #line 1140 "Python/generated_cases.c.h" + #line 1149 "Python/generated_cases.c.h" } TARGET(END_ASYNC_FOR) { PyObject *exc = stack_pointer[-1]; PyObject *awaitable = stack_pointer[-2]; - #line 832 "Python/bytecodes.c" + #line 836 "Python/bytecodes.c" assert(exc && PyExceptionInstance_Check(exc)); if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) { - #line 1149 "Python/generated_cases.c.h" + #line 1158 "Python/generated_cases.c.h" Py_DECREF(awaitable); Py_DECREF(exc); - #line 835 "Python/bytecodes.c" + #line 839 "Python/bytecodes.c" } else { Py_INCREF(exc); _PyErr_SetRaisedException(tstate, exc); goto exception_unwind; } - #line 1159 "Python/generated_cases.c.h" + #line 1168 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -1166,23 +1175,23 @@ PyObject *sub_iter = stack_pointer[-3]; PyObject *none; PyObject *value; - #line 844 "Python/bytecodes.c" + #line 848 "Python/bytecodes.c" assert(throwflag); assert(exc_value && PyExceptionInstance_Check(exc_value)); if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) { value = Py_NewRef(((PyStopIterationObject *)exc_value)->value); - #line 1175 "Python/generated_cases.c.h" + #line 1184 "Python/generated_cases.c.h" Py_DECREF(sub_iter); Py_DECREF(last_sent_val); Py_DECREF(exc_value); - #line 849 "Python/bytecodes.c" + #line 853 "Python/bytecodes.c" none = Py_NewRef(Py_None); } else { _PyErr_SetRaisedException(tstate, Py_NewRef(exc_value)); goto exception_unwind; } - #line 1186 "Python/generated_cases.c.h" + #line 1195 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; stack_pointer[-2] = none; @@ -1191,9 +1200,9 @@ TARGET(LOAD_ASSERTION_ERROR) { PyObject *value; - #line 858 "Python/bytecodes.c" + #line 862 "Python/bytecodes.c" value = Py_NewRef(PyExc_AssertionError); - #line 1197 "Python/generated_cases.c.h" + #line 1206 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1201,7 +1210,7 @@ TARGET(LOAD_BUILD_CLASS) { PyObject *bc; - #line 862 "Python/bytecodes.c" + #line 866 "Python/bytecodes.c" if (PyDict_CheckExact(BUILTINS())) { bc = _PyDict_GetItemWithError(BUILTINS(), &_Py_ID(__build_class__)); @@ -1223,41 +1232,57 @@ if (true) goto error; } } - #line 1227 "Python/generated_cases.c.h" + #line 1236 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = bc; DISPATCH(); } + TARGET(LOAD_LOCALS) { + PyObject *locals; + #line 890 "Python/bytecodes.c" + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found when loading locals()"); + if (true) goto error; + } + Py_INCREF(locals); + #line 1252 "Python/generated_cases.c.h" + STACK_GROW(1); + stack_pointer[-1] = locals; + DISPATCH(); + } + TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 886 "Python/bytecodes.c" + #line 900 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); - #line 1242 "Python/generated_cases.c.h" + #line 1267 "Python/generated_cases.c.h" Py_DECREF(v); - #line 893 "Python/bytecodes.c" + #line 907 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); - #line 1251 "Python/generated_cases.c.h" + #line 1276 "Python/generated_cases.c.h" Py_DECREF(v); - #line 900 "Python/bytecodes.c" + #line 914 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1255 "Python/generated_cases.c.h" + #line 1280 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { - #line 904 "Python/bytecodes.c" + #line 918 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1274,7 +1299,7 @@ name); goto error; } - #line 1278 "Python/generated_cases.c.h" + #line 1303 "Python/generated_cases.c.h" DISPATCH(); } @@ -1282,7 +1307,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 930 "Python/bytecodes.c" + #line 944 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1296,11 +1321,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); - #line 1300 "Python/generated_cases.c.h" + #line 1325 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 944 "Python/bytecodes.c" + #line 958 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1304 "Python/generated_cases.c.h" + #line 1329 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1310,14 +1335,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 948 "Python/bytecodes.c" + #line 962 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); - #line 1321 "Python/generated_cases.c.h" + #line 1346 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1328,7 +1353,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 958 "Python/bytecodes.c" + #line 972 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1336,7 +1361,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1340 "Python/generated_cases.c.h" + #line 1365 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1347,7 +1372,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 969 "Python/bytecodes.c" + #line 983 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1355,7 +1380,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1359 "Python/generated_cases.c.h" + #line 1384 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1365,15 +1390,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 980 "Python/bytecodes.c" + #line 994 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); - #line 1373 "Python/generated_cases.c.h" + #line 1398 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 984 "Python/bytecodes.c" + #line 998 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1377 "Python/generated_cases.c.h" + #line 1402 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1384,7 +1409,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 995 "Python/bytecodes.c" + #line 1009 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { assert(cframe.use_tracing == 0); @@ -1401,12 +1426,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); - #line 1405 "Python/generated_cases.c.h" + #line 1430 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1012 "Python/bytecodes.c" + #line 1026 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 1410 "Python/generated_cases.c.h" + #line 1435 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1414,34 +1439,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1016 "Python/bytecodes.c" + #line 1030 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); - #line 1421 "Python/generated_cases.c.h" + #line 1446 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1019 "Python/bytecodes.c" + #line 1033 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1425 "Python/generated_cases.c.h" + #line 1450 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1023 "Python/bytecodes.c" + #line 1037 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); - #line 1435 "Python/generated_cases.c.h" + #line 1460 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1026 "Python/bytecodes.c" + #line 1040 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1439 "Python/generated_cases.c.h" + #line 1464 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { - #line 1030 "Python/bytecodes.c" + #line 1044 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1453,13 +1478,80 @@ } goto error; } - #line 1457 "Python/generated_cases.c.h" + #line 1482 "Python/generated_cases.c.h" + DISPATCH(); + } + + TARGET(LOAD_CLASS_OR_GLOBAL) { + PyObject *v; + #line 1058 "Python/bytecodes.c" + PyObject *name = GETITEM(frame->f_code->co_names, oparg); + PyObject *locals = GETLOCAL(0); + if (locals == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no locals when loading %R", name); + goto error; + } + if (PyDict_CheckExact(locals)) { + v = PyDict_GetItemWithError(locals, name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + } + else { + v = PyObject_GetItem(locals, name); + if (v == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + goto error; + _PyErr_Clear(tstate); + } + } + if (v == NULL) { + v = PyDict_GetItemWithError(GLOBALS(), name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + else { + if (PyDict_CheckExact(BUILTINS())) { + v = PyDict_GetItemWithError(BUILTINS(), name); + if (v == NULL) { + if (!_PyErr_Occurred(tstate)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + Py_INCREF(v); + } + else { + v = PyObject_GetItem(BUILTINS(), name); + if (v == NULL) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + } + } + } + #line 1547 "Python/generated_cases.c.h" + STACK_GROW(1); + stack_pointer[-1] = v; DISPATCH(); } TARGET(LOAD_NAME) { PyObject *v; - #line 1044 "Python/bytecodes.c" + #line 1119 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = LOCALS(); if (locals == NULL) { @@ -1518,7 +1610,7 @@ } } } - #line 1522 "Python/generated_cases.c.h" + #line 1614 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1529,7 +1621,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1111 "Python/bytecodes.c" + #line 1186 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1582,7 +1674,7 @@ } } null = NULL; - #line 1586 "Python/generated_cases.c.h" + #line 1678 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1596,7 +1688,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1166 "Python/bytecodes.c" + #line 1241 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); @@ -1608,7 +1700,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1612 "Python/generated_cases.c.h" + #line 1704 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1623,7 +1715,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1180 "Python/bytecodes.c" + #line 1255 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); @@ -1638,7 +1730,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1642 "Python/generated_cases.c.h" + #line 1734 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1648,16 +1740,16 @@ } TARGET(DELETE_FAST) { - #line 1197 "Python/bytecodes.c" + #line 1272 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1656 "Python/generated_cases.c.h" + #line 1748 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1203 "Python/bytecodes.c" + #line 1278 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1666,12 +1758,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1670 "Python/generated_cases.c.h" + #line 1762 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1214 "Python/bytecodes.c" + #line 1289 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1682,13 +1774,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1686 "Python/generated_cases.c.h" + #line 1778 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1227 "Python/bytecodes.c" + #line 1302 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1720,7 +1812,7 @@ } Py_INCREF(value); } - #line 1724 "Python/generated_cases.c.h" + #line 1816 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1728,7 +1820,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1261 "Python/bytecodes.c" + #line 1336 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1736,7 +1828,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1740 "Python/generated_cases.c.h" + #line 1832 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1744,18 +1836,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1271 "Python/bytecodes.c" + #line 1346 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 1753 "Python/generated_cases.c.h" + #line 1845 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1278 "Python/bytecodes.c" + #line 1353 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1766,22 +1858,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 1770 "Python/generated_cases.c.h" + #line 1862 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1291 "Python/bytecodes.c" + #line 1366 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 1779 "Python/generated_cases.c.h" + #line 1871 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1293 "Python/bytecodes.c" + #line 1368 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1785 "Python/generated_cases.c.h" + #line 1877 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -1791,10 +1883,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1297 "Python/bytecodes.c" + #line 1372 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1798 "Python/generated_cases.c.h" + #line 1890 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -1804,10 +1896,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1302 "Python/bytecodes.c" + #line 1377 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1811 "Python/generated_cases.c.h" + #line 1903 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -1817,7 +1909,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1307 "Python/bytecodes.c" + #line 1382 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -1828,13 +1920,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 1832 "Python/generated_cases.c.h" + #line 1924 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1318 "Python/bytecodes.c" + #line 1393 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 1838 "Python/generated_cases.c.h" + #line 1930 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -1843,13 +1935,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1325 "Python/bytecodes.c" + #line 1400 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 1849 "Python/generated_cases.c.h" + #line 1941 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1327 "Python/bytecodes.c" + #line 1402 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 1853 "Python/generated_cases.c.h" + #line 1945 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -1857,7 +1949,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1331 "Python/bytecodes.c" + #line 1406 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -1872,7 +1964,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 1876 "Python/generated_cases.c.h" + #line 1968 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -1882,7 +1974,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1348 "Python/bytecodes.c" + #line 1423 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -1890,13 +1982,13 @@ if (map == NULL) goto error; - #line 1894 "Python/generated_cases.c.h" + #line 1986 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1356 "Python/bytecodes.c" + #line 1431 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 1900 "Python/generated_cases.c.h" + #line 1992 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -1904,7 +1996,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1360 "Python/bytecodes.c" + #line 1435 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -1944,7 +2036,7 @@ Py_DECREF(ann_dict); } } - #line 1948 "Python/generated_cases.c.h" + #line 2040 "Python/generated_cases.c.h" DISPATCH(); } @@ -1952,7 +2044,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1402 "Python/bytecodes.c" + #line 1477 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -1962,14 +2054,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 1966 "Python/generated_cases.c.h" + #line 2058 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1412 "Python/bytecodes.c" + #line 1487 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 1973 "Python/generated_cases.c.h" + #line 2065 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -1977,7 +2069,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1416 "Python/bytecodes.c" + #line 1491 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -1985,12 +2077,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 1989 "Python/generated_cases.c.h" + #line 2081 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1424 "Python/bytecodes.c" + #line 1499 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 1994 "Python/generated_cases.c.h" + #line 2086 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -1998,17 +2090,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1430 "Python/bytecodes.c" + #line 1505 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2007 "Python/generated_cases.c.h" + #line 2099 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1435 "Python/bytecodes.c" + #line 1510 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2012 "Python/generated_cases.c.h" + #line 2104 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2018,13 +2110,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1442 "Python/bytecodes.c" + #line 1517 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2028 "Python/generated_cases.c.h" + #line 2120 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2036,7 +2128,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1465 "Python/bytecodes.c" + #line 1540 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2071,9 +2163,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2075 "Python/generated_cases.c.h" + #line 2167 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1500 "Python/bytecodes.c" + #line 1575 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2082,12 +2174,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2086 "Python/generated_cases.c.h" + #line 2178 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1509 "Python/bytecodes.c" + #line 1584 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2091 "Python/generated_cases.c.h" + #line 2183 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2101,7 +2193,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1514 "Python/bytecodes.c" + #line 1589 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2115,7 +2207,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2119 "Python/generated_cases.c.h" + #line 2211 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2130,7 +2222,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1531 "Python/bytecodes.c" + #line 1606 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; @@ -2144,7 +2236,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2148 "Python/generated_cases.c.h" + #line 2240 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2159,7 +2251,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1548 "Python/bytecodes.c" + #line 1623 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2187,7 +2279,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2191 "Python/generated_cases.c.h" + #line 2283 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2202,7 +2294,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1579 "Python/bytecodes.c" + #line 1654 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2213,7 +2305,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2217 "Python/generated_cases.c.h" + #line 2309 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2228,7 +2320,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1593 "Python/bytecodes.c" + #line 1668 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); @@ -2241,7 +2333,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2245 "Python/generated_cases.c.h" + #line 2337 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2255,7 +2347,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1609 "Python/bytecodes.c" + #line 1684 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); @@ -2279,7 +2371,7 @@ new_frame->localsplus[0] = owner; JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); DISPATCH_INLINED(new_frame); - #line 2283 "Python/generated_cases.c.h" + #line 2375 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2287,7 +2379,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1635 "Python/bytecodes.c" + #line 1710 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2313,7 +2405,7 @@ new_frame->localsplus[1] = Py_NewRef(name); JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); DISPATCH_INLINED(new_frame); - #line 2317 "Python/generated_cases.c.h" + #line 2409 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2321,7 +2413,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1663 "Python/bytecodes.c" + #line 1738 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2340,7 +2432,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2344 "Python/generated_cases.c.h" + #line 2436 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2351,7 +2443,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1684 "Python/bytecodes.c" + #line 1759 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2391,7 +2483,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2395 "Python/generated_cases.c.h" + #line 2487 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2402,7 +2494,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1726 "Python/bytecodes.c" + #line 1801 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2413,7 +2505,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2417 "Python/generated_cases.c.h" + #line 2509 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2425,7 +2517,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1746 "Python/bytecodes.c" + #line 1821 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2439,12 +2531,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2443 "Python/generated_cases.c.h" + #line 2535 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1760 "Python/bytecodes.c" + #line 1835 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2448 "Python/generated_cases.c.h" + #line 2540 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2455,7 +2547,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1764 "Python/bytecodes.c" + #line 1839 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); @@ -2468,7 +2560,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2472 "Python/generated_cases.c.h" + #line 2564 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2479,7 +2571,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1780 "Python/bytecodes.c" + #line 1855 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); @@ -2496,7 +2588,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2500 "Python/generated_cases.c.h" + #line 2592 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2507,7 +2599,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1800 "Python/bytecodes.c" + #line 1875 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); @@ -2521,7 +2613,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2525 "Python/generated_cases.c.h" + #line 2617 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2532,14 +2624,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1816 "Python/bytecodes.c" + #line 1891 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2538 "Python/generated_cases.c.h" + #line 2630 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1818 "Python/bytecodes.c" + #line 1893 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2543 "Python/generated_cases.c.h" + #line 2635 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2549,15 +2641,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1822 "Python/bytecodes.c" + #line 1897 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2555 "Python/generated_cases.c.h" + #line 2647 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1824 "Python/bytecodes.c" + #line 1899 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2561 "Python/generated_cases.c.h" + #line 2653 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2568,12 +2660,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 1829 "Python/bytecodes.c" + #line 1904 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2574 "Python/generated_cases.c.h" + #line 2666 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1831 "Python/bytecodes.c" + #line 1906 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2581,10 +2673,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2585 "Python/generated_cases.c.h" + #line 2677 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1839 "Python/bytecodes.c" + #line 1914 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2593,7 +2685,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2597 "Python/generated_cases.c.h" + #line 2689 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2603,21 +2695,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1850 "Python/bytecodes.c" + #line 1925 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2610 "Python/generated_cases.c.h" + #line 2702 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1853 "Python/bytecodes.c" + #line 1928 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2617 "Python/generated_cases.c.h" + #line 2709 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1858 "Python/bytecodes.c" + #line 1933 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2621 "Python/generated_cases.c.h" + #line 2713 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2626,15 +2718,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 1862 "Python/bytecodes.c" + #line 1937 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2633 "Python/generated_cases.c.h" + #line 2725 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 1865 "Python/bytecodes.c" + #line 1940 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2638 "Python/generated_cases.c.h" + #line 2730 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2643,29 +2735,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 1869 "Python/bytecodes.c" + #line 1944 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2651 "Python/generated_cases.c.h" + #line 2743 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 1875 "Python/bytecodes.c" + #line 1950 "Python/bytecodes.c" JUMPBY(oparg); - #line 2660 "Python/generated_cases.c.h" + #line 2752 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 1879 "Python/bytecodes.c" + #line 1954 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2669 "Python/generated_cases.c.h" + #line 2761 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2673,7 +2765,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 1885 "Python/bytecodes.c" + #line 1960 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2683,9 +2775,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2687 "Python/generated_cases.c.h" + #line 2779 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 1895 "Python/bytecodes.c" + #line 1970 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2693,14 +2785,14 @@ if (err < 0) goto pop_1_error; } } - #line 2697 "Python/generated_cases.c.h" + #line 2789 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 1905 "Python/bytecodes.c" + #line 1980 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2710,9 +2802,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2714 "Python/generated_cases.c.h" + #line 2806 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 1915 "Python/bytecodes.c" + #line 1990 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2720,67 +2812,67 @@ if (err < 0) goto pop_1_error; } } - #line 2724 "Python/generated_cases.c.h" + #line 2816 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 1925 "Python/bytecodes.c" + #line 2000 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 2733 "Python/generated_cases.c.h" + #line 2825 "Python/generated_cases.c.h" Py_DECREF(value); - #line 1927 "Python/bytecodes.c" + #line 2002 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 2741 "Python/generated_cases.c.h" + #line 2833 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 1935 "Python/bytecodes.c" + #line 2010 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 2754 "Python/generated_cases.c.h" + #line 2846 "Python/generated_cases.c.h" Py_DECREF(value); - #line 1941 "Python/bytecodes.c" + #line 2016 "Python/bytecodes.c" } - #line 2758 "Python/generated_cases.c.h" + #line 2850 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 1945 "Python/bytecodes.c" + #line 2020 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 2771 "Python/generated_cases.c.h" + #line 2863 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 1954 "Python/bytecodes.c" + #line 2029 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 2784 "Python/generated_cases.c.h" + #line 2876 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -2791,16 +2883,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 1962 "Python/bytecodes.c" + #line 2037 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 2800 "Python/generated_cases.c.h" + #line 2892 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 1967 "Python/bytecodes.c" + #line 2042 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -2808,7 +2900,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 2812 "Python/generated_cases.c.h" + #line 2904 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -2817,10 +2909,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 1977 "Python/bytecodes.c" + #line 2052 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 2824 "Python/generated_cases.c.h" + #line 2916 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2830,10 +2922,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 1983 "Python/bytecodes.c" + #line 2058 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 2837 "Python/generated_cases.c.h" + #line 2929 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2844,11 +2936,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 1989 "Python/bytecodes.c" + #line 2064 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 2852 "Python/generated_cases.c.h" + #line 2944 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -2857,14 +2949,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 1995 "Python/bytecodes.c" + #line 2070 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 2864 "Python/generated_cases.c.h" + #line 2956 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1998 "Python/bytecodes.c" + #line 2073 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 2868 "Python/generated_cases.c.h" + #line 2960 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -2872,7 +2964,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2002 "Python/bytecodes.c" + #line 2077 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -2895,11 +2987,11 @@ if (iter == NULL) { goto error; } - #line 2899 "Python/generated_cases.c.h" + #line 2991 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2025 "Python/bytecodes.c" + #line 2100 "Python/bytecodes.c" } - #line 2903 "Python/generated_cases.c.h" + #line 2995 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -2910,7 +3002,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2044 "Python/bytecodes.c" + #line 2119 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2943,7 +3035,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 2947 "Python/generated_cases.c.h" + #line 3039 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -2953,7 +3045,7 @@ TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2079 "Python/bytecodes.c" + #line 2154 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; @@ -2974,7 +3066,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 2978 "Python/generated_cases.c.h" + #line 3070 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -2984,7 +3076,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2102 "Python/bytecodes.c" + #line 2177 "Python/bytecodes.c" assert(cframe.use_tracing == 0); _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); @@ -3005,7 +3097,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3009 "Python/generated_cases.c.h" + #line 3101 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3015,7 +3107,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2125 "Python/bytecodes.c" + #line 2200 "Python/bytecodes.c" assert(cframe.use_tracing == 0); _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); @@ -3034,7 +3126,7 @@ if (next == NULL) { goto error; } - #line 3038 "Python/generated_cases.c.h" + #line 3130 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3043,7 +3135,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2146 "Python/bytecodes.c" + #line 2221 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3058,14 +3150,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg); assert(next_instr->op.code == END_FOR); DISPATCH_INLINED(gen_frame); - #line 3062 "Python/generated_cases.c.h" + #line 3154 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2163 "Python/bytecodes.c" + #line 2238 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3088,16 +3180,16 @@ Py_DECREF(enter); goto error; } - #line 3092 "Python/generated_cases.c.h" + #line 3184 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2186 "Python/bytecodes.c" + #line 2261 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3101 "Python/generated_cases.c.h" + #line 3193 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3109,7 +3201,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2196 "Python/bytecodes.c" + #line 2271 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3135,16 +3227,16 @@ Py_DECREF(enter); goto error; } - #line 3139 "Python/generated_cases.c.h" + #line 3231 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2222 "Python/bytecodes.c" + #line 2297 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3148 "Python/generated_cases.c.h" + #line 3240 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3156,7 +3248,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2231 "Python/bytecodes.c" + #line 2306 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3177,7 +3269,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3181 "Python/generated_cases.c.h" + #line 3273 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3186,7 +3278,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2254 "Python/bytecodes.c" + #line 2329 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3196,7 +3288,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3200 "Python/generated_cases.c.h" + #line 3292 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3210,7 +3302,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2266 "Python/bytecodes.c" + #line 2341 "Python/bytecodes.c" /* Cached method object */ assert(cframe.use_tracing == 0); PyTypeObject *self_cls = Py_TYPE(self); @@ -3228,7 +3320,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3232 "Python/generated_cases.c.h" + #line 3324 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3242,7 +3334,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2286 "Python/bytecodes.c" + #line 2361 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3253,7 +3345,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3257 "Python/generated_cases.c.h" + #line 3349 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3267,7 +3359,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2299 "Python/bytecodes.c" + #line 2374 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3282,7 +3374,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3286 "Python/generated_cases.c.h" + #line 3378 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3291,11 +3383,11 @@ } TARGET(KW_NAMES) { - #line 2316 "Python/bytecodes.c" + #line 2391 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3299 "Python/generated_cases.c.h" + #line 3391 "Python/generated_cases.c.h" DISPATCH(); } @@ -3306,7 +3398,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2352 "Python/bytecodes.c" + #line 2427 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3378,7 +3470,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3382 "Python/generated_cases.c.h" + #line 3474 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3390,7 +3482,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2430 "Python/bytecodes.c" + #line 2505 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3400,7 +3492,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3404 "Python/generated_cases.c.h" + #line 3496 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3409,7 +3501,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2442 "Python/bytecodes.c" + #line 2517 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3434,7 +3526,7 @@ STACK_SHRINK(oparg + 2); JUMPBY(INLINE_CACHE_ENTRIES_CALL); DISPATCH_INLINED(new_frame); - #line 3438 "Python/generated_cases.c.h" + #line 3530 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3442,7 +3534,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2469 "Python/bytecodes.c" + #line 2544 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3477,7 +3569,7 @@ STACK_SHRINK(oparg + 2); JUMPBY(INLINE_CACHE_ENTRIES_CALL); DISPATCH_INLINED(new_frame); - #line 3481 "Python/generated_cases.c.h" + #line 3573 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3485,7 +3577,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2506 "Python/bytecodes.c" + #line 2581 "Python/bytecodes.c" assert(kwnames == NULL); assert(cframe.use_tracing == 0); assert(oparg == 1); @@ -3496,7 +3588,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3500 "Python/generated_cases.c.h" + #line 3592 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3509,7 +3601,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2519 "Python/bytecodes.c" + #line 2594 "Python/bytecodes.c" assert(kwnames == NULL); assert(cframe.use_tracing == 0); assert(oparg == 1); @@ -3521,7 +3613,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3525 "Python/generated_cases.c.h" + #line 3617 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3535,7 +3627,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2534 "Python/bytecodes.c" + #line 2609 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3546,7 +3638,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3550 "Python/generated_cases.c.h" + #line 3642 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3560,7 +3652,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2548 "Python/bytecodes.c" + #line 2623 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3582,7 +3674,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3586 "Python/generated_cases.c.h" + #line 3678 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3596,7 +3688,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2573 "Python/bytecodes.c" + #line 2648 "Python/bytecodes.c" assert(cframe.use_tracing == 0); /* Builtin METH_O functions */ assert(kwnames == NULL); @@ -3625,7 +3717,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3629 "Python/generated_cases.c.h" + #line 3721 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3639,7 +3731,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2605 "Python/bytecodes.c" + #line 2680 "Python/bytecodes.c" assert(cframe.use_tracing == 0); /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); @@ -3672,7 +3764,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 3676 "Python/generated_cases.c.h" + #line 3768 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3686,7 +3778,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2641 "Python/bytecodes.c" + #line 2716 "Python/bytecodes.c" assert(cframe.use_tracing == 0); /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; @@ -3719,7 +3811,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3723 "Python/generated_cases.c.h" + #line 3815 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3733,7 +3825,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2677 "Python/bytecodes.c" + #line 2752 "Python/bytecodes.c" assert(cframe.use_tracing == 0); assert(kwnames == NULL); /* len(o) */ @@ -3759,7 +3851,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3763 "Python/generated_cases.c.h" + #line 3855 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3772,7 +3864,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2705 "Python/bytecodes.c" + #line 2780 "Python/bytecodes.c" assert(cframe.use_tracing == 0); assert(kwnames == NULL); /* isinstance(o, o2) */ @@ -3800,7 +3892,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3804 "Python/generated_cases.c.h" + #line 3896 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3812,7 +3904,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2736 "Python/bytecodes.c" + #line 2811 "Python/bytecodes.c" assert(cframe.use_tracing == 0); assert(kwnames == NULL); assert(oparg == 1); @@ -3831,14 +3923,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 3835 "Python/generated_cases.c.h" + #line 3927 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2757 "Python/bytecodes.c" + #line 2832 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -3869,7 +3961,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3873 "Python/generated_cases.c.h" + #line 3965 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3882,7 +3974,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2791 "Python/bytecodes.c" + #line 2866 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3911,7 +4003,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3915 "Python/generated_cases.c.h" + #line 4007 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3924,7 +4016,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2823 "Python/bytecodes.c" + #line 2898 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -3953,7 +4045,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3957 "Python/generated_cases.c.h" + #line 4049 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3966,7 +4058,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2855 "Python/bytecodes.c" + #line 2930 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -3994,7 +4086,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3998 "Python/generated_cases.c.h" + #line 4090 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4009,7 +4101,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 2886 "Python/bytecodes.c" + #line 2961 "Python/bytecodes.c" if (oparg & 1) { // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. @@ -4028,15 +4120,15 @@ assert(PyTuple_CheckExact(callargs)); result = do_call_core(tstate, func, callargs, kwargs, cframe.use_tracing); - #line 4032 "Python/generated_cases.c.h" + #line 4124 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 2905 "Python/bytecodes.c" + #line 2980 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4040 "Python/generated_cases.c.h" + #line 4132 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4051,7 +4143,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 2916 "Python/bytecodes.c" + #line 2991 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4080,14 +4172,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4084 "Python/generated_cases.c.h" + #line 4176 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 2947 "Python/bytecodes.c" + #line 3022 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4108,7 +4200,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4112 "Python/generated_cases.c.h" + #line 4204 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4116,15 +4208,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 2970 "Python/bytecodes.c" + #line 3045 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4122 "Python/generated_cases.c.h" + #line 4214 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 2972 "Python/bytecodes.c" + #line 3047 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4128 "Python/generated_cases.c.h" + #line 4220 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4135,7 +4227,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 2976 "Python/bytecodes.c" + #line 3051 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4170,7 +4262,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4174 "Python/generated_cases.c.h" + #line 4266 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4179,10 +4271,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3013 "Python/bytecodes.c" + #line 3088 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4186 "Python/generated_cases.c.h" + #line 4278 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4194,7 +4286,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3018 "Python/bytecodes.c" + #line 3093 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4210,12 +4302,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4214 "Python/generated_cases.c.h" + #line 4306 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3034 "Python/bytecodes.c" + #line 3109 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4219 "Python/generated_cases.c.h" + #line 4311 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4225,27 +4317,27 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3039 "Python/bytecodes.c" + #line 3114 "Python/bytecodes.c" assert(oparg >= 2); - #line 4231 "Python/generated_cases.c.h" + #line 4323 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3043 "Python/bytecodes.c" + #line 3118 "Python/bytecodes.c" assert(oparg); assert(cframe.use_tracing == 0); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4245 "Python/generated_cases.c.h" + #line 4337 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3052 "Python/bytecodes.c" + #line 3127 "Python/bytecodes.c" Py_UNREACHABLE(); - #line 4251 "Python/generated_cases.c.h" + #line 4343 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index f57b76aeb31050..09011e4f76c70e 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -37,6 +37,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 1; case PUSH_NULL: return 0; + case POP_NULL: + return 1; case END_FOR: return 1+1; case UNARY_NEGATIVE: @@ -123,6 +125,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 0; case LOAD_BUILD_CLASS: return 0; + case LOAD_LOCALS: + return 0; case STORE_NAME: return 1; case DELETE_NAME: @@ -145,6 +149,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 1; case DELETE_GLOBAL: return 0; + case LOAD_CLASS_OR_GLOBAL: + return 0; case LOAD_NAME: return 0; case LOAD_GLOBAL: @@ -383,6 +389,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case PUSH_NULL: return 1; + case POP_NULL: + return 0; case END_FOR: return 0+0; case UNARY_NEGATIVE: @@ -469,6 +477,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case LOAD_BUILD_CLASS: return 1; + case LOAD_LOCALS: + return 1; case STORE_NAME: return 0; case DELETE_NAME: @@ -491,6 +501,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case DELETE_GLOBAL: return 0; + case LOAD_CLASS_OR_GLOBAL: + return 1; case LOAD_NAME: return 1; case LOAD_GLOBAL: @@ -719,6 +731,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [LOAD_CONST__LOAD_FAST] = { true, INSTR_FMT_IBIB }, [POP_TOP] = { true, INSTR_FMT_IX }, [PUSH_NULL] = { true, INSTR_FMT_IX }, + [POP_NULL] = { true, INSTR_FMT_IX }, [END_FOR] = { true, INSTR_FMT_IB }, [UNARY_NEGATIVE] = { true, INSTR_FMT_IX }, [UNARY_NOT] = { true, INSTR_FMT_IX }, @@ -762,6 +775,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [CLEANUP_THROW] = { true, INSTR_FMT_IX }, [LOAD_ASSERTION_ERROR] = { true, INSTR_FMT_IX }, [LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX }, + [LOAD_LOCALS] = { true, INSTR_FMT_IX }, [STORE_NAME] = { true, INSTR_FMT_IB }, [DELETE_NAME] = { true, INSTR_FMT_IB }, [UNPACK_SEQUENCE] = { true, INSTR_FMT_IBC }, @@ -773,6 +787,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [DELETE_ATTR] = { true, INSTR_FMT_IB }, [STORE_GLOBAL] = { true, INSTR_FMT_IB }, [DELETE_GLOBAL] = { true, INSTR_FMT_IB }, + [LOAD_CLASS_OR_GLOBAL] = { true, INSTR_FMT_IB }, [LOAD_NAME] = { true, INSTR_FMT_IB }, [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index c502471bcd17b6..1dd4fddd6bf2d0 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -85,9 +85,9 @@ static void *opcode_targets[256] = { &&TARGET_RETURN_VALUE, &&TARGET_LOAD_GLOBAL_MODULE, &&TARGET_SETUP_ANNOTATIONS, + &&TARGET_POP_NULL, + &&TARGET_LOAD_LOCALS, &&TARGET_STORE_ATTR_INSTANCE_VALUE, - &&TARGET_STORE_ATTR_SLOT, - &&TARGET_STORE_ATTR_WITH_HINT, &&TARGET_POP_EXCEPT, &&TARGET_STORE_NAME, &&TARGET_DELETE_NAME, @@ -110,9 +110,9 @@ static void *opcode_targets[256] = { &&TARGET_IMPORT_NAME, &&TARGET_IMPORT_FROM, &&TARGET_JUMP_FORWARD, + &&TARGET_STORE_ATTR_SLOT, + &&TARGET_STORE_ATTR_WITH_HINT, &&TARGET_STORE_FAST__LOAD_FAST, - &&TARGET_STORE_FAST__STORE_FAST, - &&TARGET_STORE_SUBSCR_DICT, &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_LOAD_GLOBAL, @@ -140,9 +140,9 @@ static void *opcode_targets[256] = { &&TARGET_STORE_DEREF, &&TARGET_DELETE_DEREF, &&TARGET_JUMP_BACKWARD, - &&TARGET_STORE_SUBSCR_LIST_INT, + &&TARGET_STORE_FAST__STORE_FAST, &&TARGET_CALL_FUNCTION_EX, - &&TARGET_UNPACK_SEQUENCE_LIST, + &&TARGET_STORE_SUBSCR_DICT, &&TARGET_EXTENDED_ARG, &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, @@ -152,15 +152,15 @@ static void *opcode_targets[256] = { &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, - &&TARGET_UNPACK_SEQUENCE_TUPLE, - &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, + &&TARGET_STORE_SUBSCR_LIST_INT, + &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, + &&TARGET_UNPACK_SEQUENCE_TUPLE, + &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, &&_unknown_opcode, - &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, @@ -174,7 +174,7 @@ static void *opcode_targets[256] = { &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, - &&_unknown_opcode, + &&TARGET_LOAD_CLASS_OR_GLOBAL, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From d26b82aaf4249067af6d8eaaaf317ee7466467ac Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 09:42:36 -0600 Subject: [PATCH 038/200] fix it in classes too --- Lib/test/test_type_params.py | 21 ++++++++++++++++++++- Python/compile.c | 7 ++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 7302399369a00b..b4e9cd801a00ac 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -206,6 +206,26 @@ def funcB[B](self): ... with self.assertRaisesRegex(NameError, "name 'B' is not defined"): exec(code, {}) + def test_class_scope_interaction_01(self): + code = textwrap.dedent("""\ + class C: + x = 1 + def method[T](self, arg: x): pass + + assert C.method.__annotations__["arg"] == 1 + """) + exec(code, {}) + + def test_class_scope_interaction_02(self): + code = textwrap.dedent("""\ + class C: + class Base: pass + class Child[T](Base): pass + + assert C.Child.__bases__ == (C.Base,) + """) + exec(code, {}) + class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): @@ -339,7 +359,6 @@ def func1[**A](): self.assertFalse(a.__contravariant__) - class TypeParamsTypeParamsDunder(unittest.TestCase): def test_typeparams_dunder_class_01(self): class Outer[A, B]: diff --git a/Python/compile.c b/Python/compile.c index f3ddf4f2d3a9af..4e1d91047c1c4f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2444,6 +2444,8 @@ compiler_class(struct compiler *c, stmt_ty s) s->v.ClassDef.keywords)); if (typeparams) { + int is_in_class = c->u->u_ste->ste_type_params_in_class; + c->u->u_argcount = is_in_class; PyCodeObject *co = assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2454,7 +2456,10 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); - ADDOP_I(c, loc, CALL, 0); + if (is_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + } + ADDOP_I(c, loc, CALL, is_in_class); } /* 6. apply decorators */ From 423d2de770a93951a6d805753bc177af9311e0bd Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 09:58:42 -0600 Subject: [PATCH 039/200] Support bounds --- Include/internal/pycore_intrinsics.h | 3 ++- Python/compile.c | 8 +++++++- Python/intrinsics.c | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index cfd1c04ef76e9a..a653fdba19c1dc 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -17,8 +17,9 @@ /* Binary Functions: */ #define INTRINSIC_PREP_RERAISE_STAR 1 +#define INTRINSIC_TYPEVAR_WITH_BOUND 2 -#define MAX_INTRINSIC_2 1 +#define MAX_INTRINSIC_2 2 typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value); diff --git a/Python/compile.c b/Python/compile.c index 4e1d91047c1c4f..56612802d833a9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2132,7 +2132,13 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) switch(typeparam->kind) { case TypeVar_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVar.name); - ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVAR); + if (typeparam->v.TypeVar.bound) { + VISIT(c, expr, typeparam->v.TypeVar.bound); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_TYPEVAR_WITH_BOUND); + } + else { + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVAR); + } compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store); break; case TypeVarTuple_kind: diff --git a/Python/intrinsics.c b/Python/intrinsics.c index a5a3e47d325d92..d435d6d59fa666 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -246,8 +246,15 @@ prep_reraise_star(PyThreadState* unused, PyObject *orig, PyObject *excs) return _PyExc_PrepReraiseStar(orig, excs); } +static PyObject * +make_typevar_with_bound(PyThreadState* unused, PyObject *name, PyObject *bound) +{ + assert(PyUnicode_Check(name)); + return _Py_make_typevar(PyUnicode_AsUTF8(name), bound); +} + const instrinsic_func2 _PyIntrinsics_BinaryFunctions[] = { [INTRINSIC_PREP_RERAISE_STAR] = prep_reraise_star, + [INTRINSIC_TYPEVAR_WITH_BOUND] = make_typevar_with_bound, }; - From fdd887763333879ce15e89663c9fd5a4cfd60ce0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 10:36:48 -0600 Subject: [PATCH 040/200] Use dummy class to get TypeVar-like types --- Lib/typing.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index 8c26aa9a592bf0..c274167e45c88a 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1302,12 +1302,17 @@ def __typing_prepare_subst__(self, alias, args): import builtins if hasattr(builtins, "TypeVar"): - TypeVar = builtins.TypeVar - TypeVarTuple = builtins.TypeVarTuple - ParamSpec = builtins.ParamSpec + class _Dummy[T, *Ts, **P]: + type_params = (T, Ts, P) + + TypeVar = type(_Dummy.type_params[0]) + TypeVarTuple = type(_Dummy.type_params[1]) + ParamSpec = type(_Dummy.type_params[2]) ParamSpecArgs = type(ParamSpec("P").args) ParamSpecKwargs = type(ParamSpec("P").kwargs) + del _Dummy + import copyreg def _pickle_psargs(psargs): From 2461ed5c76cdee9d0dd38eb2e881a0716243afa1 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 10:37:36 -0600 Subject: [PATCH 041/200] fix typo in test --- Lib/test/test_type_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index b4e9cd801a00ac..a4538b923e9065 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -168,7 +168,7 @@ class ClassA: def func[T](self, a: x, b: T): ... - assert Class.func.__annotations__["a"] is int + assert ClassA.func.__annotations__["a"] is int """ ) exec(code, {}) From e9a196fceddd6e273dbadb36deac0534e4bb90f5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 10:49:34 -0600 Subject: [PATCH 042/200] Add union support to TypeVar (and ParamSpec, somewhat dubiously) --- Objects/typevarobject.c | 10 ++++++++++ Objects/unionobject.c | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index d511f79c7dc38e..1175c927fbf3c5 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -2,6 +2,7 @@ #include "Python.h" #include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK #include "pycore_typevarobject.h" +#include "pycore_unionobject.h" // _Py_union_type_or #include "structmember.h" /*[clinic input] @@ -244,6 +245,10 @@ static PyMethodDef typevar_methods[] = { {0} }; +static PyNumberMethods typevar_as_number = { + .nb_or = _Py_union_type_or, // Add __or__ function +}; + PyTypeObject _PyTypeVar_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.TypeVar", @@ -257,6 +262,7 @@ PyTypeObject _PyTypeVar_Type = { .tp_members = typevar_members, .tp_methods = typevar_methods, .tp_new = typevar_new, + .tp_as_number = &typevar_as_number, }; typedef struct { @@ -624,6 +630,9 @@ static PyMethodDef paramspec_methods[] = { {0} }; +static PyNumberMethods paramspec_as_number = { + .nb_or = _Py_union_type_or, // Add __or__ function +}; // TODO: // - pickling @@ -641,6 +650,7 @@ PyTypeObject _PyParamSpec_Type = { .tp_methods = paramspec_methods, .tp_getset = paramspec_getset, .tp_new = paramspec_new, + .tp_as_number = ¶mspec_as_number, }; static void typevartupleobject_dealloc(PyObject *self) diff --git a/Objects/unionobject.c b/Objects/unionobject.c index f273f7d15ef25f..b84c9b8ecedd94 100644 --- a/Objects/unionobject.c +++ b/Objects/unionobject.c @@ -1,6 +1,7 @@ // types.UnionType -- used to represent e.g. Union[int, str], int | str #include "Python.h" #include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK +#include "pycore_typevarobject.h" // _PyTypeVar_Type #include "pycore_unionobject.h" #include "structmember.h" @@ -150,7 +151,9 @@ is_unionable(PyObject *obj) return (obj == Py_None || PyType_Check(obj) || _PyGenericAlias_Check(obj) || - _PyUnion_Check(obj)); + _PyUnion_Check(obj) || + Py_IS_TYPE(obj, &_PyTypeVar_Type) || + Py_IS_TYPE(obj, &_PyParamSpec_Type)); } PyObject * From 536cf13629d574408eee5521478b1e5cef3071f3 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2023 18:16:48 -0600 Subject: [PATCH 043/200] add function.__type_variables__ --- Python/bytecodes.c | 6 + Python/compile.c | 9 +- Python/generated_cases.c.h | 485 +++++++++++++++++++------------------ Python/opcode_metadata.h | 2 +- Python/symtable.c | 6 + 5 files changed, 266 insertions(+), 242 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 070d13607f3604..a2929c1cacf32d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -123,6 +123,7 @@ dummy_func( PyObject *subject; PyObject *top; PyObject *type; + PyObject *typevars; int values_or_none; switch (opcode) { @@ -2985,6 +2986,7 @@ dummy_func( inst(MAKE_FUNCTION, (defaults if (oparg & 0x01), kwdefaults if (oparg & 0x02), + typevars if (oparg & 0x10), annotations if (oparg & 0x04), closure if (oparg & 0x08), codeobj -- func)) { @@ -2997,6 +2999,10 @@ dummy_func( goto error; } + if (oparg & 0x10) { + assert(PyTuple_CheckExact(typevars)); + func_obj->func_typevars = typevars; + } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; diff --git a/Python/compile.c b/Python/compile.c index 56612802d833a9..33d4e5c1cbfecf 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2125,8 +2125,9 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) if (!typeparams) { return SUCCESS; } + Py_ssize_t n = asdl_seq_LEN(typeparams); - for (Py_ssize_t i = 0; i < asdl_seq_LEN(typeparams); i++) { + for (Py_ssize_t i = 0; i < n; i++) { typeparam_ty typeparam = asdl_seq_GET(typeparams, i); location loc = LOC(typeparam); switch(typeparam->kind) { @@ -2139,20 +2140,24 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) else { ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVAR); } + ADDOP_I(c, loc, COPY, 1); compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store); break; case TypeVarTuple_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVarTuple.name); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVARTUPLE); + ADDOP_I(c, loc, COPY, 1); compiler_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store); break; case ParamSpec_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.ParamSpec.name); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_PARAMSPEC); + ADDOP_I(c, loc, COPY, 1); compiler_nameop(c, loc, typeparam->v.ParamSpec.name, Store); break; } } + ADDOP_I(c, LOC(asdl_seq_GET(typeparams, 0)), BUILD_TUPLE, n); return SUCCESS; } @@ -2231,6 +2236,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int num_typeparam_args = 0; if (typeparams) { + funcflags |= 0x10; PyObject *typeparams_name = PyUnicode_FromFormat("", name); if (!typeparams_name) { return ERROR; @@ -2355,6 +2361,7 @@ compiler_class(struct compiler *c, stmt_ty s) } Py_DECREF(typeparams_name); RETURN_IF_ERROR(compiler_type_params(c, typeparams)); + ADDOP(c, loc, POP_TOP); } /* ultimately generate code for: diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index bfec53c8c27d8d..24ebb885030997 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -8,7 +8,7 @@ } TARGET(RESUME) { - #line 135 "Python/bytecodes.c" + #line 136 "Python/bytecodes.c" assert(tstate->cframe == &cframe); assert(frame == cframe.current_frame); if (_Py_atomic_load_relaxed_int32(eval_breaker) && oparg < 2) { @@ -20,7 +20,7 @@ TARGET(LOAD_CLOSURE) { PyObject *value; - #line 143 "Python/bytecodes.c" + #line 144 "Python/bytecodes.c" /* We keep LOAD_CLOSURE so that the bytecode stays more readable. */ value = GETLOCAL(oparg); if (value == NULL) goto unbound_local_error; @@ -33,7 +33,7 @@ TARGET(LOAD_FAST_CHECK) { PyObject *value; - #line 150 "Python/bytecodes.c" + #line 151 "Python/bytecodes.c" value = GETLOCAL(oparg); if (value == NULL) goto unbound_local_error; Py_INCREF(value); @@ -45,7 +45,7 @@ TARGET(LOAD_FAST) { PyObject *value; - #line 156 "Python/bytecodes.c" + #line 157 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); @@ -58,7 +58,7 @@ TARGET(LOAD_CONST) { PREDICTED(LOAD_CONST); PyObject *value; - #line 162 "Python/bytecodes.c" + #line 163 "Python/bytecodes.c" value = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(value); #line 65 "Python/generated_cases.c.h" @@ -69,7 +69,7 @@ TARGET(STORE_FAST) { PyObject *value = stack_pointer[-1]; - #line 167 "Python/bytecodes.c" + #line 168 "Python/bytecodes.c" SETLOCAL(oparg, value); #line 75 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -81,7 +81,7 @@ PyObject *_tmp_2; { PyObject *value; - #line 156 "Python/bytecodes.c" + #line 157 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); @@ -91,7 +91,7 @@ oparg = (next_instr++)->op.arg; { PyObject *value; - #line 156 "Python/bytecodes.c" + #line 157 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); @@ -109,7 +109,7 @@ PyObject *_tmp_2; { PyObject *value; - #line 156 "Python/bytecodes.c" + #line 157 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); @@ -119,7 +119,7 @@ oparg = (next_instr++)->op.arg; { PyObject *value; - #line 162 "Python/bytecodes.c" + #line 163 "Python/bytecodes.c" value = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(value); #line 126 "Python/generated_cases.c.h" @@ -135,14 +135,14 @@ PyObject *_tmp_1 = stack_pointer[-1]; { PyObject *value = _tmp_1; - #line 167 "Python/bytecodes.c" + #line 168 "Python/bytecodes.c" SETLOCAL(oparg, value); #line 141 "Python/generated_cases.c.h" } oparg = (next_instr++)->op.arg; { PyObject *value; - #line 156 "Python/bytecodes.c" + #line 157 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); @@ -158,14 +158,14 @@ PyObject *_tmp_2 = stack_pointer[-2]; { PyObject *value = _tmp_1; - #line 167 "Python/bytecodes.c" + #line 168 "Python/bytecodes.c" SETLOCAL(oparg, value); #line 164 "Python/generated_cases.c.h" } oparg = (next_instr++)->op.arg; { PyObject *value = _tmp_2; - #line 167 "Python/bytecodes.c" + #line 168 "Python/bytecodes.c" SETLOCAL(oparg, value); #line 171 "Python/generated_cases.c.h" } @@ -178,7 +178,7 @@ PyObject *_tmp_2; { PyObject *value; - #line 162 "Python/bytecodes.c" + #line 163 "Python/bytecodes.c" value = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(value); #line 185 "Python/generated_cases.c.h" @@ -187,7 +187,7 @@ oparg = (next_instr++)->op.arg; { PyObject *value; - #line 156 "Python/bytecodes.c" + #line 157 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); @@ -202,7 +202,7 @@ TARGET(POP_TOP) { PyObject *value = stack_pointer[-1]; - #line 177 "Python/bytecodes.c" + #line 178 "Python/bytecodes.c" #line 207 "Python/generated_cases.c.h" Py_DECREF(value); STACK_SHRINK(1); @@ -211,7 +211,7 @@ TARGET(PUSH_NULL) { PyObject *res; - #line 181 "Python/bytecodes.c" + #line 182 "Python/bytecodes.c" res = NULL; #line 217 "Python/generated_cases.c.h" STACK_GROW(1); @@ -221,7 +221,7 @@ TARGET(POP_NULL) { PyObject *value = stack_pointer[-1]; - #line 185 "Python/bytecodes.c" + #line 186 "Python/bytecodes.c" assert(value == NULL); #line 227 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -233,13 +233,13 @@ PyObject *_tmp_2 = stack_pointer[-2]; { PyObject *value = _tmp_1; - #line 177 "Python/bytecodes.c" + #line 178 "Python/bytecodes.c" #line 238 "Python/generated_cases.c.h" Py_DECREF(value); } { PyObject *value = _tmp_2; - #line 177 "Python/bytecodes.c" + #line 178 "Python/bytecodes.c" #line 244 "Python/generated_cases.c.h" Py_DECREF(value); } @@ -250,11 +250,11 @@ TARGET(UNARY_NEGATIVE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 191 "Python/bytecodes.c" + #line 192 "Python/bytecodes.c" res = PyNumber_Negative(value); #line 256 "Python/generated_cases.c.h" Py_DECREF(value); - #line 193 "Python/bytecodes.c" + #line 194 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; #line 260 "Python/generated_cases.c.h" stack_pointer[-1] = res; @@ -264,11 +264,11 @@ TARGET(UNARY_NOT) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 197 "Python/bytecodes.c" + #line 198 "Python/bytecodes.c" int err = PyObject_IsTrue(value); #line 270 "Python/generated_cases.c.h" Py_DECREF(value); - #line 199 "Python/bytecodes.c" + #line 200 "Python/bytecodes.c" if (err < 0) goto pop_1_error; if (err == 0) { res = Py_True; @@ -285,11 +285,11 @@ TARGET(UNARY_INVERT) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 210 "Python/bytecodes.c" + #line 211 "Python/bytecodes.c" res = PyNumber_Invert(value); #line 291 "Python/generated_cases.c.h" Py_DECREF(value); - #line 212 "Python/bytecodes.c" + #line 213 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; #line 295 "Python/generated_cases.c.h" stack_pointer[-1] = res; @@ -300,7 +300,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; - #line 229 "Python/bytecodes.c" + #line 230 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); @@ -320,7 +320,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; - #line 240 "Python/bytecodes.c" + #line 241 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); @@ -339,7 +339,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; - #line 250 "Python/bytecodes.c" + #line 251 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); @@ -359,7 +359,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; - #line 261 "Python/bytecodes.c" + #line 262 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); @@ -377,7 +377,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 270 "Python/bytecodes.c" + #line 271 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -396,7 +396,7 @@ TARGET(BINARY_OP_INPLACE_ADD_UNICODE) { PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; - #line 287 "Python/bytecodes.c" + #line 288 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -433,7 +433,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; - #line 317 "Python/bytecodes.c" + #line 318 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -452,7 +452,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; - #line 327 "Python/bytecodes.c" + #line 328 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); @@ -474,7 +474,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; PyObject *res; - #line 346 "Python/bytecodes.c" + #line 347 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -490,7 +490,7 @@ #line 491 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); - #line 359 "Python/bytecodes.c" + #line 360 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 496 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -504,7 +504,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *res; - #line 363 "Python/bytecodes.c" + #line 364 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); // Can't use ERROR_IF() here, because we haven't // DECREF'ed container yet, and we still own slice. @@ -528,7 +528,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *v = stack_pointer[-4]; - #line 378 "Python/bytecodes.c" + #line 379 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); int err; if (slice == NULL) { @@ -550,7 +550,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *res; - #line 393 "Python/bytecodes.c" + #line 394 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR); @@ -576,7 +576,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *tuple = stack_pointer[-2]; PyObject *res; - #line 410 "Python/bytecodes.c" + #line 411 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR); @@ -602,7 +602,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *res; - #line 427 "Python/bytecodes.c" + #line 428 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR); STAT_INC(BINARY_SUBSCR, hit); @@ -614,7 +614,7 @@ #line 615 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); - #line 436 "Python/bytecodes.c" + #line 437 "Python/bytecodes.c" if (true) goto pop_2_error; } Py_INCREF(res); // Do this before DECREF'ing dict, sub @@ -630,7 +630,7 @@ TARGET(BINARY_SUBSCR_GETITEM) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; - #line 443 "Python/bytecodes.c" + #line 444 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(container); DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR); PyHeapTypeObject *ht = (PyHeapTypeObject *)tp; @@ -657,7 +657,7 @@ TARGET(LIST_APPEND) { PyObject *v = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 466 "Python/bytecodes.c" + #line 467 "Python/bytecodes.c" if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error; #line 663 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -668,11 +668,11 @@ TARGET(SET_ADD) { PyObject *v = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 471 "Python/bytecodes.c" + #line 472 "Python/bytecodes.c" int err = PySet_Add(set, v); #line 674 "Python/generated_cases.c.h" Py_DECREF(v); - #line 473 "Python/bytecodes.c" + #line 474 "Python/bytecodes.c" if (err) goto pop_1_error; #line 678 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -687,7 +687,7 @@ PyObject *container = stack_pointer[-2]; PyObject *v = stack_pointer[-3]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 484 "Python/bytecodes.c" + #line 485 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { assert(cframe.use_tracing == 0); @@ -707,7 +707,7 @@ Py_DECREF(v); Py_DECREF(container); Py_DECREF(sub); - #line 500 "Python/bytecodes.c" + #line 501 "Python/bytecodes.c" if (err) goto pop_3_error; #line 713 "Python/generated_cases.c.h" STACK_SHRINK(3); @@ -719,7 +719,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; - #line 504 "Python/bytecodes.c" + #line 505 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR); @@ -747,7 +747,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; - #line 524 "Python/bytecodes.c" + #line 525 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR); STAT_INC(STORE_SUBSCR, hit); @@ -763,13 +763,13 @@ TARGET(DELETE_SUBSCR) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; - #line 533 "Python/bytecodes.c" + #line 534 "Python/bytecodes.c" /* del container[sub] */ int err = PyObject_DelItem(container, sub); #line 770 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); - #line 536 "Python/bytecodes.c" + #line 537 "Python/bytecodes.c" if (err) goto pop_2_error; #line 775 "Python/generated_cases.c.h" STACK_SHRINK(2); @@ -779,12 +779,12 @@ TARGET(CALL_INTRINSIC_1) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 540 "Python/bytecodes.c" + #line 541 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_1); res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value); #line 786 "Python/generated_cases.c.h" Py_DECREF(value); - #line 543 "Python/bytecodes.c" + #line 544 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; #line 790 "Python/generated_cases.c.h" stack_pointer[-1] = res; @@ -795,13 +795,13 @@ PyObject *value1 = stack_pointer[-1]; PyObject *value2 = stack_pointer[-2]; PyObject *res; - #line 547 "Python/bytecodes.c" + #line 548 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_2); res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1); #line 802 "Python/generated_cases.c.h" Py_DECREF(value2); Py_DECREF(value1); - #line 550 "Python/bytecodes.c" + #line 551 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 807 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -811,7 +811,7 @@ TARGET(RAISE_VARARGS) { PyObject **args = (stack_pointer - oparg); - #line 554 "Python/bytecodes.c" + #line 555 "Python/bytecodes.c" PyObject *cause = NULL, *exc = NULL; switch (oparg) { case 2: @@ -834,7 +834,7 @@ TARGET(INTERPRETER_EXIT) { PyObject *retval = stack_pointer[-1]; - #line 574 "Python/bytecodes.c" + #line 575 "Python/bytecodes.c" assert(frame == &entry_frame); assert(_PyFrame_IsIncomplete(frame)); STACK_SHRINK(1); // Since we're not going to DISPATCH() @@ -851,7 +851,7 @@ TARGET(RETURN_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 588 "Python/bytecodes.c" + #line 589 "Python/bytecodes.c" STACK_SHRINK(1); assert(EMPTY()); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -869,7 +869,7 @@ } TARGET(RETURN_CONST) { - #line 604 "Python/bytecodes.c" + #line 605 "Python/bytecodes.c" PyObject *retval = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(retval); assert(EMPTY()); @@ -890,7 +890,7 @@ TARGET(GET_AITER) { PyObject *obj = stack_pointer[-1]; PyObject *iter; - #line 621 "Python/bytecodes.c" + #line 622 "Python/bytecodes.c" unaryfunc getter = NULL; PyTypeObject *type = Py_TYPE(obj); @@ -905,14 +905,14 @@ type->tp_name); #line 907 "Python/generated_cases.c.h" Py_DECREF(obj); - #line 634 "Python/bytecodes.c" + #line 635 "Python/bytecodes.c" if (true) goto pop_1_error; } iter = (*getter)(obj); #line 914 "Python/generated_cases.c.h" Py_DECREF(obj); - #line 639 "Python/bytecodes.c" + #line 640 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; if (Py_TYPE(iter)->tp_as_async == NULL || @@ -933,7 +933,7 @@ TARGET(GET_ANEXT) { PyObject *aiter = stack_pointer[-1]; PyObject *awaitable; - #line 654 "Python/bytecodes.c" + #line 655 "Python/bytecodes.c" unaryfunc getter = NULL; PyObject *next_iter = NULL; PyTypeObject *type = Py_TYPE(aiter); @@ -988,7 +988,7 @@ PREDICTED(GET_AWAITABLE); PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 701 "Python/bytecodes.c" + #line 702 "Python/bytecodes.c" iter = _PyCoro_GetAwaitableIter(iterable); if (iter == NULL) { @@ -997,7 +997,7 @@ #line 999 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 708 "Python/bytecodes.c" + #line 709 "Python/bytecodes.c" if (iter != NULL && PyCoro_CheckExact(iter)) { PyObject *yf = _PyGen_yf((PyGenObject*)iter); @@ -1026,7 +1026,7 @@ PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; PyObject *retval; - #line 734 "Python/bytecodes.c" + #line 735 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PySendCache *cache = (_PySendCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1071,7 +1071,7 @@ TARGET(SEND_GEN) { PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; - #line 772 "Python/bytecodes.c" + #line 773 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyGenObject *gen = (PyGenObject *)receiver; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type && @@ -1092,7 +1092,7 @@ TARGET(YIELD_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 790 "Python/bytecodes.c" + #line 791 "Python/bytecodes.c" // NOTE: It's important that YIELD_VALUE never raises an exception! // The compiler treats any exception raised here as a failed close() // or throw() call. @@ -1116,7 +1116,7 @@ TARGET(POP_EXCEPT) { PyObject *exc_value = stack_pointer[-1]; - #line 811 "Python/bytecodes.c" + #line 812 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; Py_XSETREF(exc_info->exc_value, exc_value); #line 1123 "Python/generated_cases.c.h" @@ -1127,7 +1127,7 @@ TARGET(RERAISE) { PyObject *exc = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); - #line 816 "Python/bytecodes.c" + #line 817 "Python/bytecodes.c" assert(oparg >= 0 && oparg <= 2); if (oparg) { PyObject *lasti = values[0]; @@ -1151,13 +1151,13 @@ TARGET(END_ASYNC_FOR) { PyObject *exc = stack_pointer[-1]; PyObject *awaitable = stack_pointer[-2]; - #line 836 "Python/bytecodes.c" + #line 837 "Python/bytecodes.c" assert(exc && PyExceptionInstance_Check(exc)); if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) { #line 1158 "Python/generated_cases.c.h" Py_DECREF(awaitable); Py_DECREF(exc); - #line 839 "Python/bytecodes.c" + #line 840 "Python/bytecodes.c" } else { Py_INCREF(exc); @@ -1175,7 +1175,7 @@ PyObject *sub_iter = stack_pointer[-3]; PyObject *none; PyObject *value; - #line 848 "Python/bytecodes.c" + #line 849 "Python/bytecodes.c" assert(throwflag); assert(exc_value && PyExceptionInstance_Check(exc_value)); if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) { @@ -1184,7 +1184,7 @@ Py_DECREF(sub_iter); Py_DECREF(last_sent_val); Py_DECREF(exc_value); - #line 853 "Python/bytecodes.c" + #line 854 "Python/bytecodes.c" none = Py_NewRef(Py_None); } else { @@ -1200,7 +1200,7 @@ TARGET(LOAD_ASSERTION_ERROR) { PyObject *value; - #line 862 "Python/bytecodes.c" + #line 863 "Python/bytecodes.c" value = Py_NewRef(PyExc_AssertionError); #line 1206 "Python/generated_cases.c.h" STACK_GROW(1); @@ -1210,7 +1210,7 @@ TARGET(LOAD_BUILD_CLASS) { PyObject *bc; - #line 866 "Python/bytecodes.c" + #line 867 "Python/bytecodes.c" if (PyDict_CheckExact(BUILTINS())) { bc = _PyDict_GetItemWithError(BUILTINS(), &_Py_ID(__build_class__)); @@ -1240,7 +1240,7 @@ TARGET(LOAD_LOCALS) { PyObject *locals; - #line 890 "Python/bytecodes.c" + #line 891 "Python/bytecodes.c" locals = LOCALS(); if (locals == NULL) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -1256,7 +1256,7 @@ TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 900 "Python/bytecodes.c" + #line 901 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1265,7 +1265,7 @@ "no locals found when storing %R", name); #line 1267 "Python/generated_cases.c.h" Py_DECREF(v); - #line 907 "Python/bytecodes.c" + #line 908 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) @@ -1274,7 +1274,7 @@ err = PyObject_SetItem(ns, name, v); #line 1276 "Python/generated_cases.c.h" Py_DECREF(v); - #line 914 "Python/bytecodes.c" + #line 915 "Python/bytecodes.c" if (err) goto pop_1_error; #line 1280 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -1282,7 +1282,7 @@ } TARGET(DELETE_NAME) { - #line 918 "Python/bytecodes.c" + #line 919 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1307,7 +1307,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 944 "Python/bytecodes.c" + #line 945 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1323,7 +1323,7 @@ int res = unpack_iterable(tstate, seq, oparg, -1, top); #line 1325 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 958 "Python/bytecodes.c" + #line 959 "Python/bytecodes.c" if (res == 0) goto pop_1_error; #line 1329 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -1335,7 +1335,7 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 962 "Python/bytecodes.c" + #line 963 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); @@ -1353,7 +1353,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 972 "Python/bytecodes.c" + #line 973 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1372,7 +1372,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 983 "Python/bytecodes.c" + #line 984 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1390,13 +1390,13 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 994 "Python/bytecodes.c" + #line 995 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); #line 1398 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 998 "Python/bytecodes.c" + #line 999 "Python/bytecodes.c" if (res == 0) goto pop_1_error; #line 1402 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); @@ -1409,7 +1409,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 1009 "Python/bytecodes.c" + #line 1010 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { assert(cframe.use_tracing == 0); @@ -1429,7 +1429,7 @@ #line 1430 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1026 "Python/bytecodes.c" + #line 1027 "Python/bytecodes.c" if (err) goto pop_2_error; #line 1435 "Python/generated_cases.c.h" STACK_SHRINK(2); @@ -1439,12 +1439,12 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1030 "Python/bytecodes.c" + #line 1031 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); #line 1446 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1033 "Python/bytecodes.c" + #line 1034 "Python/bytecodes.c" if (err) goto pop_1_error; #line 1450 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -1453,12 +1453,12 @@ TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1037 "Python/bytecodes.c" + #line 1038 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); #line 1460 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1040 "Python/bytecodes.c" + #line 1041 "Python/bytecodes.c" if (err) goto pop_1_error; #line 1464 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -1466,7 +1466,7 @@ } TARGET(DELETE_GLOBAL) { - #line 1044 "Python/bytecodes.c" + #line 1045 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1484,7 +1484,7 @@ TARGET(LOAD_CLASS_OR_GLOBAL) { PyObject *v; - #line 1058 "Python/bytecodes.c" + #line 1059 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = GETLOCAL(0); if (locals == NULL) { @@ -1551,7 +1551,7 @@ TARGET(LOAD_NAME) { PyObject *v; - #line 1119 "Python/bytecodes.c" + #line 1120 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = LOCALS(); if (locals == NULL) { @@ -1621,7 +1621,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1186 "Python/bytecodes.c" + #line 1187 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1688,7 +1688,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1241 "Python/bytecodes.c" + #line 1242 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); @@ -1715,7 +1715,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1255 "Python/bytecodes.c" + #line 1256 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); @@ -1740,7 +1740,7 @@ } TARGET(DELETE_FAST) { - #line 1272 "Python/bytecodes.c" + #line 1273 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); @@ -1749,7 +1749,7 @@ } TARGET(MAKE_CELL) { - #line 1278 "Python/bytecodes.c" + #line 1279 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1763,7 +1763,7 @@ } TARGET(DELETE_DEREF) { - #line 1289 "Python/bytecodes.c" + #line 1290 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1780,7 +1780,7 @@ TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1302 "Python/bytecodes.c" + #line 1303 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1820,7 +1820,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1336 "Python/bytecodes.c" + #line 1337 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1836,7 +1836,7 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1346 "Python/bytecodes.c" + #line 1347 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); @@ -1847,7 +1847,7 @@ } TARGET(COPY_FREE_VARS) { - #line 1353 "Python/bytecodes.c" + #line 1354 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1865,13 +1865,13 @@ TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1366 "Python/bytecodes.c" + #line 1367 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); #line 1871 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1368 "Python/bytecodes.c" + #line 1369 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } #line 1877 "Python/generated_cases.c.h" STACK_SHRINK(oparg); @@ -1883,7 +1883,7 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1372 "Python/bytecodes.c" + #line 1373 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } #line 1890 "Python/generated_cases.c.h" @@ -1896,7 +1896,7 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1377 "Python/bytecodes.c" + #line 1378 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } #line 1903 "Python/generated_cases.c.h" @@ -1909,7 +1909,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1382 "Python/bytecodes.c" + #line 1383 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -1922,7 +1922,7 @@ } #line 1924 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1393 "Python/bytecodes.c" + #line 1394 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); @@ -1935,11 +1935,11 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1400 "Python/bytecodes.c" + #line 1401 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); #line 1941 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1402 "Python/bytecodes.c" + #line 1403 "Python/bytecodes.c" if (err < 0) goto pop_1_error; #line 1945 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -1949,7 +1949,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1406 "Python/bytecodes.c" + #line 1407 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -1974,7 +1974,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1423 "Python/bytecodes.c" + #line 1424 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -1986,7 +1986,7 @@ for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1431 "Python/bytecodes.c" + #line 1432 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } #line 1992 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); @@ -1996,7 +1996,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1435 "Python/bytecodes.c" + #line 1436 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2044,7 +2044,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1477 "Python/bytecodes.c" + #line 1478 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2059,7 +2059,7 @@ Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1487 "Python/bytecodes.c" + #line 1488 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } #line 2065 "Python/generated_cases.c.h" STACK_SHRINK(oparg); @@ -2069,7 +2069,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1491 "Python/bytecodes.c" + #line 1492 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2079,7 +2079,7 @@ } #line 2081 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1499 "Python/bytecodes.c" + #line 1500 "Python/bytecodes.c" if (true) goto pop_1_error; } #line 2086 "Python/generated_cases.c.h" @@ -2090,14 +2090,14 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1505 "Python/bytecodes.c" + #line 1506 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); #line 2099 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1510 "Python/bytecodes.c" + #line 1511 "Python/bytecodes.c" if (true) goto pop_1_error; } #line 2104 "Python/generated_cases.c.h" @@ -2110,7 +2110,7 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1517 "Python/bytecodes.c" + #line 1518 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ @@ -2128,7 +2128,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1540 "Python/bytecodes.c" + #line 1541 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2165,7 +2165,7 @@ */ #line 2167 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1575 "Python/bytecodes.c" + #line 1576 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2176,7 +2176,7 @@ res = PyObject_GetAttr(owner, name); #line 2178 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1584 "Python/bytecodes.c" + #line 1585 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } #line 2183 "Python/generated_cases.c.h" @@ -2193,7 +2193,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1589 "Python/bytecodes.c" + #line 1590 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2222,7 +2222,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1606 "Python/bytecodes.c" + #line 1607 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; @@ -2251,7 +2251,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1623 "Python/bytecodes.c" + #line 1624 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2294,7 +2294,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1654 "Python/bytecodes.c" + #line 1655 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2320,7 +2320,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1668 "Python/bytecodes.c" + #line 1669 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); @@ -2347,7 +2347,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1684 "Python/bytecodes.c" + #line 1685 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); @@ -2379,7 +2379,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1710 "Python/bytecodes.c" + #line 1711 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2413,7 +2413,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1738 "Python/bytecodes.c" + #line 1739 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2443,7 +2443,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1759 "Python/bytecodes.c" + #line 1760 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2494,7 +2494,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1801 "Python/bytecodes.c" + #line 1802 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); @@ -2517,7 +2517,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1821 "Python/bytecodes.c" + #line 1822 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2534,7 +2534,7 @@ #line 2535 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1835 "Python/bytecodes.c" + #line 1836 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 2540 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2547,7 +2547,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1839 "Python/bytecodes.c" + #line 1840 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); @@ -2571,7 +2571,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1855 "Python/bytecodes.c" + #line 1856 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); @@ -2599,7 +2599,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1875 "Python/bytecodes.c" + #line 1876 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); @@ -2624,12 +2624,12 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1891 "Python/bytecodes.c" + #line 1892 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; #line 2630 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1893 "Python/bytecodes.c" + #line 1894 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); #line 2635 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2641,12 +2641,12 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1897 "Python/bytecodes.c" + #line 1898 "Python/bytecodes.c" int res = PySequence_Contains(right, left); #line 2647 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1899 "Python/bytecodes.c" + #line 1900 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); #line 2653 "Python/generated_cases.c.h" @@ -2660,12 +2660,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 1904 "Python/bytecodes.c" + #line 1905 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { #line 2666 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1906 "Python/bytecodes.c" + #line 1907 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2676,7 +2676,7 @@ #line 2677 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1914 "Python/bytecodes.c" + #line 1915 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2695,19 +2695,19 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1925 "Python/bytecodes.c" + #line 1926 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { #line 2702 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1928 "Python/bytecodes.c" + #line 1929 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); #line 2709 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1933 "Python/bytecodes.c" + #line 1934 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); #line 2713 "Python/generated_cases.c.h" stack_pointer[-1] = b; @@ -2718,13 +2718,13 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 1937 "Python/bytecodes.c" + #line 1938 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); #line 2725 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 1940 "Python/bytecodes.c" + #line 1941 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 2730 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2735,7 +2735,7 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 1944 "Python/bytecodes.c" + #line 1945 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; @@ -2746,7 +2746,7 @@ } TARGET(JUMP_FORWARD) { - #line 1950 "Python/bytecodes.c" + #line 1951 "Python/bytecodes.c" JUMPBY(oparg); #line 2752 "Python/generated_cases.c.h" DISPATCH(); @@ -2754,7 +2754,7 @@ TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 1954 "Python/bytecodes.c" + #line 1955 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); #line 2761 "Python/generated_cases.c.h" @@ -2765,7 +2765,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 1960 "Python/bytecodes.c" + #line 1961 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2777,7 +2777,7 @@ int err = PyObject_IsTrue(cond); #line 2779 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 1970 "Python/bytecodes.c" + #line 1971 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2792,7 +2792,7 @@ TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 1980 "Python/bytecodes.c" + #line 1981 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2804,7 +2804,7 @@ int err = PyObject_IsTrue(cond); #line 2806 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 1990 "Python/bytecodes.c" + #line 1991 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2819,11 +2819,11 @@ TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2000 "Python/bytecodes.c" + #line 2001 "Python/bytecodes.c" if (!Py_IsNone(value)) { #line 2825 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2002 "Python/bytecodes.c" + #line 2003 "Python/bytecodes.c" JUMPBY(oparg); } else { @@ -2836,7 +2836,7 @@ TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2010 "Python/bytecodes.c" + #line 2011 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); @@ -2844,7 +2844,7 @@ else { #line 2846 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2016 "Python/bytecodes.c" + #line 2017 "Python/bytecodes.c" } #line 2850 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2852,7 +2852,7 @@ } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2020 "Python/bytecodes.c" + #line 2021 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. @@ -2866,7 +2866,7 @@ TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2029 "Python/bytecodes.c" + #line 2030 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; @@ -2883,7 +2883,7 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2037 "Python/bytecodes.c" + #line 2038 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); @@ -2892,7 +2892,7 @@ Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2042 "Python/bytecodes.c" + #line 2043 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -2909,7 +2909,7 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2052 "Python/bytecodes.c" + #line 2053 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); #line 2916 "Python/generated_cases.c.h" @@ -2922,7 +2922,7 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2058 "Python/bytecodes.c" + #line 2059 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); #line 2929 "Python/generated_cases.c.h" @@ -2936,7 +2936,7 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2064 "Python/bytecodes.c" + #line 2065 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; @@ -2949,12 +2949,12 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2070 "Python/bytecodes.c" + #line 2071 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); #line 2956 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2073 "Python/bytecodes.c" + #line 2074 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; #line 2960 "Python/generated_cases.c.h" stack_pointer[-1] = iter; @@ -2964,7 +2964,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2077 "Python/bytecodes.c" + #line 2078 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -2989,7 +2989,7 @@ } #line 2991 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2100 "Python/bytecodes.c" + #line 2101 "Python/bytecodes.c" } #line 2995 "Python/generated_cases.c.h" stack_pointer[-1] = iter; @@ -3002,7 +3002,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2119 "Python/bytecodes.c" + #line 2120 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3045,7 +3045,7 @@ TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2154 "Python/bytecodes.c" + #line 2155 "Python/bytecodes.c" assert(cframe.use_tracing == 0); DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; @@ -3076,7 +3076,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2177 "Python/bytecodes.c" + #line 2178 "Python/bytecodes.c" assert(cframe.use_tracing == 0); _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); @@ -3107,7 +3107,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2200 "Python/bytecodes.c" + #line 2201 "Python/bytecodes.c" assert(cframe.use_tracing == 0); _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); @@ -3135,7 +3135,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2221 "Python/bytecodes.c" + #line 2222 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3157,7 +3157,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2238 "Python/bytecodes.c" + #line 2239 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3182,7 +3182,7 @@ } #line 3184 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2261 "Python/bytecodes.c" + #line 2262 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { @@ -3201,7 +3201,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2271 "Python/bytecodes.c" + #line 2272 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3229,7 +3229,7 @@ } #line 3231 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2297 "Python/bytecodes.c" + #line 2298 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { @@ -3248,7 +3248,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2306 "Python/bytecodes.c" + #line 2307 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3278,7 +3278,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2329 "Python/bytecodes.c" + #line 2330 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3302,7 +3302,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2341 "Python/bytecodes.c" + #line 2342 "Python/bytecodes.c" /* Cached method object */ assert(cframe.use_tracing == 0); PyTypeObject *self_cls = Py_TYPE(self); @@ -3334,7 +3334,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2361 "Python/bytecodes.c" + #line 2362 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3359,7 +3359,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2374 "Python/bytecodes.c" + #line 2375 "Python/bytecodes.c" assert(cframe.use_tracing == 0); PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); @@ -3383,7 +3383,7 @@ } TARGET(KW_NAMES) { - #line 2391 "Python/bytecodes.c" + #line 2392 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); @@ -3398,7 +3398,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2427 "Python/bytecodes.c" + #line 2428 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3482,7 +3482,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2505 "Python/bytecodes.c" + #line 2506 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3501,7 +3501,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2517 "Python/bytecodes.c" + #line 2518 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3534,7 +3534,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2544 "Python/bytecodes.c" + #line 2545 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3577,7 +3577,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2581 "Python/bytecodes.c" + #line 2582 "Python/bytecodes.c" assert(kwnames == NULL); assert(cframe.use_tracing == 0); assert(oparg == 1); @@ -3601,7 +3601,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2594 "Python/bytecodes.c" + #line 2595 "Python/bytecodes.c" assert(kwnames == NULL); assert(cframe.use_tracing == 0); assert(oparg == 1); @@ -3627,7 +3627,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2609 "Python/bytecodes.c" + #line 2610 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3652,7 +3652,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2623 "Python/bytecodes.c" + #line 2624 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3688,7 +3688,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2648 "Python/bytecodes.c" + #line 2649 "Python/bytecodes.c" assert(cframe.use_tracing == 0); /* Builtin METH_O functions */ assert(kwnames == NULL); @@ -3731,7 +3731,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2680 "Python/bytecodes.c" + #line 2681 "Python/bytecodes.c" assert(cframe.use_tracing == 0); /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); @@ -3778,7 +3778,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2716 "Python/bytecodes.c" + #line 2717 "Python/bytecodes.c" assert(cframe.use_tracing == 0); /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; @@ -3825,7 +3825,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2752 "Python/bytecodes.c" + #line 2753 "Python/bytecodes.c" assert(cframe.use_tracing == 0); assert(kwnames == NULL); /* len(o) */ @@ -3864,7 +3864,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2780 "Python/bytecodes.c" + #line 2781 "Python/bytecodes.c" assert(cframe.use_tracing == 0); assert(kwnames == NULL); /* isinstance(o, o2) */ @@ -3904,7 +3904,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2811 "Python/bytecodes.c" + #line 2812 "Python/bytecodes.c" assert(cframe.use_tracing == 0); assert(kwnames == NULL); assert(oparg == 1); @@ -3930,7 +3930,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2832 "Python/bytecodes.c" + #line 2833 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -3974,7 +3974,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2866 "Python/bytecodes.c" + #line 2867 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4016,7 +4016,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2898 "Python/bytecodes.c" + #line 2899 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4058,7 +4058,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2930 "Python/bytecodes.c" + #line 2931 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4101,7 +4101,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 2961 "Python/bytecodes.c" + #line 2962 "Python/bytecodes.c" if (oparg & 1) { // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. @@ -4124,7 +4124,7 @@ Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 2980 "Python/bytecodes.c" + #line 2981 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } @@ -4140,10 +4140,11 @@ PyObject *codeobj = stack_pointer[-1]; PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0))] : NULL; PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL; - PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; - PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; + PyObject *typevars = (oparg & 0x10) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0))] : NULL; + PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; + PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 2991 "Python/bytecodes.c" + #line 2993 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4153,6 +4154,10 @@ goto error; } + if (oparg & 0x10) { + assert(PyTuple_CheckExact(typevars)); + func_obj->func_typevars = typevars; + } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; @@ -4172,14 +4177,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4176 "Python/generated_cases.c.h" - STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); + #line 4181 "Python/generated_cases.c.h" + STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3022 "Python/bytecodes.c" + #line 3028 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4200,7 +4205,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4204 "Python/generated_cases.c.h" + #line 4209 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4208,15 +4213,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3045 "Python/bytecodes.c" + #line 3051 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4214 "Python/generated_cases.c.h" + #line 4219 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3047 "Python/bytecodes.c" + #line 3053 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4220 "Python/generated_cases.c.h" + #line 4225 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4227,7 +4232,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3051 "Python/bytecodes.c" + #line 3057 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4262,7 +4267,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4266 "Python/generated_cases.c.h" + #line 4271 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4271,10 +4276,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3088 "Python/bytecodes.c" + #line 3094 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4278 "Python/generated_cases.c.h" + #line 4283 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4286,7 +4291,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3093 "Python/bytecodes.c" + #line 3099 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4302,12 +4307,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4306 "Python/generated_cases.c.h" + #line 4311 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3109 "Python/bytecodes.c" + #line 3115 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4311 "Python/generated_cases.c.h" + #line 4316 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4317,27 +4322,27 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3114 "Python/bytecodes.c" + #line 3120 "Python/bytecodes.c" assert(oparg >= 2); - #line 4323 "Python/generated_cases.c.h" + #line 4328 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3118 "Python/bytecodes.c" + #line 3124 "Python/bytecodes.c" assert(oparg); assert(cframe.use_tracing == 0); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4337 "Python/generated_cases.c.h" + #line 4342 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3127 "Python/bytecodes.c" + #line 3133 "Python/bytecodes.c" Py_UNREACHABLE(); - #line 4343 "Python/generated_cases.c.h" + #line 4348 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 09011e4f76c70e..e5f56282584605 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -332,7 +332,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case CALL_FUNCTION_EX: return ((oparg & 1) ? 1 : 0) + 3; case MAKE_FUNCTION: - return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1; + return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1; case RETURN_GENERATOR: return 0; case BUILD_SLICE: diff --git a/Python/symtable.c b/Python/symtable.c index c69af8eb6d9fc6..b7acfa27407470 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1326,6 +1326,12 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); tmp = st->st_private; st->st_private = s->v.ClassDef.name; + if (s->v.ClassDef.typeparams) { + if (!symtable_add_def(st, &_Py_ID(__type_variables__), + DEF_LOCAL, LOCATION(s))) { + VISIT_QUIT(st, 0); + } + } VISIT_SEQ(st, stmt, s->v.ClassDef.body); st->st_private = tmp; if (!symtable_exit_block(st)) From c0b04e3b5fafb7c29ebcf6112ae61d446b2f8b17 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 09:55:58 -0600 Subject: [PATCH 044/200] Generic work --- Include/internal/pycore_intrinsics.h | 1 + Include/internal/pycore_typevarobject.h | 2 + Lib/typing.py | 87 +++++++++++++++++++ Objects/typevarobject.c | 109 ++++++++++++++++++++++++ Python/bltinmodule.c | 1 + Python/intrinsics.c | 7 ++ Python/symtable.c | 17 ++++ 7 files changed, 224 insertions(+) diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index a653fdba19c1dc..11e4a1a7240c89 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -10,6 +10,7 @@ #define INTRINSIC_TYPEVAR 7 #define INTRINSIC_PARAMSPEC 8 #define INTRINSIC_TYPEVARTUPLE 9 +#define INTRINSIC_SUBSCRIPT_GENERIC 10 #define MAX_INTRINSIC_1 9 diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index 85a1698b9cbd45..1c2898cc15ffcb 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -13,10 +13,12 @@ extern PyTypeObject _PyTypeVarTuple_Type; extern PyTypeObject _PyParamSpec_Type; extern PyTypeObject _PyParamSpecArgs_Type; extern PyTypeObject _PyParamSpecKwargs_Type; +extern PyTypeObject _PyGeneric_Type; extern PyObject *_Py_make_typevar(const char *, PyObject *); extern PyObject *_Py_make_paramspec(const char *); extern PyObject *_Py_make_typevartuple(const char *); +extern PyObject *_Py_subscript_generic(PyObject *); #ifdef __cplusplus } diff --git a/Lib/typing.py b/Lib/typing.py index c274167e45c88a..8c6f7f35bbb1b0 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1969,6 +1969,93 @@ def __init_subclass__(cls, *args, **kwargs): cls.__parameters__ = tuple(tvars) +@_tp_cache +def _generic_class_getitem(cls, params): + """Parameterizes a generic class. + + At least, parameterizing a generic class is the *main* thing this method + does. For example, for some generic class `Foo`, this is called when we + do `Foo[int]` - there, with `cls=Foo` and `params=int`. + + However, note that this method is also called when defining generic + classes in the first place with `class Foo(Generic[T]): ...`. + """ + if not isinstance(params, tuple): + params = (params,) + + params = tuple(_type_convert(p) for p in params) + if cls in (builtins.Generic, Protocol): + # Generic and Protocol can only be subscripted with unique type variables. + if not params: + raise TypeError( + f"Parameter list to {cls.__qualname__}[...] cannot be empty" + ) + if not all(_is_typevar_like(p) for p in params): + raise TypeError( + f"Parameters to {cls.__name__}[...] must all be type variables " + f"or parameter specification variables.") + if len(set(params)) != len(params): + raise TypeError( + f"Parameters to {cls.__name__}[...] must all be unique") + else: + # Subscripting a regular Generic subclass. + for param in cls.__parameters__: + prepare = getattr(param, '__typing_prepare_subst__', None) + if prepare is not None: + params = prepare(cls, params) + _check_generic(cls, params, len(cls.__parameters__)) + + new_args = [] + for param, new_arg in zip(cls.__parameters__, params): + if isinstance(param, TypeVarTuple): + new_args.extend(new_arg) + else: + new_args.append(new_arg) + params = tuple(new_args) + + return _GenericAlias(cls, params, + _paramspec_tvars=True) + +import builtins + +def _generic_init_subclass(cls, *args, **kwargs): + super(builtins.Generic, cls).__init_subclass__(*args, **kwargs) + tvars = [] + if '__orig_bases__' in cls.__dict__: + error = builtins.Generic in cls.__orig_bases__ + else: + error = (builtins.Generic in cls.__bases__ and + cls.__name__ != 'Protocol' and + type(cls) != _TypedDictMeta) + if error: + raise TypeError("Cannot inherit from plain Generic") + if '__orig_bases__' in cls.__dict__: + tvars = _collect_parameters(cls.__orig_bases__) + # Look for Generic[T1, ..., Tn]. + # If found, tvars must be a subset of it. + # If not found, tvars is it. + # Also check for and reject plain Generic, + # and reject multiple Generic[...]. + gvars = None + for base in cls.__orig_bases__: + if (isinstance(base, _GenericAlias) and + base.__origin__ is builtins.Generic): + if gvars is not None: + raise TypeError( + "Cannot inherit from Generic[...] multiple types.") + gvars = base.__parameters__ + if gvars is not None: + tvarset = set(tvars) + gvarset = set(gvars) + if not tvarset <= gvarset: + s_vars = ', '.join(str(t) for t in tvars if t not in gvarset) + s_args = ', '.join(str(g) for g in gvars) + raise TypeError(f"Some type variables ({s_vars}) are" + f" not listed in Generic[{s_args}]") + tvars = gvars + cls.__parameters__ = tuple(tvars) + + class _TypingEllipsis: """Internal placeholder for ... (ellipsis).""" diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 1175c927fbf3c5..1bfb3787a7efe2 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -11,6 +11,7 @@ class paramspec "paramspecobject *" "&_PyParamSpec_Type" class paramspecargs "paramspecargsobject *" "&_PyParamSpecArgs_Type" class paramspeckwargs "paramspeckwargsobject *" "&_PyParamSpecKwargs_Type" class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" +class Generic "PyObject *" "&PyGeneric_Type [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=74cb9c15a049111b]*/ @@ -821,3 +822,111 @@ PyObject *_Py_make_paramspec(const char *name) { PyObject *_Py_make_typevartuple(const char *name) { return (PyObject *)typevartupleobject_alloc(name); } + +PyDoc_STRVAR(generic_doc, +"Abstract base class for generic types.\n\ +\n\ +A generic type is typically declared by inheriting from\n\ +this class parameterized with one or more type variables.\n\ +For example, a generic mapping type might be defined as::\n\ +\n\ + class Mapping(Generic[KT, VT]):\n\ + def __getitem__(self, key: KT) -> VT:\n\ + ...\n\ + # Etc.\n\ +\n\ +This class can then be used as follows::\n\ +\n\ + def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:\n\ + try:\n\ + return mapping[key]\n\ + except KeyError:\n\ + return default\n\ +"); + +PyDoc_STRVAR(generic_class_getitem_doc, +"Parameterizes a generic class.\n\ +\n\ +At least, parameterizing a generic class is the *main* thing this method\n\ +does. For example, for some generic class `Foo`, this is called when we\n\ +do `Foo[int]` - there, with `cls=Foo` and `params=int`.\n\ +\n\ +However, note that this method is also called when defining generic\n\ +classes in the first place with `class Foo(Generic[T]): ...`.\n\ +"); + +static PyObject * +call_typing_args_kwargs(const char *name, PyTypeObject *cls, PyObject *args, PyObject *kwargs) +{ + PyObject *typing = NULL, *func = NULL, *new_args = NULL; + typing = PyImport_ImportModule("typing"); + if (typing == NULL) { + goto error; + } + func = PyObject_GetAttrString(typing, name); + if (func == NULL) { + goto error; + } + assert(PyTuple_Check(args)); + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + new_args = PyTuple_New(nargs + 1); + if (new_args == NULL) { + goto error; + } + PyTuple_SET_ITEM(new_args, 0, Py_NewRef((PyObject *)cls)); + for (Py_ssize_t i = 0; i < nargs; i++) { + PyObject *arg = PyTuple_GET_ITEM(args, i); + PyTuple_SET_ITEM(new_args, i + 1, Py_NewRef(arg)); + } + PyObject *result = PyObject_Call(func, new_args, kwargs); + Py_DECREF(func); + Py_DECREF(typing); + Py_DecRef(new_args); + return result; +error: + Py_XDECREF(typing); + Py_XDECREF(func); + Py_XDECREF(new_args); + return NULL; +} + +static PyObject * +generic_init_subclass(PyTypeObject *cls, PyObject *args, PyObject *kwargs) +{ + return call_typing_args_kwargs("_generic_init_subclass", cls, args, kwargs); +} + +static PyObject * +generic_class_getitem(PyTypeObject *cls, PyObject *args, PyObject *kwargs) +{ + return call_typing_args_kwargs("_generic_class_getitem", cls, args, kwargs); +} + +PyObject * +_Py_subscript_generic(PyObject *params) +{ + PyObject *args = PyTuple_Pack(2, &_PyGeneric_Type, params); + if (args == NULL) { + return NULL; + } + return call_typing_func_object("_generic_class_getitem", args); +} + +static PyMethodDef generic_methods[] = { + {"__class_getitem__", (PyCFunction)(void (*)(void))generic_class_getitem, + METH_VARARGS | METH_KEYWORDS | METH_CLASS, + generic_class_getitem_doc}, + {"__init_subclass__", (PyCFunction)(void (*)(void))generic_init_subclass, + METH_VARARGS | METH_KEYWORDS | METH_CLASS, + PyDoc_STR("Function to initialize subclasses.")}, + {NULL} /* Sentinel */ +}; + +PyTypeObject _PyGeneric_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "typing.Generic", + .tp_basicsize = sizeof(PyObject), + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_doc = generic_doc, + .tp_methods = generic_methods, +}; diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 3eb2b04e52972f..acf7f8d8a1bcf4 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3096,6 +3096,7 @@ _PyBuiltin_Init(PyInterpreterState *interp) SETBUILTIN("TypeVar", &_PyTypeVar_Type); SETBUILTIN("TypeVarTuple", &_PyTypeVarTuple_Type); SETBUILTIN("ParamSpec", &_PyParamSpec_Type); + SETBUILTIN("Generic", &_PyGeneric_Type); debug = PyBool_FromLong(config->optimization_level == 0); if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { Py_DECREF(debug); diff --git a/Python/intrinsics.c b/Python/intrinsics.c index d435d6d59fa666..fa76da47b9c71e 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -221,6 +221,12 @@ make_typevartuple(PyThreadState* unused, PyObject *v) return _Py_make_typevartuple(PyUnicode_AsUTF8(v)); } +static PyObject * +subscript_generic(PyThreadState* unused, PyObject *v) +{ + return _Py_subscript_generic(v); +} + const instrinsic_func1 _PyIntrinsics_UnaryFunctions[] = { [0] = no_intrinsic, @@ -233,6 +239,7 @@ _PyIntrinsics_UnaryFunctions[] = { [INTRINSIC_TYPEVAR] = make_typevar, [INTRINSIC_PARAMSPEC] = make_paramspec, [INTRINSIC_TYPEVARTUPLE] = make_typevartuple, + [INTRINSIC_SUBSCRIPT_GENERIC] = subscript_generic, }; diff --git a/Python/symtable.c b/Python/symtable.c index b7acfa27407470..d242cdd2e10798 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1331,6 +1331,23 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) DEF_LOCAL, LOCATION(s))) { VISIT_QUIT(st, 0); } + for (Py_ssize_t i = 0; i < asdl_seq_LEN(s->v.ClassDef.typeparams); i++) { + typeparam_ty tp = asdl_seq_GET(s->v.ClassDef.typeparams, i); + PyObject *name; + switch (tp->kind) { + case TypeVar_kind: + name = tp->v.TypeVar.name; + break; + case ParamSpec_kind: + name = tp->v.ParamSpec.name; + break; + case TypeVarTuple_kind: + name = tp->v.TypeVarTuple.name; + break; + } + if (!symtable_add_def(st, name, USE, LOCATION(s))) + VISIT_QUIT(st, 0); + } } VISIT_SEQ(st, stmt, s->v.ClassDef.body); st->st_private = tmp; From 59e6fa017adeb6526892773283f1cfdaf4a8592e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 10:58:25 -0600 Subject: [PATCH 045/200] Use _Py_DECLARE_STR --- .../pycore_global_objects_fini_generated.h | 4 ++- Include/internal/pycore_global_strings.h | 4 ++- .../internal/pycore_runtime_init_generated.h | 4 ++- .../internal/pycore_unicodeobject_generated.h | 3 -- Python/symtable.c | 32 ++++++------------- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 267a2792e3e2cc..654dbb0f92e8ae 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -557,11 +557,14 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_close_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_open_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_percent)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(defaults)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot_locals)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(empty)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(json_decoder)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(kwdefaults)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(list_err)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(namespace)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(newline)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(open_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(percent)); @@ -1129,7 +1132,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reducer_override)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(registry)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(rel_tol)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(release)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reload)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(repl)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(replace)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 359a18a3c97656..09021b7ac9e057 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -40,11 +40,14 @@ struct _Py_global_strings { STRUCT_FOR_STR(dbl_close_br, "}}") STRUCT_FOR_STR(dbl_open_br, "{{") STRUCT_FOR_STR(dbl_percent, "%%") + STRUCT_FOR_STR(defaults, ".defaults") STRUCT_FOR_STR(dot, ".") STRUCT_FOR_STR(dot_locals, ".") STRUCT_FOR_STR(empty, "") STRUCT_FOR_STR(json_decoder, "json.decoder") + STRUCT_FOR_STR(kwdefaults, ".kwdefaults") STRUCT_FOR_STR(list_err, "list index out of range") + STRUCT_FOR_STR(namespace, ".namespace") STRUCT_FOR_STR(newline, "\n") STRUCT_FOR_STR(open_br, "{") STRUCT_FOR_STR(percent, "%") @@ -615,7 +618,6 @@ struct _Py_global_strings { STRUCT_FOR_ID(reducer_override) STRUCT_FOR_ID(registry) STRUCT_FOR_ID(rel_tol) - STRUCT_FOR_ID(release) STRUCT_FOR_ID(reload) STRUCT_FOR_ID(repl) STRUCT_FOR_ID(replace) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 375f206b04871c..ed0f2d7236836d 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -546,11 +546,14 @@ extern "C" { INIT_STR(dbl_close_br, "}}"), \ INIT_STR(dbl_open_br, "{{"), \ INIT_STR(dbl_percent, "%%"), \ + INIT_STR(defaults, ".defaults"), \ INIT_STR(dot, "."), \ INIT_STR(dot_locals, "."), \ INIT_STR(empty, ""), \ INIT_STR(json_decoder, "json.decoder"), \ + INIT_STR(kwdefaults, ".kwdefaults"), \ INIT_STR(list_err, "list index out of range"), \ + INIT_STR(namespace, ".namespace"), \ INIT_STR(newline, "\n"), \ INIT_STR(open_br, "{"), \ INIT_STR(percent, "%"), \ @@ -1121,7 +1124,6 @@ extern "C" { INIT_ID(reducer_override), \ INIT_ID(registry), \ INIT_ID(rel_tol), \ - INIT_ID(release), \ INIT_ID(reload), \ INIT_ID(repl), \ INIT_ID(replace), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 3ef42073c19bd4..c277982fe3ba09 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1698,9 +1698,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(rel_tol); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); - string = &_Py_ID(release); - assert(_PyUnicode_CheckConsistency(string, 1)); - _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(reload); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Python/symtable.c b/Python/symtable.c index d242cdd2e10798..c93dc859b62674 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1123,23 +1123,6 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag, lineno, col_offset, end_lineno, end_col_offset); } -static int -symtable_add_param(const char *name, struct symtable *st, - int lineno, int col_offset, int end_lineno, int end_col_offset) -{ - PyObject *name_obj = PyUnicode_FromString(name); - if (name_obj == NULL) { - return 0; - } - if (!symtable_add_def(st, name_obj, DEF_PARAM, - lineno, col_offset, end_lineno, end_col_offset)) { - Py_DECREF(name_obj); - return 0; - } - Py_DECREF(name_obj); - return 1; -} - static int symtable_enter_typeparam_block(struct symtable *st, identifier name, void *ast, int has_defaults, int has_kwdefaults, @@ -1153,20 +1136,23 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, } if (current_type == ClassBlock) { st->st_cur->ste_type_params_in_class = 1; - if (!symtable_add_param(".namespace", st, - lineno, col_offset, end_lineno, end_col_offset)) { + _Py_DECLARE_STR(namespace, ".namespace"); + if (!symtable_add_def(st, &_Py_STR(namespace), DEF_PARAM, + lineno, col_offset, end_lineno, end_col_offset)) { return 0; } } if (has_defaults) { - if (!symtable_add_param(".defaults", st, - lineno, col_offset, end_lineno, end_col_offset)) { + _Py_DECLARE_STR(defaults, ".defaults"); + if (!symtable_add_def(st, &_Py_STR(defaults), DEF_PARAM, + lineno, col_offset, end_lineno, end_col_offset)) { return 0; } } if (has_kwdefaults) { - if (!symtable_add_param(".kwdefaults", st, - lineno, col_offset, end_lineno, end_col_offset)) { + _Py_DECLARE_STR(kwdefaults, ".kwdefaults"); + if (!symtable_add_def(st, &_Py_STR(kwdefaults), DEF_PARAM, + lineno, col_offset, end_lineno, end_col_offset)) { return 0; } } From 5521c7d3be1770b2fa11eb9ca412e5a02cea625b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 13:18:13 -0600 Subject: [PATCH 046/200] Support inheriting from Generic --- .../pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + Include/internal/pycore_intrinsics.h | 2 +- .../internal/pycore_runtime_init_generated.h | 1 + Python/compile.c | 40 ++++++++++++++----- Python/symtable.c | 18 ++++++++- 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 654dbb0f92e8ae..17bf306258b34e 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -569,6 +569,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(open_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(percent)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(shim_name)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(type_params)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(utf_8)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(CANCELLED)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(FINISHED)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 09021b7ac9e057..f1ef1bdb861732 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -52,6 +52,7 @@ struct _Py_global_strings { STRUCT_FOR_STR(open_br, "{") STRUCT_FOR_STR(percent, "%") STRUCT_FOR_STR(shim_name, "") + STRUCT_FOR_STR(type_params, ".type_params") STRUCT_FOR_STR(utf_8, "utf-8") } literals; diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index 11e4a1a7240c89..5918067fd3aaf7 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -12,7 +12,7 @@ #define INTRINSIC_TYPEVARTUPLE 9 #define INTRINSIC_SUBSCRIPT_GENERIC 10 -#define MAX_INTRINSIC_1 9 +#define MAX_INTRINSIC_1 10 /* Binary Functions: */ diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index ed0f2d7236836d..eb7e444f250e01 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -558,6 +558,7 @@ extern "C" { INIT_STR(open_br, "{"), \ INIT_STR(percent, "%"), \ INIT_STR(shim_name, ""), \ + INIT_STR(type_params, ".type_params"), \ INIT_STR(utf_8, "utf-8"), \ } diff --git a/Python/compile.c b/Python/compile.c index 33d4e5c1cbfecf..98490aeec91773 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -544,7 +544,8 @@ static int compiler_call_simple_kw_helper(struct compiler *c, Py_ssize_t nkwelts); static int compiler_call_helper(struct compiler *c, location loc, int n, asdl_expr_seq *args, - asdl_keyword_seq *keywords); + asdl_keyword_seq *keywords, + PyObject *extra_positional_arg); static int compiler_try_except(struct compiler *, stmt_ty); static int compiler_try_star_except(struct compiler *, stmt_ty); static int compiler_set_qualname(struct compiler *); @@ -2361,7 +2362,9 @@ compiler_class(struct compiler *c, stmt_ty s) } Py_DECREF(typeparams_name); RETURN_IF_ERROR(compiler_type_params(c, typeparams)); - ADDOP(c, loc, POP_TOP); + _Py_DECLARE_STR(type_params, ".type_params"); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Store)); + //ADDOP(c, loc, POP_TOP); } /* ultimately generate code for: @@ -2452,11 +2455,14 @@ compiler_class(struct compiler *c, stmt_ty s) ADDOP_LOAD_CONST(c, loc, s->v.ClassDef.name); /* 5. generate the rest of the code for the call */ - RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, - s->v.ClassDef.bases, - s->v.ClassDef.keywords)); if (typeparams) { + _Py_DECLARE_STR(type_params, ".type_params"); + RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, + s->v.ClassDef.bases, + s->v.ClassDef.keywords, + &_Py_STR(type_params))); + int is_in_class = c->u->u_ste->ste_type_params_in_class; c->u->u_argcount = is_in_class; PyCodeObject *co = assemble(c, 0); @@ -2473,6 +2479,11 @@ compiler_class(struct compiler *c, stmt_ty s) ADDOP(c, loc, LOAD_LOCALS); } ADDOP_I(c, loc, CALL, is_in_class); + } else { + RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, + s->v.ClassDef.bases, + s->v.ClassDef.keywords, + NULL)); } /* 6. apply decorators */ @@ -4575,7 +4586,8 @@ compiler_call(struct compiler *c, expr_ty e) loc = LOC(e); return compiler_call_helper(c, loc, 0, e->v.Call.args, - e->v.Call.keywords); + e->v.Call.keywords, + NULL); } static int @@ -4725,16 +4737,18 @@ static int compiler_call_helper(struct compiler *c, location loc, int n, /* Args already pushed */ asdl_expr_seq *args, - asdl_keyword_seq *keywords) + asdl_keyword_seq *keywords, + PyObject *extra_positional_arg) { - Py_ssize_t i, nseen, nelts, nkwelts; + Py_ssize_t i, nseen, nelts, nkwelts, real_nelts; RETURN_IF_ERROR(validate_keywords(c, keywords)); nelts = asdl_seq_LEN(args); nkwelts = asdl_seq_LEN(keywords); + real_nelts = extra_positional_arg == NULL ? nelts : nelts + 1; - if (nelts + nkwelts*2 > STACK_USE_GUIDELINE) { + if (real_nelts + nkwelts*2 > STACK_USE_GUIDELINE) { goto ex_call; } for (i = 0; i < nelts; i++) { @@ -4756,16 +4770,22 @@ compiler_call_helper(struct compiler *c, location loc, assert(elt->kind != Starred_kind); VISIT(c, expr, elt); } + if (extra_positional_arg != NULL) { + RETURN_IF_ERROR(compiler_nameop(c, loc, extra_positional_arg, Load)); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC); + } if (nkwelts) { VISIT_SEQ(c, keyword, keywords); RETURN_IF_ERROR( compiler_call_simple_kw_helper(c, loc, keywords, nkwelts)); } - ADDOP_I(c, loc, CALL, n + nelts + nkwelts); + ADDOP_I(c, loc, CALL, n + real_nelts + nkwelts); return SUCCESS; ex_call: + assert(extra_positional_arg == NULL); // TODO(PEP 695) + /* Do positional arguments. */ if (n ==0 && nelts == 1 && ((expr_ty)asdl_seq_GET(args, 0))->kind == Starred_kind) { VISIT(c, expr, ((expr_ty)asdl_seq_GET(args, 0))->v.Starred.value); diff --git a/Python/symtable.c b/Python/symtable.c index c93dc859b62674..098a3a83e054b0 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1126,6 +1126,7 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag, static int symtable_enter_typeparam_block(struct symtable *st, identifier name, void *ast, int has_defaults, int has_kwdefaults, + int is_class, int lineno, int col_offset, int end_lineno, int end_col_offset) { @@ -1142,6 +1143,19 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, return 0; } } + if (is_class) { + _Py_DECLARE_STR(type_params, ".type_params"); + // It gets "set" when we create the type params tuple and + // "used" when we build up the bases. + if (!symtable_add_def(st, &_Py_STR(type_params), DEF_LOCAL, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + if (!symtable_add_def(st, &_Py_STR(type_params), USE, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + } if (has_defaults) { _Py_DECLARE_STR(defaults, ".defaults"); if (!symtable_add_def(st, &_Py_STR(defaults), DEF_PARAM, @@ -1267,6 +1281,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) s->v.FunctionDef.args->defaults != NULL, has_kwonlydefaults(s->v.FunctionDef.args->kwonlyargs, s->v.FunctionDef.args->kw_defaults), + false, LOCATION(s))) { VISIT_QUIT(st, 0); } @@ -1298,7 +1313,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (s->v.ClassDef.typeparams) { if (!symtable_enter_typeparam_block(st, s->v.ClassDef.name, (void *)s->v.ClassDef.typeparams, - false, false, + false, false, true, LOCATION(s))) { VISIT_QUIT(st, 0); } @@ -1558,6 +1573,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) st, s->v.AsyncFunctionDef.name, (void *)s->v.AsyncFunctionDef.typeparams, s->v.AsyncFunctionDef.args->defaults != NULL, + false, has_kwonlydefaults(s->v.AsyncFunctionDef.args->kwonlyargs, s->v.AsyncFunctionDef.args->kw_defaults), LOCATION(s))) { From b9d8fbb0ab9f367f0bbfd54ad9ea408d09efa5db Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 13:29:32 -0600 Subject: [PATCH 047/200] Fix up qualnames --- Python/compile.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 98490aeec91773..4e720374a5dc05 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -196,6 +196,7 @@ enum { COMPILER_SCOPE_ASYNC_FUNCTION, COMPILER_SCOPE_LAMBDA, COMPILER_SCOPE_COMPREHENSION, + COMPILER_SCOPE_TYPEPARAMS, }; typedef struct { @@ -780,6 +781,19 @@ compiler_set_qualname(struct compiler *c) capsule = PyList_GET_ITEM(c->c_stack, stack_size - 1); parent = (struct compiler_unit *)PyCapsule_GetPointer(capsule, CAPSULE_NAME); assert(parent); + if (parent->u_scope_type == COMPILER_SCOPE_TYPEPARAMS) { + /* The parent is a type parameter scope, so we need to + look at the grandparent. */ + if (stack_size == 2) { + // If we're immediately within the module, we can skip + // the rest and just set the qualname to be the same as name. + u->u_qualname = Py_NewRef(u->u_name); + return SUCCESS; + } + capsule = PyList_GET_ITEM(c->c_stack, stack_size - 2); + parent = (struct compiler_unit *)PyCapsule_GetPointer(capsule, CAPSULE_NAME); + assert(parent); + } if (u->u_scope_type == COMPILER_SCOPE_FUNCTION || u->u_scope_type == COMPILER_SCOPE_ASYNC_FUNCTION @@ -2242,7 +2256,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) if (!typeparams_name) { return ERROR; } - if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_FUNCTION, + if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_TYPEPARAMS, (void *)typeparams, firstlineno) == -1) { Py_DECREF(typeparams_name); return ERROR; @@ -2355,7 +2369,7 @@ compiler_class(struct compiler *c, stmt_ty s) if (!typeparams_name) { return ERROR; } - if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_FUNCTION, + if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_TYPEPARAMS, (void *)typeparams, firstlineno) == -1) { Py_DECREF(typeparams_name); return ERROR; From f3340c2618e3dff6a9d687165ecd292be62191c3 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 13:44:02 -0600 Subject: [PATCH 048/200] Update the magic number, rearrange typing.py accordingly --- Lib/importlib/_bootstrap_external.py | 3 +- Lib/typing.py | 209 ++++++++++++++------------- Objects/typevarobject.c | 4 +- 3 files changed, 110 insertions(+), 106 deletions(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index de6c434450fc82..1dd823861a8db0 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -439,6 +439,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.12a7 3523 (Convert COMPARE_AND_BRANCH back to COMPARE_OP) # Python 3.12a7 3524 (Shrink the BINARY_SUBSCR caches) # Python 3.12b1 3525 (Shrink the CALL caches) +# Python 3.12b1 3526 (Add new instructions for PEP 695) # Python 3.13 will start with 3550 @@ -455,7 +456,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3525).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3526).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c diff --git a/Lib/typing.py b/Lib/typing.py index 8c6f7f35bbb1b0..7ac4badfe42f6e 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -918,7 +918,8 @@ def _is_unpacked_typevartuple(x: Any) -> bool: def _is_typevar_like(x: Any) -> bool: - return isinstance(x, (TypeVar, ParamSpec)) or _is_unpacked_typevartuple(x) + # TODO(PEP 695): remove TypeVarTuple here + return isinstance(x, (TypeVar, ParamSpec, TypeVarTuple)) or _is_unpacked_typevartuple(x) class _PickleUsingNameMixin: @@ -1301,29 +1302,93 @@ def __typing_prepare_subst__(self, alias, args): import builtins -if hasattr(builtins, "TypeVar"): - class _Dummy[T, *Ts, **P]: - type_params = (T, Ts, P) - TypeVar = type(_Dummy.type_params[0]) - TypeVarTuple = type(_Dummy.type_params[1]) - ParamSpec = type(_Dummy.type_params[2]) - ParamSpecArgs = type(ParamSpec("P").args) - ParamSpecKwargs = type(ParamSpec("P").kwargs) - del _Dummy +@_tp_cache +def _generic_class_getitem(cls, params): + """Parameterizes a generic class. - import copyreg + At least, parameterizing a generic class is the *main* thing this method + does. For example, for some generic class `Foo`, this is called when we + do `Foo[int]` - there, with `cls=Foo` and `params=int`. - def _pickle_psargs(psargs): - return ParamSpecArgs, (psargs.__origin__,) + However, note that this method is also called when defining generic + classes in the first place with `class Foo(Generic[T]): ...`. + """ + if not isinstance(params, tuple): + params = (params,) - copyreg.pickle(ParamSpecArgs, _pickle_psargs) + params = tuple(_type_convert(p) for p in params) + if cls in (builtins.Generic, Protocol): + # Generic and Protocol can only be subscripted with unique type variables. + if not params: + raise TypeError( + f"Parameter list to {cls.__qualname__}[...] cannot be empty" + ) + if not all(_is_typevar_like(p) for p in params): + raise TypeError( + f"Parameters to {cls.__name__}[...] must all be type variables " + f"or parameter specification variables.") + if len(set(params)) != len(params): + raise TypeError( + f"Parameters to {cls.__name__}[...] must all be unique") + else: + # Subscripting a regular Generic subclass. + for param in cls.__parameters__: + prepare = getattr(param, '__typing_prepare_subst__', None) + if prepare is not None: + params = prepare(cls, params) + _check_generic(cls, params, len(cls.__parameters__)) - def _pickle_pskwargs(pskwargs): - return ParamSpecKwargs, (pskwargs.__origin__,) + new_args = [] + for param, new_arg in zip(cls.__parameters__, params): + if isinstance(param, TypeVarTuple): + new_args.extend(new_arg) + else: + new_args.append(new_arg) + params = tuple(new_args) + + return _GenericAlias(cls, params, + _paramspec_tvars=True) + + +def _generic_init_subclass(cls, *args, **kwargs): + super(builtins.Generic, cls).__init_subclass__(*args, **kwargs) + tvars = [] + if '__orig_bases__' in cls.__dict__: + error = builtins.Generic in cls.__orig_bases__ + else: + error = (builtins.Generic in cls.__bases__ and + cls.__name__ != 'Protocol' and + type(cls) != _TypedDictMeta) + if error: + raise TypeError("Cannot inherit from plain Generic") + if '__orig_bases__' in cls.__dict__: + tvars = _collect_parameters(cls.__orig_bases__) + # Look for Generic[T1, ..., Tn]. + # If found, tvars must be a subset of it. + # If not found, tvars is it. + # Also check for and reject plain Generic, + # and reject multiple Generic[...]. + gvars = None + for base in cls.__orig_bases__: + if (isinstance(base, _GenericAlias) and + base.__origin__ is builtins.Generic): + if gvars is not None: + raise TypeError( + "Cannot inherit from Generic[...] multiple types.") + gvars = base.__parameters__ + if gvars is not None: + tvarset = set(tvars) + gvarset = set(gvars) + if not tvarset <= gvarset: + s_vars = ', '.join(str(t) for t in tvars if t not in gvarset) + s_args = ', '.join(str(g) for g in gvars) + raise TypeError(f"Some type variables ({s_vars}) are" + f" not listed in Generic[{s_args}]") + tvars = gvars + cls.__parameters__ = tuple(tvars) - copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) def _is_dunder(attr): return attr.startswith('__') and attr.endswith('__') @@ -1969,92 +2034,6 @@ def __init_subclass__(cls, *args, **kwargs): cls.__parameters__ = tuple(tvars) -@_tp_cache -def _generic_class_getitem(cls, params): - """Parameterizes a generic class. - - At least, parameterizing a generic class is the *main* thing this method - does. For example, for some generic class `Foo`, this is called when we - do `Foo[int]` - there, with `cls=Foo` and `params=int`. - - However, note that this method is also called when defining generic - classes in the first place with `class Foo(Generic[T]): ...`. - """ - if not isinstance(params, tuple): - params = (params,) - - params = tuple(_type_convert(p) for p in params) - if cls in (builtins.Generic, Protocol): - # Generic and Protocol can only be subscripted with unique type variables. - if not params: - raise TypeError( - f"Parameter list to {cls.__qualname__}[...] cannot be empty" - ) - if not all(_is_typevar_like(p) for p in params): - raise TypeError( - f"Parameters to {cls.__name__}[...] must all be type variables " - f"or parameter specification variables.") - if len(set(params)) != len(params): - raise TypeError( - f"Parameters to {cls.__name__}[...] must all be unique") - else: - # Subscripting a regular Generic subclass. - for param in cls.__parameters__: - prepare = getattr(param, '__typing_prepare_subst__', None) - if prepare is not None: - params = prepare(cls, params) - _check_generic(cls, params, len(cls.__parameters__)) - - new_args = [] - for param, new_arg in zip(cls.__parameters__, params): - if isinstance(param, TypeVarTuple): - new_args.extend(new_arg) - else: - new_args.append(new_arg) - params = tuple(new_args) - - return _GenericAlias(cls, params, - _paramspec_tvars=True) - -import builtins - -def _generic_init_subclass(cls, *args, **kwargs): - super(builtins.Generic, cls).__init_subclass__(*args, **kwargs) - tvars = [] - if '__orig_bases__' in cls.__dict__: - error = builtins.Generic in cls.__orig_bases__ - else: - error = (builtins.Generic in cls.__bases__ and - cls.__name__ != 'Protocol' and - type(cls) != _TypedDictMeta) - if error: - raise TypeError("Cannot inherit from plain Generic") - if '__orig_bases__' in cls.__dict__: - tvars = _collect_parameters(cls.__orig_bases__) - # Look for Generic[T1, ..., Tn]. - # If found, tvars must be a subset of it. - # If not found, tvars is it. - # Also check for and reject plain Generic, - # and reject multiple Generic[...]. - gvars = None - for base in cls.__orig_bases__: - if (isinstance(base, _GenericAlias) and - base.__origin__ is builtins.Generic): - if gvars is not None: - raise TypeError( - "Cannot inherit from Generic[...] multiple types.") - gvars = base.__parameters__ - if gvars is not None: - tvarset = set(tvars) - gvarset = set(gvars) - if not tvarset <= gvarset: - s_vars = ', '.join(str(t) for t in tvars if t not in gvarset) - s_args = ', '.join(str(g) for g in gvars) - raise TypeError(f"Some type variables ({s_vars}) are" - f" not listed in Generic[{s_args}]") - tvars = gvars - cls.__parameters__ = tuple(tvars) - class _TypingEllipsis: """Internal placeholder for ... (ellipsis).""" @@ -2303,6 +2282,30 @@ def _proto_hook(other): if cls.__init__ is Protocol.__init__: cls.__init__ = _no_init_or_replace_init +if hasattr(builtins, "TypeVar"): + def _dummy[T, *Ts, **P](): + pass + + TypeVar = type(_dummy.__type_variables__[0]) + TypeVarTuple = type(_dummy.__type_variables__[1]) + ParamSpec = type(_dummy.__type_variables__[2]) + ParamSpecArgs = type(ParamSpec("P").args) + ParamSpecKwargs = type(ParamSpec("P").kwargs) + + del _dummy + + import copyreg + + def _pickle_psargs(psargs): + return ParamSpecArgs, (psargs.__origin__,) + + copyreg.pickle(ParamSpecArgs, _pickle_psargs) + + def _pickle_pskwargs(pskwargs): + return ParamSpecKwargs, (pskwargs.__origin__,) + + copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) + class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True): """Runtime representation of an annotated type. diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 1bfb3787a7efe2..7c1f40d6b6482a 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -11,9 +11,9 @@ class paramspec "paramspecobject *" "&_PyParamSpec_Type" class paramspecargs "paramspecargsobject *" "&_PyParamSpecArgs_Type" class paramspeckwargs "paramspeckwargsobject *" "&_PyParamSpecKwargs_Type" class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" -class Generic "PyObject *" "&PyGeneric_Type +class Generic "PyObject *" "&PyGeneric_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=74cb9c15a049111b]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=9b0f1a94d4a27c0c]*/ typedef struct { PyObject_HEAD From b5de372e75a8e632ba7c3df6fab96f891b2771ea Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 14:11:03 -0600 Subject: [PATCH 049/200] fix missing initialization --- Python/symtable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/symtable.c b/Python/symtable.c index 098a3a83e054b0..e9dac27033ef69 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -107,6 +107,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_returns_value = 0; ste->ste_needs_class_closure = 0; ste->ste_comp_iter_target = 0; + ste->ste_type_params_in_class = 0; ste->ste_comp_iter_expr = 0; ste->ste_symbols = PyDict_New(); From fa81c01fe4b3973295fb46094d52159b1fcd2b43 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 14:23:40 -0600 Subject: [PATCH 050/200] set __type_variables__ on classes --- Python/compile.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 4e720374a5dc05..299b96a1e068e8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2156,19 +2156,19 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVAR); } ADDOP_I(c, loc, COPY, 1); - compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store); + RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.TypeVar.name, Store)); break; case TypeVarTuple_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVarTuple.name); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVARTUPLE); ADDOP_I(c, loc, COPY, 1); - compiler_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store); + RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.TypeVarTuple.name, Store)); break; case ParamSpec_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.ParamSpec.name); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_PARAMSPEC); ADDOP_I(c, loc, COPY, 1); - compiler_nameop(c, loc, typeparam->v.ParamSpec.name, Store); + RETURN_IF_ERROR(compiler_nameop(c, loc, typeparam->v.ParamSpec.name, Store)); break; } } @@ -2346,6 +2346,31 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return compiler_nameop(c, loc, name, Store); } +static int +compiler_set_type_params_in_class(struct compiler *c, location loc, asdl_typeparam_seq *typeparams) +{ + Py_ssize_t count = asdl_seq_LEN(typeparams); + for (Py_ssize_t i = 0; i < count; i++) { + typeparam_ty typeparam = asdl_seq_GET(typeparams, i); + PyObject *name; + switch(typeparam->kind) { + case TypeVar_kind: + name = typeparam->v.TypeVar.name; + break; + case TypeVarTuple_kind: + name = typeparam->v.TypeVarTuple.name; + break; + case ParamSpec_kind: + name = typeparam->v.ParamSpec.name; + break; + } + RETURN_IF_ERROR(compiler_nameop(c, loc, name, Load)); + } + ADDOP_I(c, loc, BUILD_TUPLE, count); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_ID(__type_variables__), Store)); + return 1; +} + static int compiler_class(struct compiler *c, stmt_ty s) { @@ -2378,7 +2403,6 @@ compiler_class(struct compiler *c, stmt_ty s) RETURN_IF_ERROR(compiler_type_params(c, typeparams)); _Py_DECLARE_STR(type_params, ".type_params"); RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Store)); - //ADDOP(c, loc, POP_TOP); } /* ultimately generate code for: @@ -2417,6 +2441,12 @@ compiler_class(struct compiler *c, stmt_ty s) compiler_exit_scope(c); return ERROR; } + if (typeparams) { + if (!compiler_set_type_params_in_class(c, loc, typeparams)) { + compiler_exit_scope(c); + return ERROR; + } + } /* compile the body proper */ if (compiler_body(c, loc, s->v.ClassDef.body) < 0) { compiler_exit_scope(c); From 7aeee08bd11790bfbf9652892a6c3aade67e65de Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 14:35:58 -0600 Subject: [PATCH 051/200] Add docs to typevarobject.c --- Objects/typevarobject.c | 150 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 146 insertions(+), 4 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 7c1f40d6b6482a..eb53ae617d2ac9 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -250,6 +250,50 @@ static PyNumberMethods typevar_as_number = { .nb_or = _Py_union_type_or, // Add __or__ function }; +PyDoc_STRVAR(typevar_doc, +"Type variable.\n\ +\n\ +Usage::\n\ +\n\ + T = TypeVar('T') # Can be anything\n\ + A = TypeVar('A', str, bytes) # Must be str or bytes\n\ +\n\ +Type variables exist primarily for the benefit of static type\n\ +checkers. They serve as the parameters for generic types as well\n\ +as for generic function definitions. See class Generic for more\n\ +information on generic types. Generic functions work as follows:\n\ +\n\ + def repeat(x: T, n: int) -> List[T]:\n\ + '''Return a list containing n references to x.'''\n\ + return [x]*n\n\ +\n\ + def longest(x: A, y: A) -> A:\n\ + '''Return the longest of two strings.'''\n\ + return x if len(x) >= len(y) else y\n\ +\n\ +The latter example's signature is essentially the overloading\n\ +of (str, str) -> str and (bytes, bytes) -> bytes. Also note\n\ +that if the arguments are instances of some subclass of str,\n\ +the return type is still plain str.\n\ +\n\ +At runtime, isinstance(x, T) and issubclass(C, T) will raise TypeError.\n\ +\n\ +Type variables defined with covariant=True or contravariant=True\n\ +can be used to declare covariant or contravariant generic types.\n\ +See PEP 484 for more details. By default generic types are invariant\n\ +in all type variables.\n\ +\n\ +Type variables can be introspected. e.g.:\n\ +\n\ + T.__name__ == 'T'\n\ + T.__constraints__ == ()\n\ + T.__covariant__ == False\n\ + T.__contravariant__ = False\n\ + A.__constraints__ == (str, bytes)\n\ +\n\ +Note that only type variables defined in global scope can be pickled.\n\ +"); + PyTypeObject _PyTypeVar_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.TypeVar", @@ -264,6 +308,7 @@ PyTypeObject _PyTypeVar_Type = { .tp_methods = typevar_methods, .tp_new = typevar_new, .tp_as_number = &typevar_as_number, + .tp_doc = typevar_doc, }; typedef struct { @@ -347,6 +392,19 @@ paramspecargs_new_impl(PyTypeObject *type, PyObject *origin) return (PyObject *)paramspecargsobject_new(origin); } +PyDoc_STRVAR(paramspecargs_doc, +"The args for a ParamSpec object.\n\ +\n\ +Given a ParamSpec object P, P.args is an instance of ParamSpecArgs.\n\ +\n\ +ParamSpecArgs objects have a reference back to their ParamSpec:\n\ +\n\ + P.args.__origin__ is P\n\ +\n\ +This type is meant for runtime introspection and has no special meaning to\n\ +static type checkers.\n\ +"); + PyTypeObject _PyParamSpecArgs_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.ParamSpecArgs", @@ -360,6 +418,7 @@ PyTypeObject _PyParamSpecArgs_Type = { .tp_traverse = paramspecargsobject_traverse, .tp_members = paramspecargs_members, .tp_new = paramspecargs_new, + .tp_doc = paramspecargs_doc, }; typedef struct { @@ -443,6 +502,19 @@ paramspeckwargs_new_impl(PyTypeObject *type, PyObject *origin) return (PyObject *)paramspeckwargsobject_new(origin); } +PyDoc_STRVAR(paramspeckwargs_doc, +"The kwargs for a ParamSpec object.\n\ +\n\ +Given a ParamSpec object P, P.kwargs is an instance of ParamSpecKwargs.\n\ +\n\ +ParamSpecKwargs objects have a reference back to their ParamSpec:\n\ +\n\ + P.kwargs.__origin__ is P\n\ +\n\ +This type is meant for runtime introspection and has no special meaning to\n\ +static type checkers.\n\ +"); + PyTypeObject _PyParamSpecKwargs_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.ParamSpecKwargs", @@ -456,6 +528,7 @@ PyTypeObject _PyParamSpecKwargs_Type = { .tp_traverse = paramspeckwargsobject_traverse, .tp_members = paramspeckwargs_members, .tp_new = paramspeckwargs_new, + .tp_doc = paramspeckwargs_doc, }; static void paramspecobject_dealloc(PyObject *self) @@ -635,8 +708,52 @@ static PyNumberMethods paramspec_as_number = { .nb_or = _Py_union_type_or, // Add __or__ function }; -// TODO: -// - pickling +PyDoc_STRVAR(paramspec_doc, +"Parameter specification variable.\n\ +\n\ +Usage::\n\ +\n\ + P = ParamSpec('P')\n\ +\n\ +Parameter specification variables exist primarily for the benefit of static\n\ +type checkers. They are used to forward the parameter types of one\n\ +callable to another callable, a pattern commonly found in higher order\n\ +functions and decorators. They are only valid when used in ``Concatenate``,\n\ +or as the first argument to ``Callable``, or as parameters for user-defined\n\ +Generics. See class Generic for more information on generic types. An\n\ +example for annotating a decorator::\n\ +\n\ + T = TypeVar('T')\n\ + P = ParamSpec('P')\n\ +\n\ + def add_logging(f: Callable[P, T]) -> Callable[P, T]:\n\ + '''A type-safe decorator to add logging to a function.'''\n\ + def inner(*args: P.args, **kwargs: P.kwargs) -> T:\n\ + logging.info(f'{f.__name__} was called')\n\ + return f(*args, **kwargs)\n\ + return inner\n\ +\n\ + @add_logging\n\ + def add_two(x: float, y: float) -> float:\n\ + '''Add two numbers together.'''\n\ + return x + y\n\ +\n\ +Parameter specification variables defined with covariant=True or\n\ +contravariant=True can be used to declare covariant or contravariant\n\ +generic types. These keyword arguments are valid, but their actual semantics\n\ +are yet to be decided. See PEP 612 for details.\n\ +\n\ +Parameter specification variables can be introspected. e.g.:\n\ +\n\ + P.__name__ == 'P'\n\ + P.__bound__ == None\n\ + P.__covariant__ == False\n\ + P.__contravariant__ == False\n\ +\n\ +Note that only parameter specification variables defined in global scope can\n\ +be pickled.\n\ +"); + PyTypeObject _PyParamSpec_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.ParamSpec", @@ -652,6 +769,7 @@ PyTypeObject _PyParamSpec_Type = { .tp_getset = paramspec_getset, .tp_new = paramspec_new, .tp_as_number = ¶mspec_as_number, + .tp_doc = paramspec_doc, }; static void typevartupleobject_dealloc(PyObject *self) @@ -791,8 +909,31 @@ static PyMethodDef typevartuple_methods[] = { {0} }; -// TODO: -// - Pickling +PyDoc_STRVAR(typevartuple_doc, +"Type variable tuple.\n\ +\n\ +Usage:\n\ +\n\ + Ts = TypeVarTuple('Ts') # Can be given any name\n\ +\n\ +Just as a TypeVar (type variable) is a placeholder for a single type,\n\ +a TypeVarTuple is a placeholder for an *arbitrary* number of types. For\n\ +example, if we define a generic class using a TypeVarTuple:\n\ +\n\ + class C(Generic[*Ts]): ...\n\ +\n\ +Then we can parameterize that class with an arbitrary number of type\n\ +arguments:\n\ +\n\ + C[int] # Fine\n\ + C[int, str] # Also fine\n\ + C[()] # Even this is fine\n\ +\n\ +For more details, see PEP 646.\n\ +\n\ +Note that only TypeVarTuples defined in global scope can be pickled.\n\ +"); + PyTypeObject _PyTypeVarTuple_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "typing.TypeVarTuple", @@ -805,6 +946,7 @@ PyTypeObject _PyTypeVarTuple_Type = { .tp_members = typevartuple_members, .tp_methods = typevartuple_methods, .tp_new = typevartuple, + .tp_doc = typevartuple_doc, }; PyObject *_Py_make_typevar(const char *name, PyObject *bound_or_constraints) { From a7e6bcbf07ced5318c1e205a69c778d4a64707c5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 14:39:23 -0600 Subject: [PATCH 052/200] drop Python implementations of Generic, TypeVar, etc. --- Lib/typing.py | 548 ++++++++------------------------------------------ 1 file changed, 81 insertions(+), 467 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index 7ac4badfe42f6e..d8f1e7cbccb0da 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -23,6 +23,7 @@ import collections from collections import defaultdict import collections.abc +import copyreg import contextlib import functools import operator @@ -929,51 +930,6 @@ def __reduce__(self): return self.__name__ -class _BoundVarianceMixin: - """Mixin giving __init__ bound and variance arguments. - - This is used by TypeVar and ParamSpec, which both employ the notions of - a type 'bound' (restricting type arguments to be a subtype of some - specified type) and type 'variance' (determining subtype relations between - generic types). - """ - def __init__(self, bound, covariant, contravariant, autovariance): - """Used to setup TypeVars and ParamSpec's bound, covariant, - contravariant, and autovariance attributes. - """ - if covariant and contravariant: - raise ValueError("Bivariant types are not supported.") - if autovariance and (covariant or contravariant): - raise ValueError("Variance cannot be specified with autovariance.") - self.__covariant__ = bool(covariant) - self.__contravariant__ = bool(contravariant) - self.__autovariance__ = bool(autovariance) - if bound: - self.__bound__ = _type_check(bound, "Bound must be a type.") - else: - self.__bound__ = None - - def __or__(self, right): - return Union[self, right] - - def __ror__(self, left): - return Union[left, self] - - def __repr__(self): - if self.__covariant__: - prefix = '+' - elif self.__contravariant__: - prefix = '-' - elif self.__autovariance__: - prefix = '' - else: - prefix = '~' - return prefix + self.__name__ - - def __mro_entries__(self, bases): - raise TypeError(f"Cannot subclass an instance of {type(self).__name__}") - - class TypeAliasType(_Final, _Immutable, _PickleUsingNameMixin, _root=True): """Type alias allocated through the use of a "type" statement. """ @@ -1004,304 +960,74 @@ def __ror__(self, left): return Union[left, self] -class TypeVar(_Final, _Immutable, _BoundVarianceMixin, _PickleUsingNameMixin, - _root=True): - """Type variable. - - Usage:: - - T = TypeVar('T') # Can be anything - A = TypeVar('A', str, bytes) # Must be str or bytes - - Type variables exist primarily for the benefit of static type - checkers. They serve as the parameters for generic types as well - as for generic function definitions. See class Generic for more - information on generic types. Generic functions work as follows: - - def repeat(x: T, n: int) -> List[T]: - '''Return a list containing n references to x.''' - return [x]*n - - def longest(x: A, y: A) -> A: - '''Return the longest of two strings.''' - return x if len(x) >= len(y) else y - - The latter example's signature is essentially the overloading - of (str, str) -> str and (bytes, bytes) -> bytes. Also note - that if the arguments are instances of some subclass of str, - the return type is still plain str. - - At runtime, isinstance(x, T) and issubclass(C, T) will raise TypeError. - - Type variables defined with covariant=True or contravariant=True - can be used to declare covariant or contravariant generic types. - See PEP 484 for more details. By default generic types are invariant - in all type variables. - - Type variables can be introspected. e.g.: - - T.__name__ == 'T' - T.__constraints__ == () - T.__covariant__ == False - T.__contravariant__ = False - A.__constraints__ == (str, bytes) - - Note that only type variables defined in global scope can be pickled. - """ - - def __init__(self, name, *constraints, bound=None, - covariant=False, contravariant=False, autovariance=False): - self.__name__ = name - super().__init__(bound, covariant, contravariant, autovariance) - if constraints and bound is not None: - raise TypeError("Constraints cannot be combined with bound=...") - if constraints and len(constraints) == 1: - raise TypeError("A single constraint is not allowed") - msg = "TypeVar(name, constraint, ...): constraints must be types." - self.__constraints__ = tuple(_type_check(t, msg) for t in constraints) - def_mod = _caller() - if def_mod != 'typing': - self.__module__ = def_mod - - def __typing_subst__(self, arg): - msg = "Parameters to generic types must be types." - arg = _type_check(arg, msg, is_argument=True) - if ((isinstance(arg, _GenericAlias) and arg.__origin__ is Unpack) or - (isinstance(arg, GenericAlias) and getattr(arg, '__unpacked__', False))): - raise TypeError(f"{arg} is not valid as type argument") - return arg - -_typevar_subst = TypeVar.__typing_subst__ - - -class TypeVarTuple(_Final, _Immutable, _PickleUsingNameMixin, _root=True): - """Type variable tuple. - - Usage: - - Ts = TypeVarTuple('Ts') # Can be given any name - - Just as a TypeVar (type variable) is a placeholder for a single type, - a TypeVarTuple is a placeholder for an *arbitrary* number of types. For - example, if we define a generic class using a TypeVarTuple: - - class C(Generic[*Ts]): ... - - Then we can parameterize that class with an arbitrary number of type - arguments: - - C[int] # Fine - C[int, str] # Also fine - C[()] # Even this is fine - - For more details, see PEP 646. - - Note that only TypeVarTuples defined in global scope can be pickled. - """ - - def __init__(self, name): - self.__name__ = name - - # Used for pickling. - def_mod = _caller() - if def_mod != 'typing': - self.__module__ = def_mod - - def __iter__(self): - yield Unpack[self] - - def __repr__(self): - return self.__name__ - - def __typing_subst__(self, arg): - raise TypeError("Substitution of bare TypeVarTuple is not supported") - - def __typing_prepare_subst__(self, alias, args): - params = alias.__parameters__ - typevartuple_index = params.index(self) - for param in params[typevartuple_index + 1:]: - if isinstance(param, TypeVarTuple): - raise TypeError(f"More than one TypeVarTuple parameter in {alias}") - - alen = len(args) - plen = len(params) - left = typevartuple_index - right = plen - typevartuple_index - 1 - var_tuple_index = None - fillarg = None - for k, arg in enumerate(args): - if not isinstance(arg, type): - subargs = getattr(arg, '__typing_unpacked_tuple_args__', None) - if subargs and len(subargs) == 2 and subargs[-1] is ...: - if var_tuple_index is not None: - raise TypeError("More than one unpacked arbitrary-length tuple argument") - var_tuple_index = k - fillarg = subargs[0] - if var_tuple_index is not None: - left = min(left, var_tuple_index) - right = min(right, alen - var_tuple_index - 1) - elif left + right > alen: - raise TypeError(f"Too few arguments for {alias};" - f" actual {alen}, expected at least {plen-1}") - - return ( - *args[:left], - *([fillarg]*(typevartuple_index - left)), - tuple(args[left: alen - right]), - *([fillarg]*(plen - right - left - typevartuple_index - 1)), - *args[alen - right:], - ) - - def __mro_entries__(self, bases): - raise TypeError(f"Cannot subclass an instance of {type(self).__name__}") - -_typevartuple_prepare_subst = TypeVarTuple.__typing_prepare_subst__ - - -class ParamSpecArgs(_Final, _Immutable, _root=True): - """The args for a ParamSpec object. - - Given a ParamSpec object P, P.args is an instance of ParamSpecArgs. - - ParamSpecArgs objects have a reference back to their ParamSpec: - - P.args.__origin__ is P - - This type is meant for runtime introspection and has no special meaning to - static type checkers. - """ - def __init__(self, origin): - self.__origin__ = origin - - def __repr__(self): - return f"{self.__origin__.__name__}.args" - - def __eq__(self, other): - if not isinstance(other, ParamSpecArgs): - return NotImplemented - return self.__origin__ == other.__origin__ - - def __mro_entries__(self, bases): - raise TypeError(f"Cannot subclass an instance of {type(self).__name__}") - - -class ParamSpecKwargs(_Final, _Immutable, _root=True): - """The kwargs for a ParamSpec object. - - Given a ParamSpec object P, P.kwargs is an instance of ParamSpecKwargs. - - ParamSpecKwargs objects have a reference back to their ParamSpec: - - P.kwargs.__origin__ is P - - This type is meant for runtime introspection and has no special meaning to - static type checkers. - """ - def __init__(self, origin): - self.__origin__ = origin - - def __repr__(self): - return f"{self.__origin__.__name__}.kwargs" - - def __eq__(self, other): - if not isinstance(other, ParamSpecKwargs): - return NotImplemented - return self.__origin__ == other.__origin__ - - def __mro_entries__(self, bases): - raise TypeError(f"Cannot subclass an instance of {type(self).__name__}") - - -class ParamSpec(_Final, _Immutable, _BoundVarianceMixin, _PickleUsingNameMixin, - _root=True): - """Parameter specification variable. - - Usage:: - - P = ParamSpec('P') - - Parameter specification variables exist primarily for the benefit of static - type checkers. They are used to forward the parameter types of one - callable to another callable, a pattern commonly found in higher order - functions and decorators. They are only valid when used in ``Concatenate``, - or as the first argument to ``Callable``, or as parameters for user-defined - Generics. See class Generic for more information on generic types. An - example for annotating a decorator:: - - T = TypeVar('T') - P = ParamSpec('P') - - def add_logging(f: Callable[P, T]) -> Callable[P, T]: - '''A type-safe decorator to add logging to a function.''' - def inner(*args: P.args, **kwargs: P.kwargs) -> T: - logging.info(f'{f.__name__} was called') - return f(*args, **kwargs) - return inner - - @add_logging - def add_two(x: float, y: float) -> float: - '''Add two numbers together.''' - return x + y - - Parameter specification variables defined with covariant=True or - contravariant=True can be used to declare covariant or contravariant - generic types. These keyword arguments are valid, but their actual semantics - are yet to be decided. See PEP 612 for details. - - Parameter specification variables can be introspected. e.g.: - - P.__name__ == 'P' - P.__bound__ == None - P.__covariant__ == False - P.__contravariant__ == False - - Note that only parameter specification variables defined in global scope can - be pickled. - """ +def _typevar_subst(self, arg): + msg = "Parameters to generic types must be types." + arg = _type_check(arg, msg, is_argument=True) + if ((isinstance(arg, _GenericAlias) and arg.__origin__ is Unpack) or + (isinstance(arg, GenericAlias) and getattr(arg, '__unpacked__', False))): + raise TypeError(f"{arg} is not valid as type argument") + return arg - @property - def args(self): - return ParamSpecArgs(self) - @property - def kwargs(self): - return ParamSpecKwargs(self) +def _typevartuple_prepare_subst(self, alias, args): + params = alias.__parameters__ + typevartuple_index = params.index(self) + for param in params[typevartuple_index + 1:]: + if isinstance(param, TypeVarTuple): + raise TypeError(f"More than one TypeVarTuple parameter in {alias}") + + alen = len(args) + plen = len(params) + left = typevartuple_index + right = plen - typevartuple_index - 1 + var_tuple_index = None + fillarg = None + for k, arg in enumerate(args): + if not isinstance(arg, type): + subargs = getattr(arg, '__typing_unpacked_tuple_args__', None) + if subargs and len(subargs) == 2 and subargs[-1] is ...: + if var_tuple_index is not None: + raise TypeError("More than one unpacked arbitrary-length tuple argument") + var_tuple_index = k + fillarg = subargs[0] + if var_tuple_index is not None: + left = min(left, var_tuple_index) + right = min(right, alen - var_tuple_index - 1) + elif left + right > alen: + raise TypeError(f"Too few arguments for {alias};" + f" actual {alen}, expected at least {plen-1}") - def __init__(self, name, *, bound=None, - covariant=False, contravariant=False, autovariance=False): - self.__name__ = name - super().__init__(bound, covariant, contravariant, autovariance) - def_mod = _caller() - if def_mod != 'typing': - self.__module__ = def_mod - - def __typing_subst__(self, arg): - if isinstance(arg, (list, tuple)): - arg = tuple(_type_check(a, "Expected a type.") for a in arg) - elif not _is_param_expr(arg): - raise TypeError(f"Expected a list of types, an ellipsis, " - f"ParamSpec, or Concatenate. Got {arg}") - return arg + return ( + *args[:left], + *([fillarg]*(typevartuple_index - left)), + tuple(args[left: alen - right]), + *([fillarg]*(plen - right - left - typevartuple_index - 1)), + *args[alen - right:], + ) - def __typing_prepare_subst__(self, alias, args): - params = alias.__parameters__ - i = params.index(self) - if i >= len(args): - raise TypeError(f"Too few arguments for {alias}") - # Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612. - if len(params) == 1 and not _is_param_expr(args[0]): - assert i == 0 - args = (args,) - # Convert lists to tuples to help other libraries cache the results. - elif isinstance(args[i], list): - args = (*args[:i], tuple(args[i]), *args[i+1:]) - return args -_paramspec_subst = ParamSpec.__typing_subst__ -_paramspec_prepare_subst = ParamSpec.__typing_prepare_subst__ +def _paramspec_subst(self, arg): + if isinstance(arg, (list, tuple)): + arg = tuple(_type_check(a, "Expected a type.") for a in arg) + elif not _is_param_expr(arg): + raise TypeError(f"Expected a list of types, an ellipsis, " + f"ParamSpec, or Concatenate. Got {arg}") + return arg -import builtins +def _paramspec_prepare_subst(self, alias, args): + params = alias.__parameters__ + i = params.index(self) + if i >= len(args): + raise TypeError(f"Too few arguments for {alias}") + # Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612. + if len(params) == 1 and not _is_param_expr(args[0]): + assert i == 0 + args = (args,) + # Convert lists to tuples to help other libraries cache the results. + elif isinstance(args[i], list): + args = (*args[:i], tuple(args[i]), *args[i+1:]) + return args @_tp_cache @@ -1319,7 +1045,7 @@ def _generic_class_getitem(cls, params): params = (params,) params = tuple(_type_convert(p) for p in params) - if cls in (builtins.Generic, Protocol): + if cls in (Generic, Protocol): # Generic and Protocol can only be subscripted with unique type variables. if not params: raise TypeError( @@ -1353,12 +1079,12 @@ def _generic_class_getitem(cls, params): def _generic_init_subclass(cls, *args, **kwargs): - super(builtins.Generic, cls).__init_subclass__(*args, **kwargs) + super(Generic, cls).__init_subclass__(*args, **kwargs) tvars = [] if '__orig_bases__' in cls.__dict__: - error = builtins.Generic in cls.__orig_bases__ + error = Generic in cls.__orig_bases__ else: - error = (builtins.Generic in cls.__bases__ and + error = (Generic in cls.__bases__ and cls.__name__ != 'Protocol' and type(cls) != _TypedDictMeta) if error: @@ -1373,7 +1099,7 @@ def _generic_init_subclass(cls, *args, **kwargs): gvars = None for base in cls.__orig_bases__: if (isinstance(base, _GenericAlias) and - base.__origin__ is builtins.Generic): + base.__origin__ is Generic): if gvars is not None: raise TypeError( "Cannot inherit from Generic[...] multiple types.") @@ -1926,115 +1652,6 @@ def __typing_is_unpacked_typevartuple__(self): return isinstance(self.__args__[0], TypeVarTuple) -class Generic: - """Abstract base class for generic types. - - A generic type is typically declared by inheriting from - this class parameterized with one or more type variables. - For example, a generic mapping type might be defined as:: - - class Mapping(Generic[KT, VT]): - def __getitem__(self, key: KT) -> VT: - ... - # Etc. - - This class can then be used as follows:: - - def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: - try: - return mapping[key] - except KeyError: - return default - """ - __slots__ = () - _is_protocol = False - - @_tp_cache - def __class_getitem__(cls, params): - """Parameterizes a generic class. - - At least, parameterizing a generic class is the *main* thing this method - does. For example, for some generic class `Foo`, this is called when we - do `Foo[int]` - there, with `cls=Foo` and `params=int`. - - However, note that this method is also called when defining generic - classes in the first place with `class Foo(Generic[T]): ...`. - """ - if not isinstance(params, tuple): - params = (params,) - - params = tuple(_type_convert(p) for p in params) - if cls in (Generic, Protocol): - # Generic and Protocol can only be subscripted with unique type variables. - if not params: - raise TypeError( - f"Parameter list to {cls.__qualname__}[...] cannot be empty" - ) - if not all(_is_typevar_like(p) for p in params): - raise TypeError( - f"Parameters to {cls.__name__}[...] must all be type variables " - f"or parameter specification variables.") - if len(set(params)) != len(params): - raise TypeError( - f"Parameters to {cls.__name__}[...] must all be unique") - else: - # Subscripting a regular Generic subclass. - for param in cls.__parameters__: - prepare = getattr(param, '__typing_prepare_subst__', None) - if prepare is not None: - params = prepare(cls, params) - _check_generic(cls, params, len(cls.__parameters__)) - - new_args = [] - for param, new_arg in zip(cls.__parameters__, params): - if isinstance(param, TypeVarTuple): - new_args.extend(new_arg) - else: - new_args.append(new_arg) - params = tuple(new_args) - - return _GenericAlias(cls, params, - _paramspec_tvars=True) - - def __init_subclass__(cls, *args, **kwargs): - super().__init_subclass__(*args, **kwargs) - tvars = [] - if '__orig_bases__' in cls.__dict__: - error = Generic in cls.__orig_bases__ - else: - error = (Generic in cls.__bases__ and - cls.__name__ != 'Protocol' and - type(cls) != _TypedDictMeta) - if error: - raise TypeError("Cannot inherit from plain Generic") - if '__orig_bases__' in cls.__dict__: - tvars = _collect_parameters(cls.__orig_bases__) - # Look for Generic[T1, ..., Tn]. - # If found, tvars must be a subset of it. - # If not found, tvars is it. - # Also check for and reject plain Generic, - # and reject multiple Generic[...]. - gvars = None - for base in cls.__orig_bases__: - if (isinstance(base, _GenericAlias) and - base.__origin__ is Generic): - if gvars is not None: - raise TypeError( - "Cannot inherit from Generic[...] multiple types.") - gvars = base.__parameters__ - if gvars is not None: - tvarset = set(tvars) - gvarset = set(gvars) - if not tvarset <= gvarset: - s_vars = ', '.join(str(t) for t in tvars if t not in gvarset) - s_args = ', '.join(str(g) for g in gvars) - raise TypeError(f"Some type variables ({s_vars}) are" - f" not listed in Generic[{s_args}]") - tvars = gvars - cls.__parameters__ = tuple(tvars) - - - class _TypingEllipsis: """Internal placeholder for ... (ellipsis).""" @@ -2282,29 +1899,26 @@ def _proto_hook(other): if cls.__init__ is Protocol.__init__: cls.__init__ = _no_init_or_replace_init -if hasattr(builtins, "TypeVar"): - def _dummy[T, *Ts, **P](): - pass - - TypeVar = type(_dummy.__type_variables__[0]) - TypeVarTuple = type(_dummy.__type_variables__[1]) - ParamSpec = type(_dummy.__type_variables__[2]) - ParamSpecArgs = type(ParamSpec("P").args) - ParamSpecKwargs = type(ParamSpec("P").kwargs) +def _dummy[T, *Ts, **P](): + pass - del _dummy +TypeVar = type(_dummy.__type_variables__[0]) +TypeVarTuple = type(_dummy.__type_variables__[1]) +ParamSpec = type(_dummy.__type_variables__[2]) +ParamSpecArgs = type(ParamSpec("P").args) +ParamSpecKwargs = type(ParamSpec("P").kwargs) - import copyreg +del _dummy - def _pickle_psargs(psargs): - return ParamSpecArgs, (psargs.__origin__,) +def _pickle_psargs(psargs): + return ParamSpecArgs, (psargs.__origin__,) - copyreg.pickle(ParamSpecArgs, _pickle_psargs) +copyreg.pickle(ParamSpecArgs, _pickle_psargs) - def _pickle_pskwargs(pskwargs): - return ParamSpecKwargs, (pskwargs.__origin__,) +def _pickle_pskwargs(pskwargs): + return ParamSpecKwargs, (pskwargs.__origin__,) - copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) +copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True): From fe844584f2e022db712be4705507f725ea60e9bf Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 14:46:15 -0600 Subject: [PATCH 053/200] fix Generic --- Lib/typing.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index d8f1e7cbccb0da..1e9649d08fa5d3 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1899,16 +1899,17 @@ def _proto_hook(other): if cls.__init__ is Protocol.__init__: cls.__init__ = _no_init_or_replace_init -def _dummy[T, *Ts, **P](): +class _Dummy[T, *Ts, **P](): pass -TypeVar = type(_dummy.__type_variables__[0]) -TypeVarTuple = type(_dummy.__type_variables__[1]) -ParamSpec = type(_dummy.__type_variables__[2]) +TypeVar = type(_Dummy.__type_variables__[0]) +TypeVarTuple = type(_Dummy.__type_variables__[1]) +ParamSpec = type(_Dummy.__type_variables__[2]) ParamSpecArgs = type(ParamSpec("P").args) ParamSpecKwargs = type(ParamSpec("P").kwargs) +Generic = _Dummy.__mro__[1] -del _dummy +del _Dummy def _pickle_psargs(psargs): return ParamSpecArgs, (psargs.__origin__,) From 34c024da8f36d6c559f3ccdfa4da6cd605414bca Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 14:48:20 -0600 Subject: [PATCH 054/200] make generics instantiable --- Objects/typevarobject.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index eb53ae617d2ac9..f396e026b36e1f 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1071,4 +1071,5 @@ PyTypeObject _PyGeneric_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = generic_doc, .tp_methods = generic_methods, + .tp_new = PyType_GenericNew, }; From d9ec56e2045d38c3b9fc123bb688524aaffed816 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 15:17:51 -0600 Subject: [PATCH 055/200] fix NamedTuple --- Lib/typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/typing.py b/Lib/typing.py index 1e9649d08fa5d3..652402d3dc54d6 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -2689,7 +2689,7 @@ def __new__(cls, typename, bases, ns): module=ns['__module__']) nm_tpl.__bases__ = bases if Generic in bases: - class_getitem = Generic.__class_getitem__.__func__ + class_getitem = _generic_class_getitem nm_tpl.__class_getitem__ = classmethod(class_getitem) # update from user namespace without overriding special namedtuple attributes for key in ns: From 6ab8b1e99e9ef598c5d69cbeb49622b837f517a9 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 15:48:09 -0600 Subject: [PATCH 056/200] fix some tests --- Lib/test/test_type_params.py | 7 ++++--- Objects/typevarobject.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index a4538b923e9065..4abc39946f5fc1 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -218,11 +218,12 @@ def method[T](self, arg: x): pass def test_class_scope_interaction_02(self): code = textwrap.dedent("""\ + from typing import Generic class C: class Base: pass class Child[T](Base): pass - assert C.Child.__bases__ == (C.Base,) + assert C.Child.__bases__ == (C.Base, Generic) """) exec(code, {}) @@ -369,7 +370,7 @@ def get_typeparams(): a, b, c, d = Outer.Inner.get_typeparams() self.assertEqual(Outer.__type_variables__, (a, b)) - self.assertEqual(Outer.Inner.__type_variables__, (a, b, c, d)) + self.assertEqual(Outer.Inner.__type_variables__, (c, d)) self.assertEqual(Outer.__parameters__, (a, b)) self.assertEqual(Outer.Inner.__parameters__, (c, d)) @@ -401,7 +402,7 @@ def inner[C, D](): inner = outer() a, b, c, d = inner() self.assertEqual(outer.__type_variables__, (a, b)) - self.assertEqual(inner.__type_variables__, (a, b, c, d)) + self.assertEqual(inner.__type_variables__, (c, d)) def test_typeparams_dunder_function_02(self): def func1(): diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index f396e026b36e1f..03246495f4a379 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -240,9 +240,18 @@ typevar_reduce_impl(typevarobject *self) return PyUnicode_FromString(self->name); } +static PyObject * +typevar_mro_entries(PyObject *self, PyObject *args) +{ + PyErr_SetString(PyExc_TypeError, + "Cannot subclass an instance of TypeVar"); + return NULL; +} + static PyMethodDef typevar_methods[] = { TYPEVAR_TYPING_SUBST_METHODDEF TYPEVAR_REDUCE_METHODDEF + {"__mro_entries__", typevar_mro_entries, METH_O}, {0} }; @@ -697,10 +706,19 @@ paramspec_reduce_impl(paramspecobject *self) return PyUnicode_FromString(self->name); } +static PyObject * +paramspec_mro_entries(PyObject *self, PyObject *args) +{ + PyErr_SetString(PyExc_TypeError, + "Cannot subclass an instance of ParamSpec"); + return NULL; +} + static PyMethodDef paramspec_methods[] = { PARAMSPEC_TYPING_SUBST_METHODDEF PARAMSPEC_TYPING_PREPARE_SUBST_METHODDEF PARAMSPEC_REDUCE_METHODDEF + {"__mro_entries__", paramspec_mro_entries, METH_O}, {0} }; @@ -902,10 +920,19 @@ typevartuple_reduce_impl(typevartupleobject *self) return PyUnicode_FromString(self->name); } +static PyObject * +typevartuple_mro_entries(PyObject *self, PyObject *args) +{ + PyErr_SetString(PyExc_TypeError, + "Cannot subclass an instance of TypeVarTuple"); + return NULL; +} + static PyMethodDef typevartuple_methods[] = { TYPEVARTUPLE_TYPING_SUBST_METHODDEF TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF TYPEVARTUPLE_REDUCE_METHODDEF + {"__mro_entries__", typevartuple_mro_entries, METH_O}, {0} }; From d9169745afaaf333a60ee57bd2a3a1cf5b9400c8 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 23 Apr 2023 15:48:57 -0600 Subject: [PATCH 057/200] one more --- Lib/test/test_type_params.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 4abc39946f5fc1..59511b10844381 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -240,11 +240,10 @@ class ClassA[T](Generic[T]): ... exec(code, {}) def test_traditional_02(self): - # This does not generate a runtime error, but it should be - # flagged as an error by type checkers. from typing import TypeVar S = TypeVar("S") - class ClassA[T](dict[T, S]): ... + with self.assertRaises(TypeError): + class ClassA[T](dict[T, S]): ... def test_traditional_03(self): # This does not generate a runtime error, but it should be From b38dea439eaa37b6c138097f2476eb457b011e00 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 06:32:25 -0600 Subject: [PATCH 058/200] Use a heap type for Generic --- Include/internal/pycore_typeobject.h | 1 + Include/internal/pycore_typevarobject.h | 2 +- Lib/typing.py | 71 +++++++++++++++---------- Objects/object.c | 31 ++++++----- Objects/typevarobject.c | 36 +++++++++---- Python/bltinmodule.c | 1 - Python/pylifecycle.c | 1 + 7 files changed, 91 insertions(+), 52 deletions(-) diff --git a/Include/internal/pycore_typeobject.h b/Include/internal/pycore_typeobject.h index cc5ce2875101ea..4f862a356ce3d0 100644 --- a/Include/internal/pycore_typeobject.h +++ b/Include/internal/pycore_typeobject.h @@ -82,6 +82,7 @@ struct types_state { struct type_cache type_cache; size_t num_builtins_initialized; static_builtin_state builtins[_Py_MAX_STATIC_BUILTIN_TYPES]; + PyObject *generic_type; }; diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index 1c2898cc15ffcb..3065cd066d1c8b 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -13,12 +13,12 @@ extern PyTypeObject _PyTypeVarTuple_Type; extern PyTypeObject _PyParamSpec_Type; extern PyTypeObject _PyParamSpecArgs_Type; extern PyTypeObject _PyParamSpecKwargs_Type; -extern PyTypeObject _PyGeneric_Type; extern PyObject *_Py_make_typevar(const char *, PyObject *); extern PyObject *_Py_make_paramspec(const char *); extern PyObject *_Py_make_typevartuple(const char *); extern PyObject *_Py_subscript_generic(PyObject *); +extern int _Py_initialize_generic(PyInterpreterState *); #ifdef __cplusplus } diff --git a/Lib/typing.py b/Lib/typing.py index 652402d3dc54d6..ffef421d0fb545 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1045,7 +1045,12 @@ def _generic_class_getitem(cls, params): params = (params,) params = tuple(_type_convert(p) for p in params) - if cls in (Generic, Protocol): + try: + is_generic_or_protocol = cls in (Generic, Protocol) + except NameError: + # Happens during interpreter startup + is_generic_or_protocol = True + if is_generic_or_protocol: # Generic and Protocol can only be subscripted with unique type variables. if not params: raise TypeError( @@ -1079,12 +1084,18 @@ def _generic_class_getitem(cls, params): def _generic_init_subclass(cls, *args, **kwargs): - super(Generic, cls).__init_subclass__(*args, **kwargs) + try: + generic_cls = Generic + except NameError: + # Happens during interpreter startup. We are creating + # the _Dummy class. + generic_cls = cls.__mro__[1] + super(generic_cls, cls).__init_subclass__(*args, **kwargs) tvars = [] if '__orig_bases__' in cls.__dict__: - error = Generic in cls.__orig_bases__ + error = generic_cls in cls.__orig_bases__ else: - error = (Generic in cls.__bases__ and + error = (generic_cls in cls.__bases__ and cls.__name__ != 'Protocol' and type(cls) != _TypedDictMeta) if error: @@ -1099,7 +1110,7 @@ def _generic_init_subclass(cls, *args, **kwargs): gvars = None for base in cls.__orig_bases__: if (isinstance(base, _GenericAlias) and - base.__origin__ is Generic): + base.__origin__ is generic_cls): if gvars is not None: raise TypeError( "Cannot inherit from Generic[...] multiple types.") @@ -1405,7 +1416,12 @@ def __mro_entries__(self, bases): if self._name: # generic version of an ABC or built-in class return super().__mro_entries__(bases) - if self.__origin__ is Generic: + try: + is_Generic = self.__origin__ is Generic + except NameError: + # Happens during interpreter startup + return (self.__origin__,) + if is_Generic: if Protocol in bases: return () i = bases.index(self) @@ -1757,6 +1773,28 @@ def _lazy_load_getattr_static(): _cleanups.append(_lazy_load_getattr_static.cache_clear) +class _Dummy[T, *Ts, **P](): + pass + +TypeVar = type(_Dummy.__type_variables__[0]) +TypeVarTuple = type(_Dummy.__type_variables__[1]) +ParamSpec = type(_Dummy.__type_variables__[2]) +ParamSpecArgs = type(ParamSpec("P").args) +ParamSpecKwargs = type(ParamSpec("P").kwargs) +Generic = _Dummy.__mro__[1] + +def _pickle_psargs(psargs): + return ParamSpecArgs, (psargs.__origin__,) + +copyreg.pickle(ParamSpecArgs, _pickle_psargs) + +def _pickle_pskwargs(pskwargs): + return ParamSpecKwargs, (pskwargs.__origin__,) + +copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) + +del _Dummy, _pickle_psargs, _pickle_pskwargs + class _ProtocolMeta(ABCMeta): # This metaclass is really unfortunate and exists only because of @@ -1899,27 +1937,6 @@ def _proto_hook(other): if cls.__init__ is Protocol.__init__: cls.__init__ = _no_init_or_replace_init -class _Dummy[T, *Ts, **P](): - pass - -TypeVar = type(_Dummy.__type_variables__[0]) -TypeVarTuple = type(_Dummy.__type_variables__[1]) -ParamSpec = type(_Dummy.__type_variables__[2]) -ParamSpecArgs = type(ParamSpec("P").args) -ParamSpecKwargs = type(ParamSpec("P").kwargs) -Generic = _Dummy.__mro__[1] - -del _Dummy - -def _pickle_psargs(psargs): - return ParamSpecArgs, (psargs.__origin__,) - -copyreg.pickle(ParamSpecArgs, _pickle_psargs) - -def _pickle_pskwargs(pskwargs): - return ParamSpecKwargs, (pskwargs.__origin__,) - -copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True): diff --git a/Objects/object.c b/Objects/object.c index 2677fe822a6b10..131a4c24d90a65 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -14,7 +14,7 @@ #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_symtable.h" // PySTEntry_Type -#include "pycore_typevarobject.h" // _PyTypeVar_Type etc. +#include "pycore_typevarobject.h" // _PyTypeVar_Type etc., _Py_initialize_generic #include "pycore_unionobject.h" // _PyUnion_Type #include "pycore_interpreteridobject.h" // _PyInterpreterID_Type @@ -2104,21 +2104,24 @@ static PyTypeObject* static_types[] = { PyStatus _PyTypes_InitTypes(PyInterpreterState *interp) { - if (!_Py_IsMainInterpreter(interp)) { - return _PyStatus_OK(); + if (_Py_IsMainInterpreter(interp)) { + // All other static types (unless initialized elsewhere) + for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) { + PyTypeObject *type = static_types[i]; + if (_PyStaticType_InitBuiltin(type) < 0) { + return _PyStatus_ERR("Can't initialize builtin type"); + } + if (type == &PyType_Type) { + // Sanitify checks of the two most important types + assert(PyBaseObject_Type.tp_base == NULL); + assert(PyType_Type.tp_base == &PyBaseObject_Type); + } + } } - // All other static types (unless initialized elsewhere) - for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) { - PyTypeObject *type = static_types[i]; - if (_PyStaticType_InitBuiltin(type) < 0) { - return _PyStatus_ERR("Can't initialize builtin type"); - } - if (type == &PyType_Type) { - // Sanitify checks of the two most important types - assert(PyBaseObject_Type.tp_base == NULL); - assert(PyType_Type.tp_base == &PyBaseObject_Type); - } + // Must be after static types are initialized + if (_Py_initialize_generic(interp) < 0) { + return _PyStatus_ERR("Can't initialize Generic type"); } return _PyStatus_OK(); diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 03246495f4a379..6339afd2d1e242 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1074,7 +1074,12 @@ generic_class_getitem(PyTypeObject *cls, PyObject *args, PyObject *kwargs) PyObject * _Py_subscript_generic(PyObject *params) { - PyObject *args = PyTuple_Pack(2, &_PyGeneric_Type, params); + PyInterpreterState *interp = PyInterpreterState_Get(); + if (interp->types.generic_type == NULL) { + PyErr_SetString(PyExc_SystemError, "Cannot find Generic type"); + return NULL; + } + PyObject *args = PyTuple_Pack(2, interp->types.generic_type, params); if (args == NULL) { return NULL; } @@ -1091,12 +1096,25 @@ static PyMethodDef generic_methods[] = { {NULL} /* Sentinel */ }; -PyTypeObject _PyGeneric_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "typing.Generic", - .tp_basicsize = sizeof(PyObject), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_doc = generic_doc, - .tp_methods = generic_methods, - .tp_new = PyType_GenericNew, +static PyType_Slot generic_slots[] = { + {Py_tp_doc, (void *)generic_doc}, + {Py_tp_methods, generic_methods}, + {0, NULL}, +}; + +PyType_Spec generic_spec = { + .name = "typing.Generic", + .basicsize = sizeof(PyObject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .slots = generic_slots, }; + +int _Py_initialize_generic(PyInterpreterState *interp) +{ + PyObject *type = PyType_FromSpec(&generic_spec); + if (type == NULL) { + return -1; + } + interp->types.generic_type = type; + return 0; +} diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index acf7f8d8a1bcf4..3eb2b04e52972f 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3096,7 +3096,6 @@ _PyBuiltin_Init(PyInterpreterState *interp) SETBUILTIN("TypeVar", &_PyTypeVar_Type); SETBUILTIN("TypeVarTuple", &_PyTypeVarTuple_Type); SETBUILTIN("ParamSpec", &_PyParamSpec_Type); - SETBUILTIN("Generic", &_PyGeneric_Type); debug = PyBool_FromLong(config->optimization_level == 0); if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { Py_DECREF(debug); diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index d6627bc6b7e86b..8d47334b9112d8 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1702,6 +1702,7 @@ finalize_interp_clear(PyThreadState *tstate) int is_main_interp = _Py_IsMainInterpreter(tstate->interp); _PyExc_ClearExceptionGroupType(tstate->interp); + Py_CLEAR(tstate->interp->types.generic_type); /* Clear interpreter state and all thread states */ _PyInterpreterState_Clear(tstate); From 8991bb132521dab1791e6448629693aa2d9bb712 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 06:44:03 -0600 Subject: [PATCH 059/200] Better way to set __type_variables__ in the class --- Python/compile.c | 24 ++++-------------------- Python/symtable.c | 20 ++++---------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 299b96a1e068e8..2a93251f3ce961 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2347,26 +2347,10 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } static int -compiler_set_type_params_in_class(struct compiler *c, location loc, asdl_typeparam_seq *typeparams) +compiler_set_type_params_in_class(struct compiler *c, location loc) { - Py_ssize_t count = asdl_seq_LEN(typeparams); - for (Py_ssize_t i = 0; i < count; i++) { - typeparam_ty typeparam = asdl_seq_GET(typeparams, i); - PyObject *name; - switch(typeparam->kind) { - case TypeVar_kind: - name = typeparam->v.TypeVar.name; - break; - case TypeVarTuple_kind: - name = typeparam->v.TypeVarTuple.name; - break; - case ParamSpec_kind: - name = typeparam->v.ParamSpec.name; - break; - } - RETURN_IF_ERROR(compiler_nameop(c, loc, name, Load)); - } - ADDOP_I(c, loc, BUILD_TUPLE, count); + _Py_DECLARE_STR(type_params, ".type_params"); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_ID(__type_variables__), Store)); return 1; } @@ -2442,7 +2426,7 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } if (typeparams) { - if (!compiler_set_type_params_in_class(c, loc, typeparams)) { + if (!compiler_set_type_params_in_class(c, loc)) { compiler_exit_scope(c); return ERROR; } diff --git a/Python/symtable.c b/Python/symtable.c index e9dac27033ef69..13704de71a6530 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1333,22 +1333,10 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) DEF_LOCAL, LOCATION(s))) { VISIT_QUIT(st, 0); } - for (Py_ssize_t i = 0; i < asdl_seq_LEN(s->v.ClassDef.typeparams); i++) { - typeparam_ty tp = asdl_seq_GET(s->v.ClassDef.typeparams, i); - PyObject *name; - switch (tp->kind) { - case TypeVar_kind: - name = tp->v.TypeVar.name; - break; - case ParamSpec_kind: - name = tp->v.ParamSpec.name; - break; - case TypeVarTuple_kind: - name = tp->v.TypeVarTuple.name; - break; - } - if (!symtable_add_def(st, name, USE, LOCATION(s))) - VISIT_QUIT(st, 0); + _Py_DECLARE_STR(type_params, ".type_params"); + if (!symtable_add_def(st, &_Py_STR(type_params), + USE, LOCATION(s))) { + VISIT_QUIT(st, 0); } } VISIT_SEQ(st, stmt, s->v.ClassDef.body); From c3f520a7b55d66d03ce849ded90fd8d2daf9db76 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 07:03:18 -0600 Subject: [PATCH 060/200] Fix TypeVar | "ForwardRef" --- Lib/typing.py | 4 ++++ Objects/typevarobject.c | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index ffef421d0fb545..282a50b49e31fb 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -697,6 +697,10 @@ def Union(self, parameters): return _UnionGenericAlias(self, parameters, name="Optional") return _UnionGenericAlias(self, parameters) +def _make_union(left, right): + """Used from the C implementation of TypeVar.""" + return Union[left, right] + @_SpecialForm def Optional(self, parameters): """Optional type. diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 6339afd2d1e242..b779a5c071c6e1 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -70,6 +70,15 @@ static PyObject *type_check(PyObject *arg) { return call_typing_func_object("_type_check", args); } +static PyObject * +make_union(PyObject *self, PyObject *other) { + PyObject *args = PyTuple_Pack(2, self, other); + if (args == NULL) { + return NULL; + } + return call_typing_func_object("_make_union", args); +} + static void typevarobject_dealloc(PyObject *self) { typevarobject *tv = (typevarobject *)self; @@ -256,7 +265,7 @@ static PyMethodDef typevar_methods[] = { }; static PyNumberMethods typevar_as_number = { - .nb_or = _Py_union_type_or, // Add __or__ function + .nb_or = make_union, }; PyDoc_STRVAR(typevar_doc, @@ -723,7 +732,7 @@ static PyMethodDef paramspec_methods[] = { }; static PyNumberMethods paramspec_as_number = { - .nb_or = _Py_union_type_or, // Add __or__ function + .nb_or = make_union, }; PyDoc_STRVAR(paramspec_doc, From e668ed87351d92ad740dbece766d1c358afe6ab4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 08:35:52 -0600 Subject: [PATCH 061/200] Make ParamSpecArgs and Kwargs not subclassable --- Objects/typevarobject.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index b779a5c071c6e1..4805581e3e5f79 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -410,6 +410,19 @@ paramspecargs_new_impl(PyTypeObject *type, PyObject *origin) return (PyObject *)paramspecargsobject_new(origin); } +static PyObject * +paramspecargs_mro_entries(PyObject *self, PyObject *args) +{ + PyErr_SetString(PyExc_TypeError, + "Cannot subclass an instance of ParamSpecArgs"); + return NULL; +} + +static PyMethodDef paramspecargs_methods[] = { + {"__mro_entries__", paramspecargs_mro_entries, METH_O}, + {0} +}; + PyDoc_STRVAR(paramspecargs_doc, "The args for a ParamSpec object.\n\ \n\ @@ -435,6 +448,7 @@ PyTypeObject _PyParamSpecArgs_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = paramspecargsobject_traverse, .tp_members = paramspecargs_members, + .tp_methods = paramspecargs_methods, .tp_new = paramspecargs_new, .tp_doc = paramspecargs_doc, }; @@ -520,6 +534,19 @@ paramspeckwargs_new_impl(PyTypeObject *type, PyObject *origin) return (PyObject *)paramspeckwargsobject_new(origin); } +static PyObject * +paramspeckwargs_mro_entries(PyObject *self, PyObject *args) +{ + PyErr_SetString(PyExc_TypeError, + "Cannot subclass an instance of ParamSpecKwargs"); + return NULL; +} + +static PyMethodDef paramspeckwargs_methods[] = { + {"__mro_entries__", paramspeckwargs_mro_entries, METH_O}, + {0} +}; + PyDoc_STRVAR(paramspeckwargs_doc, "The kwargs for a ParamSpec object.\n\ \n\ @@ -545,6 +572,7 @@ PyTypeObject _PyParamSpecKwargs_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, .tp_traverse = paramspeckwargsobject_traverse, .tp_members = paramspeckwargs_members, + .tp_methods = paramspeckwargs_methods, .tp_new = paramspeckwargs_new, .tp_doc = paramspeckwargs_doc, }; From 2b844f4b2ec4c8f965cabc4f970295f31fe6a100 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 08:57:49 -0600 Subject: [PATCH 062/200] Correctly unpack TypeVarTuple --- Lib/typing.py | 46 ++++++++++++---------- Objects/typevarobject.c | 86 ++++++++++++++++++++++++++++++----------- 2 files changed, 89 insertions(+), 43 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index 282a50b49e31fb..31f906afeea0b8 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -923,8 +923,7 @@ def _is_unpacked_typevartuple(x: Any) -> bool: def _is_typevar_like(x: Any) -> bool: - # TODO(PEP 695): remove TypeVarTuple here - return isinstance(x, (TypeVar, ParamSpec, TypeVarTuple)) or _is_unpacked_typevartuple(x) + return isinstance(x, (TypeVar, ParamSpec)) or _is_unpacked_typevartuple(x) class _PickleUsingNameMixin: @@ -1777,27 +1776,12 @@ def _lazy_load_getattr_static(): _cleanups.append(_lazy_load_getattr_static.cache_clear) -class _Dummy[T, *Ts, **P](): +class _Dummy1[T]: pass -TypeVar = type(_Dummy.__type_variables__[0]) -TypeVarTuple = type(_Dummy.__type_variables__[1]) -ParamSpec = type(_Dummy.__type_variables__[2]) -ParamSpecArgs = type(ParamSpec("P").args) -ParamSpecKwargs = type(ParamSpec("P").kwargs) -Generic = _Dummy.__mro__[1] - -def _pickle_psargs(psargs): - return ParamSpecArgs, (psargs.__origin__,) - -copyreg.pickle(ParamSpecArgs, _pickle_psargs) - -def _pickle_pskwargs(pskwargs): - return ParamSpecKwargs, (pskwargs.__origin__,) - -copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) - -del _Dummy, _pickle_psargs, _pickle_pskwargs +TypeVar = type(_Dummy1.__type_variables__[0]) +# Generic and Protocol must be defined before we can use a TypeVarTuple +Generic = _Dummy1.__mro__[1] class _ProtocolMeta(ABCMeta): @@ -1942,6 +1926,26 @@ def _proto_hook(other): cls.__init__ = _no_init_or_replace_init +class _Dummy2[*Ts, **P](): + pass + +TypeVarTuple = type(_Dummy2.__type_variables__[0]) +ParamSpec = type(_Dummy2.__type_variables__[1]) +ParamSpecArgs = type(ParamSpec("P").args) +ParamSpecKwargs = type(ParamSpec("P").kwargs) + +def _pickle_psargs(psargs): + return ParamSpecArgs, (psargs.__origin__,) + +copyreg.pickle(ParamSpecArgs, _pickle_psargs) + +def _pickle_pskwargs(pskwargs): + return ParamSpecKwargs, (pskwargs.__origin__,) + +copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) + +del _Dummy1, _Dummy2, _pickle_psargs, _pickle_pskwargs + class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True): """Runtime representation of an annotated type. diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 4805581e3e5f79..c9da87db514641 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -835,36 +835,37 @@ static void typevartupleobject_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } -static PyObject *typevartupleobject_iter(PyObject *self) +static PyObject *typevartuple_unpack(PyObject *tvt) { - PyObject *typing = NULL; - PyObject *unpack = NULL; - PyObject *unpacked = NULL; - PyObject *tuple = NULL; - PyObject *result = NULL; - - typing = PyImport_ImportModule("typing"); + PyObject *typing = PyImport_ImportModule("typing"); if (typing == NULL) { - goto exit; + return NULL; } - unpack = PyObject_GetAttrString(typing, "Unpack"); + PyObject *unpack = PyObject_GetAttrString(typing, "Unpack"); if (unpack == NULL) { - goto exit; + Py_DECREF(typing); + return NULL; } - unpacked = PyObject_GetItem(unpack, self); + PyObject *unpacked = PyObject_GetItem(unpack, tvt); + Py_DECREF(typing); + Py_DECREF(unpack); + return unpacked; +} + +static PyObject *typevartupleobject_iter(PyObject *self) +{ + PyObject *unpacked = typevartuple_unpack(self); if (unpacked == NULL) { - goto exit; + return NULL; } - tuple = PyTuple_Pack(1, unpacked); + PyObject *tuple = PyTuple_Pack(1, unpacked); if (tuple == NULL) { - goto exit; + Py_DECREF(unpacked); + return NULL; } - result = PyObject_GetIter(tuple); -exit: - Py_XDECREF(typing); - Py_XDECREF(unpack); - Py_XDECREF(unpacked); - Py_XDECREF(tuple); + PyObject *result = PyObject_GetIter(tuple); + Py_DECREF(unpacked); + Py_DECREF(tuple); return result; } @@ -1108,9 +1109,47 @@ generic_class_getitem(PyTypeObject *cls, PyObject *args, PyObject *kwargs) return call_typing_args_kwargs("_generic_class_getitem", cls, args, kwargs); } +static int +contains_typevartuple(PyTupleObject *params) +{ + Py_ssize_t n = PyTuple_GET_SIZE(params); + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *param = PyTuple_GET_ITEM(params, i); + if (Py_TYPE(param) == &_PyTypeVarTuple_Type) { + return 1; + } + } + return 0; +} + PyObject * _Py_subscript_generic(PyObject *params) { + assert(PyTuple_Check(params)); + // TypeVarTuple must be unpacked when passed to Generic, so we do that here. + if (contains_typevartuple((PyTupleObject *)params)) { + Py_ssize_t n = PyTuple_GET_SIZE(params); + PyObject *new_params = PyTuple_New(n); + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *param = PyTuple_GET_ITEM(params, i); + if (Py_TYPE(param) == &_PyTypeVarTuple_Type) { + PyObject *unpacked = typevartuple_unpack(param); + if (unpacked == NULL) { + Py_DECREF(new_params); + return NULL; + } + PyTuple_SET_ITEM(new_params, i, unpacked); + } + else { + PyTuple_SET_ITEM(new_params, i, Py_NewRef(param)); + } + } + params = new_params; + } + else { + Py_INCREF(params); + } + PyInterpreterState *interp = PyInterpreterState_Get(); if (interp->types.generic_type == NULL) { PyErr_SetString(PyExc_SystemError, "Cannot find Generic type"); @@ -1120,7 +1159,10 @@ _Py_subscript_generic(PyObject *params) if (args == NULL) { return NULL; } - return call_typing_func_object("_generic_class_getitem", args); + PyObject *result = call_typing_func_object("_generic_class_getitem", args); + Py_DECREF(args); + Py_DECREF(params); + return result; } static PyMethodDef generic_methods[] = { From 47d24d9197d48d6fa0d789f6bae93523b75757ba Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 10:44:40 -0600 Subject: [PATCH 063/200] Add support for type aliases (but not for computing the value) --- Include/internal/pycore_intrinsics.h | 3 +- Include/internal/pycore_typevarobject.h | 2 + Objects/clinic/typevarobject.c.h | 19 +++- Objects/typevarobject.c | 116 +++++++++++++++++++++++- Python/compile.c | 69 ++++++++++++++ Python/intrinsics.c | 1 + Python/symtable.c | 25 +++++ 7 files changed, 232 insertions(+), 3 deletions(-) diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index 5918067fd3aaf7..cb6240b5b309d5 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -11,8 +11,9 @@ #define INTRINSIC_PARAMSPEC 8 #define INTRINSIC_TYPEVARTUPLE 9 #define INTRINSIC_SUBSCRIPT_GENERIC 10 +#define INTRINSIC_TYPEALIAS 11 -#define MAX_INTRINSIC_1 10 +#define MAX_INTRINSIC_1 11 /* Binary Functions: */ diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index 3065cd066d1c8b..2b28ca0f54079d 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -13,10 +13,12 @@ extern PyTypeObject _PyTypeVarTuple_Type; extern PyTypeObject _PyParamSpec_Type; extern PyTypeObject _PyParamSpecArgs_Type; extern PyTypeObject _PyParamSpecKwargs_Type; +extern PyTypeObject _PyTypeAlias_Type; extern PyObject *_Py_make_typevar(const char *, PyObject *); extern PyObject *_Py_make_paramspec(const char *); extern PyObject *_Py_make_typevartuple(const char *); +extern PyObject *_Py_make_typealias(PyThreadState* unused, PyObject *); extern PyObject *_Py_subscript_generic(PyObject *); extern int _Py_initialize_generic(PyInterpreterState *); diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index bf96d9815998a4..c4a8709951953d 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -722,4 +722,21 @@ typevartuple_reduce(typevartupleobject *self, PyObject *Py_UNUSED(ignored)) { return typevartuple_reduce_impl(self); } -/*[clinic end generated code: output=ac9f83f64eee2f90 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(typealias_reduce__doc__, +"__reduce__($self, /)\n" +"--\n" +"\n"); + +#define TYPEALIAS_REDUCE_METHODDEF \ + {"__reduce__", (PyCFunction)typealias_reduce, METH_NOARGS, typealias_reduce__doc__}, + +static PyObject * +typealias_reduce_impl(typealiasobject *self); + +static PyObject * +typealias_reduce(typealiasobject *self, PyObject *Py_UNUSED(ignored)) +{ + return typealias_reduce_impl(self); +} +/*[clinic end generated code: output=92385d7cbb5c1b03 input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index c9da87db514641..8fa7bafe5aa4c7 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -11,9 +11,10 @@ class paramspec "paramspecobject *" "&_PyParamSpec_Type" class paramspecargs "paramspecargsobject *" "&_PyParamSpecArgs_Type" class paramspeckwargs "paramspeckwargsobject *" "&_PyParamSpecKwargs_Type" class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" +class typealias "typealiasobject *" "&_PyTypeAlias_Type" class Generic "PyObject *" "&PyGeneric_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=9b0f1a94d4a27c0c]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=a775b1d0f0b88d23]*/ typedef struct { PyObject_HEAD @@ -39,6 +40,14 @@ typedef struct { bool autovariance; } paramspecobject; +typedef struct { + PyObject_HEAD + const char *name; + PyObject *type_params; + PyObject *compute_value; + PyObject *value; +} typealiasobject; + #include "clinic/typevarobject.c.h" static PyObject *call_typing_func_object(const char *name, PyObject *args) { @@ -1030,6 +1039,111 @@ PyObject *_Py_make_typevartuple(const char *name) { return (PyObject *)typevartupleobject_alloc(name); } +static void +typealias_dealloc(PyObject *self) +{ + typealiasobject *ta = (typealiasobject *)self; + free((void *)ta->name); + Py_XDECREF(ta->type_params); + Py_XDECREF(ta->compute_value); + Py_XDECREF(ta->value); + Py_TYPE(self)->tp_free(self); +} + +static PyObject * +typealias_repr(PyObject *self) +{ + typealiasobject *ta = (typealiasobject *)self; + return PyUnicode_FromFormat("%s", ta->name); +} + +static PyMemberDef typealias_members[] = { + {"__name__", T_STRING, offsetof(typealiasobject, name), READONLY}, + {"__type_params__", T_OBJECT, offsetof(typealiasobject, type_params), READONLY}, + {0} +}; + +static typealiasobject * +typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) +{ + typealiasobject *ta = PyObject_GC_New(typealiasobject, &_PyTypeAlias_Type); + if (ta == NULL) { + return NULL; + } + ta->name = strdup(name); + if (ta->name == NULL) { + Py_DECREF(ta); + return NULL; + } + ta->type_params = Py_XNewRef(type_params); + ta->compute_value = Py_NewRef(compute_value); + ta->value = NULL; + PyObject_GC_Track(ta); + return ta; +} + +static int typealias_traverse(typealiasobject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->type_params); + Py_VISIT(self->compute_value); + Py_VISIT(self->value); + return 0; +} + +/*[clinic input] +typealias.__reduce__ as typealias_reduce + +[clinic start generated code]*/ + +static PyObject * +typealias_reduce_impl(typealiasobject *self) +/*[clinic end generated code: output=913724f92ad3b39b input=4f06fbd9472ec0f1]*/ +{ + return PyUnicode_FromString(self->name); +} + +static PyMethodDef typealias_methods[] = { + TYPEALIAS_REDUCE_METHODDEF + {0} +}; + +PyDoc_STRVAR(typealias_doc, +"Type alias.\n\ +\n\ +Type aliases are created through the type statement:\n\ +\n\ + type Alias = int\n\ +"); + +PyTypeObject _PyTypeAlias_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + .tp_name = "TypeAlias", + .tp_basicsize = sizeof(typealiasobject), + .tp_dealloc = typealias_dealloc, + .tp_repr = typealias_repr, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .tp_members = typealias_members, + .tp_methods = typealias_methods, + .tp_doc = typealias_doc, + .tp_traverse = typealias_traverse, +}; + +PyObject * +_Py_make_typealias(PyThreadState* unused, PyObject *args) +{ + assert(PyTuple_Check(args)); + assert(PyTuple_GET_SIZE(args) == 3); + PyObject *name = PyTuple_GET_ITEM(args, 0); + assert(PyUnicode_Check(name)); + const char *name_str = PyUnicode_AsUTF8(name); + if (name_str == NULL) { + return NULL; + } + PyObject *type_params = PyTuple_GET_ITEM(args, 1); + PyObject *compute_value = PyTuple_GET_ITEM(args, 2); + return (PyObject *)typealias_alloc(name_str, type_params, compute_value); +} + PyDoc_STRVAR(generic_doc, "Abstract base class for generic types.\n\ \n\ diff --git a/Python/compile.c b/Python/compile.c index 2a93251f3ce961..f7d2b705fb063e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2522,6 +2522,73 @@ compiler_class(struct compiler *c, stmt_ty s) return SUCCESS; } +static int +compiler_typealias(struct compiler *c, stmt_ty s) +{ + location loc = LOC(s); + asdl_typeparam_seq *typeparams = s->v.TypeAlias.typeparams; + PyObject *name = s->v.TypeAlias.name->v.Name.id; + if (typeparams) { + ADDOP(c, loc, PUSH_NULL); + PyObject *typeparams_name = PyUnicode_FromFormat("", + name); + if (!typeparams_name) { + return ERROR; + } + if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_TYPEPARAMS, + (void *)typeparams, loc.lineno) == -1) { + Py_DECREF(typeparams_name); + return ERROR; + } + Py_DECREF(typeparams_name); + ADDOP_LOAD_CONST(c, loc, name); + RETURN_IF_ERROR(compiler_type_params(c, typeparams)); + } + else { + ADDOP_LOAD_CONST(c, loc, name); + ADDOP_LOAD_CONST(c, loc, Py_None); + } + RETURN_IF_ERROR( + compiler_enter_scope(c, name, COMPILER_SCOPE_FUNCTION, s, loc.lineno)); + /* Make None the first constant, so the evaluate function can't have a + docstring. */ + RETURN_IF_ERROR(compiler_add_const(c->c_const_cache, c->u, Py_None)); + VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); + ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); + PyCodeObject *co = assemble(c, 1); + compiler_exit_scope(c); + if (co == NULL) { + return ERROR; + } + if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + ADDOP_I(c, loc, BUILD_TUPLE, 3); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); + if (typeparams) { + int is_in_class = c->u->u_ste->ste_type_params_in_class; + c->u->u_argcount = is_in_class; + PyCodeObject *co = assemble(c, 0); + compiler_exit_scope(c); + if (co == NULL) { + return ERROR; + } + if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + if (is_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + } + ADDOP_I(c, loc, CALL, is_in_class); + } + RETURN_IF_ERROR(compiler_nameop(c, loc, name, Store)); + return SUCCESS; +} + /* Return false if the expression is a constant value except named singletons. Return true otherwise. */ static bool @@ -3732,6 +3799,8 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s) return compiler_function(c, s, 0); case ClassDef_kind: return compiler_class(c, s); + case TypeAlias_kind: + return compiler_typealias(c, s); case Return_kind: return compiler_return(c, s); case Delete_kind: diff --git a/Python/intrinsics.c b/Python/intrinsics.c index fa76da47b9c71e..0e74ed1371a9e5 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -240,6 +240,7 @@ _PyIntrinsics_UnaryFunctions[] = { [INTRINSIC_PARAMSPEC] = make_paramspec, [INTRINSIC_TYPEVARTUPLE] = make_typevartuple, [INTRINSIC_SUBSCRIPT_GENERIC] = subscript_generic, + [INTRINSIC_TYPEALIAS] = _Py_make_typealias, }; diff --git a/Python/symtable.c b/Python/symtable.c index 13704de71a6530..0ed0423cd9852e 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1349,6 +1349,31 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) } break; } + case TypeAlias_kind: + VISIT(st, expr, s->v.TypeAlias.name); + assert(s->v.TypeAlias.name->kind == Name_kind); + PyObject *name = s->v.TypeAlias.name->v.Name.id; + if (s->v.TypeAlias.typeparams) { + if (!symtable_enter_typeparam_block( + st, name, + (void *)s->v.TypeAlias.typeparams, + false, false, false, + LOCATION(s))) { + VISIT_QUIT(st, 0); + } + VISIT_SEQ(st, typeparam, s->v.TypeAlias.typeparams); + } + if (!symtable_enter_block(st, name, FunctionBlock, + (void *)s, LOCATION(s))) + VISIT_QUIT(st, 0); + VISIT(st, expr, s->v.TypeAlias.value); + if (!symtable_exit_block(st)) + VISIT_QUIT(st, 0); + if (s->v.TypeAlias.typeparams) { + if (!symtable_exit_block(st)) + VISIT_QUIT(st, 0); + } + break; case Return_kind: if (s->v.Return.value) { VISIT(st, expr, s->v.Return.value); From 6312d7bdd84f6821a307b4a09156d885a6230f2d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 11:10:06 -0600 Subject: [PATCH 064/200] fix merge --- Parser/parser.c | 10007 ++++++++--------------------------- Python/compile.c | 20 +- Python/generated_cases.c.h | 490 ++ 3 files changed, 2721 insertions(+), 7796 deletions(-) diff --git a/Parser/parser.c b/Parser/parser.c index 7f61b3ca7b2d71..5c32918859a319 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -176,7 +176,6 @@ static char *soft_keywords[] = { #define positional_patterns_type 1095 #define keyword_patterns_type 1096 #define keyword_pattern_type 1097 -<<<<<<< HEAD #define type_alias_type 1098 #define type_params_type 1099 #define type_param_seq_type 1100 @@ -231,758 +230,372 @@ static char *soft_keywords[] = { #define lambda_param_with_default_type 1149 #define lambda_param_maybe_default_type 1150 #define lambda_param_type 1151 -#define strings_type 1152 -#define list_type 1153 -#define tuple_type 1154 -#define set_type 1155 -#define dict_type 1156 -#define double_starred_kvpairs_type 1157 -#define double_starred_kvpair_type 1158 -#define kvpair_type 1159 -#define for_if_clauses_type 1160 -#define for_if_clause_type 1161 -#define listcomp_type 1162 -#define setcomp_type 1163 -#define genexp_type 1164 -#define dictcomp_type 1165 -#define arguments_type 1166 -#define args_type 1167 -#define kwargs_type 1168 -#define starred_expression_type 1169 -#define kwarg_or_starred_type 1170 -#define kwarg_or_double_starred_type 1171 -#define star_targets_type 1172 -#define star_targets_list_seq_type 1173 -#define star_targets_tuple_seq_type 1174 -#define star_target_type 1175 -#define target_with_star_atom_type 1176 -#define star_atom_type 1177 -#define single_target_type 1178 -#define single_subscript_attribute_target_type 1179 -#define t_primary_type 1180 // Left-recursive -#define t_lookahead_type 1181 -#define del_targets_type 1182 -#define del_target_type 1183 -#define del_t_atom_type 1184 -#define type_expressions_type 1185 -#define func_type_comment_type 1186 -#define invalid_arguments_type 1187 -#define invalid_kwarg_type 1188 -#define expression_without_invalid_type 1189 -#define invalid_legacy_expression_type 1190 -#define invalid_expression_type 1191 -#define invalid_named_expression_type 1192 -#define invalid_assignment_type 1193 -#define invalid_ann_assign_target_type 1194 -#define invalid_del_stmt_type 1195 -#define invalid_block_type 1196 -#define invalid_comprehension_type 1197 -#define invalid_dict_comprehension_type 1198 -#define invalid_parameters_type 1199 -#define invalid_default_type 1200 -#define invalid_star_etc_type 1201 -#define invalid_kwds_type 1202 -#define invalid_parameters_helper_type 1203 -#define invalid_lambda_parameters_type 1204 -#define invalid_lambda_parameters_helper_type 1205 -#define invalid_lambda_star_etc_type 1206 -#define invalid_lambda_kwds_type 1207 -#define invalid_double_type_comments_type 1208 -#define invalid_with_item_type 1209 -#define invalid_for_target_type 1210 -#define invalid_group_type 1211 -#define invalid_import_type 1212 -#define invalid_import_from_targets_type 1213 -#define invalid_with_stmt_type 1214 -#define invalid_with_stmt_indent_type 1215 -#define invalid_try_stmt_type 1216 -#define invalid_except_stmt_type 1217 -#define invalid_finally_stmt_type 1218 -#define invalid_except_stmt_indent_type 1219 -#define invalid_except_star_stmt_indent_type 1220 -#define invalid_match_stmt_type 1221 -#define invalid_case_block_type 1222 -#define invalid_as_pattern_type 1223 -#define invalid_class_pattern_type 1224 -#define invalid_class_argument_pattern_type 1225 -#define invalid_if_stmt_type 1226 -#define invalid_elif_stmt_type 1227 -#define invalid_else_stmt_type 1228 -#define invalid_while_stmt_type 1229 -#define invalid_for_stmt_type 1230 -#define invalid_def_raw_type 1231 -#define invalid_class_def_raw_type 1232 -#define invalid_double_starred_kvpairs_type 1233 -#define invalid_kvpair_type 1234 -#define invalid_starred_expression_type 1235 -#define _loop0_1_type 1236 -#define _loop0_2_type 1237 -#define _loop1_3_type 1238 -#define _loop0_5_type 1239 -#define _gather_4_type 1240 -#define _tmp_6_type 1241 -#define _tmp_7_type 1242 -#define _tmp_8_type 1243 -#define _tmp_9_type 1244 -#define _tmp_10_type 1245 -#define _tmp_11_type 1246 -#define _tmp_12_type 1247 -#define _tmp_13_type 1248 -#define _loop1_14_type 1249 -#define _tmp_15_type 1250 -#define _tmp_16_type 1251 -#define _tmp_17_type 1252 -#define _loop0_19_type 1253 -#define _gather_18_type 1254 -#define _loop0_21_type 1255 -#define _gather_20_type 1256 -#define _tmp_22_type 1257 -#define _tmp_23_type 1258 -#define _loop0_24_type 1259 -#define _loop1_25_type 1260 -#define _loop0_27_type 1261 -#define _gather_26_type 1262 -#define _tmp_28_type 1263 -#define _loop0_30_type 1264 -#define _gather_29_type 1265 -#define _tmp_31_type 1266 -#define _loop1_32_type 1267 -#define _tmp_33_type 1268 -#define _tmp_34_type 1269 -#define _tmp_35_type 1270 -#define _loop0_36_type 1271 -#define _loop0_37_type 1272 -#define _loop0_38_type 1273 -#define _loop1_39_type 1274 -#define _loop0_40_type 1275 -#define _loop1_41_type 1276 -#define _loop1_42_type 1277 -#define _loop1_43_type 1278 -#define _loop0_44_type 1279 -#define _loop1_45_type 1280 -#define _loop0_46_type 1281 -#define _loop1_47_type 1282 -#define _loop0_48_type 1283 -#define _loop0_49_type 1284 -#define _loop1_50_type 1285 -#define _loop0_52_type 1286 -#define _gather_51_type 1287 -#define _loop0_54_type 1288 -#define _gather_53_type 1289 -#define _loop0_56_type 1290 -#define _gather_55_type 1291 -#define _loop0_58_type 1292 -#define _gather_57_type 1293 -#define _tmp_59_type 1294 -#define _loop1_60_type 1295 -#define _loop1_61_type 1296 -#define _tmp_62_type 1297 -#define _tmp_63_type 1298 -#define _loop1_64_type 1299 -#define _loop0_66_type 1300 -#define _gather_65_type 1301 -#define _tmp_67_type 1302 -#define _tmp_68_type 1303 -#define _tmp_69_type 1304 -#define _tmp_70_type 1305 -#define _loop0_72_type 1306 -#define _gather_71_type 1307 -#define _loop0_74_type 1308 -#define _gather_73_type 1309 -#define _tmp_75_type 1310 -#define _loop0_77_type 1311 -#define _gather_76_type 1312 -#define _loop0_79_type 1313 -#define _gather_78_type 1314 -#define _loop0_81_type 1315 -#define _gather_80_type 1316 -#define _loop1_82_type 1317 -#define _loop1_83_type 1318 -#define _loop0_85_type 1319 -#define _gather_84_type 1320 -#define _loop1_86_type 1321 -#define _loop1_87_type 1322 -#define _loop1_88_type 1323 -#define _tmp_89_type 1324 -#define _loop0_91_type 1325 -#define _gather_90_type 1326 -#define _tmp_92_type 1327 -#define _tmp_93_type 1328 -#define _tmp_94_type 1329 -#define _tmp_95_type 1330 -#define _tmp_96_type 1331 -#define _loop0_97_type 1332 -#define _loop0_98_type 1333 -#define _loop0_99_type 1334 -#define _loop1_100_type 1335 -#define _loop0_101_type 1336 -#define _loop1_102_type 1337 -#define _loop1_103_type 1338 -#define _loop1_104_type 1339 -#define _loop0_105_type 1340 -#define _loop1_106_type 1341 -#define _loop0_107_type 1342 -#define _loop1_108_type 1343 -#define _loop0_109_type 1344 -#define _loop1_110_type 1345 -#define _loop1_111_type 1346 -#define _tmp_112_type 1347 -#define _loop0_114_type 1348 -#define _gather_113_type 1349 -#define _loop1_115_type 1350 -#define _loop0_116_type 1351 -#define _loop0_117_type 1352 -#define _tmp_118_type 1353 -#define _loop0_120_type 1354 -#define _gather_119_type 1355 -#define _tmp_121_type 1356 -#define _loop0_123_type 1357 -#define _gather_122_type 1358 -#define _loop0_125_type 1359 -#define _gather_124_type 1360 -#define _loop0_127_type 1361 -#define _gather_126_type 1362 -#define _loop0_129_type 1363 -#define _gather_128_type 1364 -#define _loop0_130_type 1365 -#define _loop0_132_type 1366 -#define _gather_131_type 1367 -#define _loop1_133_type 1368 -#define _tmp_134_type 1369 -#define _loop0_136_type 1370 -#define _gather_135_type 1371 -#define _loop0_138_type 1372 -#define _gather_137_type 1373 -#define _loop0_140_type 1374 -#define _gather_139_type 1375 -#define _loop0_142_type 1376 -#define _gather_141_type 1377 -#define _loop0_144_type 1378 -#define _gather_143_type 1379 -#define _tmp_145_type 1380 -#define _tmp_146_type 1381 -#define _tmp_147_type 1382 -#define _tmp_148_type 1383 -#define _tmp_149_type 1384 -#define _tmp_150_type 1385 -#define _tmp_151_type 1386 -#define _tmp_152_type 1387 -#define _tmp_153_type 1388 -#define _tmp_154_type 1389 -#define _tmp_155_type 1390 -#define _loop0_156_type 1391 -#define _loop0_157_type 1392 -#define _loop0_158_type 1393 -#define _tmp_159_type 1394 -#define _tmp_160_type 1395 -#define _tmp_161_type 1396 -#define _tmp_162_type 1397 -#define _tmp_163_type 1398 -#define _loop0_164_type 1399 -#define _loop0_165_type 1400 -#define _loop0_166_type 1401 -#define _loop1_167_type 1402 -#define _tmp_168_type 1403 -#define _loop0_169_type 1404 -#define _tmp_170_type 1405 -#define _loop0_171_type 1406 -#define _loop1_172_type 1407 -#define _tmp_173_type 1408 -#define _tmp_174_type 1409 -#define _tmp_175_type 1410 -#define _loop0_176_type 1411 -#define _tmp_177_type 1412 -#define _tmp_178_type 1413 -#define _loop1_179_type 1414 -#define _tmp_180_type 1415 -#define _loop0_181_type 1416 -#define _loop0_182_type 1417 -#define _loop0_183_type 1418 -#define _loop0_185_type 1419 -#define _gather_184_type 1420 -#define _tmp_186_type 1421 -#define _loop0_187_type 1422 -#define _tmp_188_type 1423 -#define _loop0_189_type 1424 -#define _loop1_190_type 1425 -#define _loop1_191_type 1426 -#define _tmp_192_type 1427 -#define _tmp_193_type 1428 -#define _loop0_194_type 1429 -#define _tmp_195_type 1430 -#define _tmp_196_type 1431 -#define _tmp_197_type 1432 -#define _loop0_199_type 1433 -#define _gather_198_type 1434 -#define _loop0_201_type 1435 -#define _gather_200_type 1436 -#define _loop0_203_type 1437 -#define _gather_202_type 1438 -#define _loop0_205_type 1439 -#define _gather_204_type 1440 -#define _tmp_206_type 1441 -#define _loop0_207_type 1442 -#define _loop1_208_type 1443 -#define _tmp_209_type 1444 -#define _loop0_210_type 1445 -#define _loop1_211_type 1446 -#define _tmp_212_type 1447 -#define _tmp_213_type 1448 -#define _tmp_214_type 1449 -#define _tmp_215_type 1450 -#define _tmp_216_type 1451 -#define _tmp_217_type 1452 -#define _tmp_218_type 1453 -#define _tmp_219_type 1454 -#define _tmp_220_type 1455 -#define _tmp_221_type 1456 -#define _loop0_223_type 1457 -#define _gather_222_type 1458 -#define _tmp_224_type 1459 -#define _tmp_225_type 1460 -#define _tmp_226_type 1461 -#define _tmp_227_type 1462 -#define _tmp_228_type 1463 -#define _tmp_229_type 1464 -#define _tmp_230_type 1465 -#define _tmp_231_type 1466 -#define _tmp_232_type 1467 -#define _tmp_233_type 1468 -#define _tmp_234_type 1469 -#define _tmp_235_type 1470 -#define _tmp_236_type 1471 -#define _tmp_237_type 1472 -#define _tmp_238_type 1473 -#define _tmp_239_type 1474 -#define _tmp_240_type 1475 -#define _tmp_241_type 1476 -#define _tmp_242_type 1477 -#define _tmp_243_type 1478 -#define _tmp_244_type 1479 -#define _tmp_245_type 1480 -#define _tmp_246_type 1481 -#define _tmp_247_type 1482 -#define _tmp_248_type 1483 -#define _tmp_249_type 1484 -#define _tmp_250_type 1485 -#define _tmp_251_type 1486 -#define _tmp_252_type 1487 -#define _tmp_253_type 1488 -======= -#define expressions_type 1098 -#define expression_type 1099 -#define yield_expr_type 1100 -#define star_expressions_type 1101 -#define star_expression_type 1102 -#define star_named_expressions_type 1103 -#define star_named_expression_type 1104 -#define assignment_expression_type 1105 -#define named_expression_type 1106 -#define disjunction_type 1107 -#define conjunction_type 1108 -#define inversion_type 1109 -#define comparison_type 1110 -#define compare_op_bitwise_or_pair_type 1111 -#define eq_bitwise_or_type 1112 -#define noteq_bitwise_or_type 1113 -#define lte_bitwise_or_type 1114 -#define lt_bitwise_or_type 1115 -#define gte_bitwise_or_type 1116 -#define gt_bitwise_or_type 1117 -#define notin_bitwise_or_type 1118 -#define in_bitwise_or_type 1119 -#define isnot_bitwise_or_type 1120 -#define is_bitwise_or_type 1121 -#define bitwise_or_type 1122 // Left-recursive -#define bitwise_xor_type 1123 // Left-recursive -#define bitwise_and_type 1124 // Left-recursive -#define shift_expr_type 1125 // Left-recursive -#define sum_type 1126 // Left-recursive -#define term_type 1127 // Left-recursive -#define factor_type 1128 -#define power_type 1129 -#define await_primary_type 1130 -#define primary_type 1131 // Left-recursive -#define slices_type 1132 -#define slice_type 1133 -#define atom_type 1134 -#define group_type 1135 -#define lambdef_type 1136 -#define lambda_params_type 1137 -#define lambda_parameters_type 1138 -#define lambda_slash_no_default_type 1139 -#define lambda_slash_with_default_type 1140 -#define lambda_star_etc_type 1141 -#define lambda_kwds_type 1142 -#define lambda_param_no_default_type 1143 -#define lambda_param_with_default_type 1144 -#define lambda_param_maybe_default_type 1145 -#define lambda_param_type 1146 -#define fstring_middle_type 1147 -#define fstring_replacement_field_type 1148 -#define fstring_conversion_type 1149 -#define fstring_full_format_spec_type 1150 -#define fstring_format_spec_type 1151 -#define string_type 1152 -#define strings_type 1153 -#define list_type 1154 -#define tuple_type 1155 -#define set_type 1156 -#define dict_type 1157 -#define double_starred_kvpairs_type 1158 -#define double_starred_kvpair_type 1159 -#define kvpair_type 1160 -#define for_if_clauses_type 1161 -#define for_if_clause_type 1162 -#define listcomp_type 1163 -#define setcomp_type 1164 -#define genexp_type 1165 -#define dictcomp_type 1166 -#define arguments_type 1167 -#define args_type 1168 -#define kwargs_type 1169 -#define starred_expression_type 1170 -#define kwarg_or_starred_type 1171 -#define kwarg_or_double_starred_type 1172 -#define star_targets_type 1173 -#define star_targets_list_seq_type 1174 -#define star_targets_tuple_seq_type 1175 -#define star_target_type 1176 -#define target_with_star_atom_type 1177 -#define star_atom_type 1178 -#define single_target_type 1179 -#define single_subscript_attribute_target_type 1180 -#define t_primary_type 1181 // Left-recursive -#define t_lookahead_type 1182 -#define del_targets_type 1183 -#define del_target_type 1184 -#define del_t_atom_type 1185 -#define type_expressions_type 1186 -#define func_type_comment_type 1187 -#define invalid_arguments_type 1188 -#define invalid_kwarg_type 1189 -#define expression_without_invalid_type 1190 -#define invalid_legacy_expression_type 1191 -#define invalid_expression_type 1192 -#define invalid_named_expression_type 1193 -#define invalid_assignment_type 1194 -#define invalid_ann_assign_target_type 1195 -#define invalid_del_stmt_type 1196 -#define invalid_block_type 1197 -#define invalid_comprehension_type 1198 -#define invalid_dict_comprehension_type 1199 -#define invalid_parameters_type 1200 -#define invalid_default_type 1201 -#define invalid_star_etc_type 1202 -#define invalid_kwds_type 1203 -#define invalid_parameters_helper_type 1204 -#define invalid_lambda_parameters_type 1205 -#define invalid_lambda_parameters_helper_type 1206 -#define invalid_lambda_star_etc_type 1207 -#define invalid_lambda_kwds_type 1208 -#define invalid_double_type_comments_type 1209 -#define invalid_with_item_type 1210 -#define invalid_for_target_type 1211 -#define invalid_group_type 1212 -#define invalid_import_type 1213 -#define invalid_import_from_targets_type 1214 -#define invalid_with_stmt_type 1215 -#define invalid_with_stmt_indent_type 1216 -#define invalid_try_stmt_type 1217 -#define invalid_except_stmt_type 1218 -#define invalid_finally_stmt_type 1219 -#define invalid_except_stmt_indent_type 1220 -#define invalid_except_star_stmt_indent_type 1221 -#define invalid_match_stmt_type 1222 -#define invalid_case_block_type 1223 -#define invalid_as_pattern_type 1224 -#define invalid_class_pattern_type 1225 -#define invalid_class_argument_pattern_type 1226 -#define invalid_if_stmt_type 1227 -#define invalid_elif_stmt_type 1228 -#define invalid_else_stmt_type 1229 -#define invalid_while_stmt_type 1230 -#define invalid_for_stmt_type 1231 -#define invalid_def_raw_type 1232 -#define invalid_class_def_raw_type 1233 -#define invalid_double_starred_kvpairs_type 1234 -#define invalid_kvpair_type 1235 -#define invalid_starred_expression_type 1236 -#define invalid_replacement_field_type 1237 -#define invalid_conversion_character_type 1238 -#define _loop0_1_type 1239 -#define _loop0_2_type 1240 -#define _loop0_3_type 1241 -#define _loop1_4_type 1242 -#define _loop0_6_type 1243 -#define _gather_5_type 1244 -#define _tmp_7_type 1245 -#define _tmp_8_type 1246 -#define _tmp_9_type 1247 -#define _tmp_10_type 1248 -#define _tmp_11_type 1249 -#define _tmp_12_type 1250 -#define _tmp_13_type 1251 -#define _tmp_14_type 1252 -#define _loop1_15_type 1253 -#define _tmp_16_type 1254 -#define _tmp_17_type 1255 -#define _tmp_18_type 1256 -#define _loop0_20_type 1257 -#define _gather_19_type 1258 -#define _loop0_22_type 1259 -#define _gather_21_type 1260 -#define _tmp_23_type 1261 -#define _tmp_24_type 1262 -#define _loop0_25_type 1263 -#define _loop1_26_type 1264 -#define _loop0_28_type 1265 -#define _gather_27_type 1266 -#define _tmp_29_type 1267 -#define _loop0_31_type 1268 -#define _gather_30_type 1269 -#define _tmp_32_type 1270 -#define _loop1_33_type 1271 -#define _tmp_34_type 1272 -#define _tmp_35_type 1273 -#define _tmp_36_type 1274 -#define _loop0_37_type 1275 -#define _loop0_38_type 1276 -#define _loop0_39_type 1277 -#define _loop1_40_type 1278 -#define _loop0_41_type 1279 -#define _loop1_42_type 1280 -#define _loop1_43_type 1281 -#define _loop1_44_type 1282 -#define _loop0_45_type 1283 -#define _loop1_46_type 1284 -#define _loop0_47_type 1285 -#define _loop1_48_type 1286 -#define _loop0_49_type 1287 -#define _loop0_50_type 1288 -#define _loop1_51_type 1289 -#define _loop0_53_type 1290 -#define _gather_52_type 1291 -#define _loop0_55_type 1292 -#define _gather_54_type 1293 -#define _loop0_57_type 1294 -#define _gather_56_type 1295 -#define _loop0_59_type 1296 -#define _gather_58_type 1297 -#define _tmp_60_type 1298 -#define _loop1_61_type 1299 -#define _loop1_62_type 1300 -#define _tmp_63_type 1301 -#define _tmp_64_type 1302 -#define _loop1_65_type 1303 -#define _loop0_67_type 1304 -#define _gather_66_type 1305 -#define _tmp_68_type 1306 -#define _tmp_69_type 1307 -#define _tmp_70_type 1308 -#define _tmp_71_type 1309 -#define _loop0_73_type 1310 -#define _gather_72_type 1311 -#define _loop0_75_type 1312 -#define _gather_74_type 1313 -#define _tmp_76_type 1314 -#define _loop0_78_type 1315 -#define _gather_77_type 1316 -#define _loop0_80_type 1317 -#define _gather_79_type 1318 -#define _loop1_81_type 1319 -#define _loop1_82_type 1320 -#define _loop0_84_type 1321 -#define _gather_83_type 1322 -#define _loop1_85_type 1323 -#define _loop1_86_type 1324 -#define _loop1_87_type 1325 -#define _tmp_88_type 1326 -#define _loop0_90_type 1327 -#define _gather_89_type 1328 -#define _tmp_91_type 1329 -#define _tmp_92_type 1330 -#define _tmp_93_type 1331 -#define _tmp_94_type 1332 -#define _tmp_95_type 1333 -#define _tmp_96_type 1334 -#define _loop0_97_type 1335 -#define _loop0_98_type 1336 -#define _loop0_99_type 1337 -#define _loop1_100_type 1338 -#define _loop0_101_type 1339 -#define _loop1_102_type 1340 -#define _loop1_103_type 1341 -#define _loop1_104_type 1342 -#define _loop0_105_type 1343 -#define _loop1_106_type 1344 -#define _loop0_107_type 1345 -#define _loop1_108_type 1346 -#define _loop0_109_type 1347 -#define _loop1_110_type 1348 -#define _tmp_111_type 1349 -#define _loop0_112_type 1350 -#define _loop1_113_type 1351 -#define _tmp_114_type 1352 -#define _loop0_116_type 1353 -#define _gather_115_type 1354 -#define _loop1_117_type 1355 -#define _loop0_118_type 1356 -#define _loop0_119_type 1357 -#define _tmp_120_type 1358 -#define _loop0_122_type 1359 -#define _gather_121_type 1360 -#define _tmp_123_type 1361 -#define _loop0_125_type 1362 -#define _gather_124_type 1363 -#define _loop0_127_type 1364 -#define _gather_126_type 1365 -#define _loop0_129_type 1366 -#define _gather_128_type 1367 -#define _loop0_131_type 1368 -#define _gather_130_type 1369 -#define _loop0_132_type 1370 -#define _loop0_134_type 1371 -#define _gather_133_type 1372 -#define _loop1_135_type 1373 -#define _tmp_136_type 1374 -#define _loop0_138_type 1375 -#define _gather_137_type 1376 -#define _loop0_140_type 1377 -#define _gather_139_type 1378 -#define _loop0_142_type 1379 -#define _gather_141_type 1380 -#define _loop0_144_type 1381 -#define _gather_143_type 1382 -#define _loop0_146_type 1383 -#define _gather_145_type 1384 -#define _tmp_147_type 1385 -#define _tmp_148_type 1386 -#define _tmp_149_type 1387 -#define _tmp_150_type 1388 -#define _tmp_151_type 1389 -#define _tmp_152_type 1390 -#define _tmp_153_type 1391 -#define _tmp_154_type 1392 -#define _tmp_155_type 1393 -#define _tmp_156_type 1394 -#define _tmp_157_type 1395 -#define _tmp_158_type 1396 -#define _loop0_159_type 1397 -#define _loop0_160_type 1398 -#define _loop0_161_type 1399 -#define _tmp_162_type 1400 -#define _tmp_163_type 1401 -#define _tmp_164_type 1402 -#define _tmp_165_type 1403 -#define _tmp_166_type 1404 -#define _loop0_167_type 1405 -#define _loop0_168_type 1406 -#define _loop0_169_type 1407 -#define _loop1_170_type 1408 -#define _tmp_171_type 1409 -#define _loop0_172_type 1410 -#define _tmp_173_type 1411 -#define _loop0_174_type 1412 -#define _loop1_175_type 1413 -#define _tmp_176_type 1414 -#define _tmp_177_type 1415 -#define _tmp_178_type 1416 -#define _loop0_179_type 1417 -#define _tmp_180_type 1418 -#define _tmp_181_type 1419 -#define _loop1_182_type 1420 -#define _tmp_183_type 1421 -#define _loop0_184_type 1422 -#define _loop0_185_type 1423 -#define _loop0_186_type 1424 -#define _loop0_188_type 1425 -#define _gather_187_type 1426 -#define _tmp_189_type 1427 -#define _loop0_190_type 1428 -#define _tmp_191_type 1429 -#define _loop0_192_type 1430 -#define _loop1_193_type 1431 -#define _loop1_194_type 1432 -#define _tmp_195_type 1433 -#define _tmp_196_type 1434 -#define _loop0_197_type 1435 -#define _tmp_198_type 1436 -#define _tmp_199_type 1437 -#define _tmp_200_type 1438 -#define _loop0_202_type 1439 -#define _gather_201_type 1440 -#define _loop0_204_type 1441 -#define _gather_203_type 1442 -#define _loop0_206_type 1443 -#define _gather_205_type 1444 -#define _loop0_208_type 1445 -#define _gather_207_type 1446 -#define _tmp_209_type 1447 -#define _loop0_210_type 1448 -#define _loop1_211_type 1449 -#define _tmp_212_type 1450 -#define _loop0_213_type 1451 -#define _loop1_214_type 1452 -#define _tmp_215_type 1453 -#define _tmp_216_type 1454 -#define _tmp_217_type 1455 -#define _tmp_218_type 1456 -#define _tmp_219_type 1457 -#define _tmp_220_type 1458 -#define _tmp_221_type 1459 -#define _tmp_222_type 1460 -#define _tmp_223_type 1461 -#define _tmp_224_type 1462 -#define _loop0_226_type 1463 -#define _gather_225_type 1464 -#define _tmp_227_type 1465 -#define _tmp_228_type 1466 -#define _tmp_229_type 1467 -#define _tmp_230_type 1468 -#define _tmp_231_type 1469 -#define _tmp_232_type 1470 -#define _tmp_233_type 1471 -#define _tmp_234_type 1472 -#define _tmp_235_type 1473 -#define _tmp_236_type 1474 -#define _tmp_237_type 1475 -#define _tmp_238_type 1476 -#define _tmp_239_type 1477 -#define _loop0_240_type 1478 -#define _tmp_241_type 1479 -#define _tmp_242_type 1480 -#define _tmp_243_type 1481 -#define _tmp_244_type 1482 -#define _tmp_245_type 1483 -#define _tmp_246_type 1484 -#define _tmp_247_type 1485 -#define _tmp_248_type 1486 -#define _tmp_249_type 1487 -#define _tmp_250_type 1488 -#define _tmp_251_type 1489 -#define _tmp_252_type 1490 -#define _tmp_253_type 1491 -#define _tmp_254_type 1492 -#define _tmp_255_type 1493 -#define _tmp_256_type 1494 -#define _tmp_257_type 1495 -#define _tmp_258_type 1496 -#define _tmp_259_type 1497 -#define _tmp_260_type 1498 -#define _tmp_261_type 1499 -#define _tmp_262_type 1500 -#define _tmp_263_type 1501 -#define _tmp_264_type 1502 -#define _tmp_265_type 1503 -#define _tmp_266_type 1504 -#define _tmp_267_type 1505 -#define _tmp_268_type 1506 -#define _tmp_269_type 1507 -#define _tmp_270_type 1508 -#define _tmp_271_type 1509 -#define _tmp_272_type 1510 ->>>>>>> upstream/main +#define fstring_middle_type 1152 +#define fstring_replacement_field_type 1153 +#define fstring_conversion_type 1154 +#define fstring_full_format_spec_type 1155 +#define fstring_format_spec_type 1156 +#define string_type 1157 +#define strings_type 1158 +#define list_type 1159 +#define tuple_type 1160 +#define set_type 1161 +#define dict_type 1162 +#define double_starred_kvpairs_type 1163 +#define double_starred_kvpair_type 1164 +#define kvpair_type 1165 +#define for_if_clauses_type 1166 +#define for_if_clause_type 1167 +#define listcomp_type 1168 +#define setcomp_type 1169 +#define genexp_type 1170 +#define dictcomp_type 1171 +#define arguments_type 1172 +#define args_type 1173 +#define kwargs_type 1174 +#define starred_expression_type 1175 +#define kwarg_or_starred_type 1176 +#define kwarg_or_double_starred_type 1177 +#define star_targets_type 1178 +#define star_targets_list_seq_type 1179 +#define star_targets_tuple_seq_type 1180 +#define star_target_type 1181 +#define target_with_star_atom_type 1182 +#define star_atom_type 1183 +#define single_target_type 1184 +#define single_subscript_attribute_target_type 1185 +#define t_primary_type 1186 // Left-recursive +#define t_lookahead_type 1187 +#define del_targets_type 1188 +#define del_target_type 1189 +#define del_t_atom_type 1190 +#define type_expressions_type 1191 +#define func_type_comment_type 1192 +#define invalid_arguments_type 1193 +#define invalid_kwarg_type 1194 +#define expression_without_invalid_type 1195 +#define invalid_legacy_expression_type 1196 +#define invalid_expression_type 1197 +#define invalid_named_expression_type 1198 +#define invalid_assignment_type 1199 +#define invalid_ann_assign_target_type 1200 +#define invalid_del_stmt_type 1201 +#define invalid_block_type 1202 +#define invalid_comprehension_type 1203 +#define invalid_dict_comprehension_type 1204 +#define invalid_parameters_type 1205 +#define invalid_default_type 1206 +#define invalid_star_etc_type 1207 +#define invalid_kwds_type 1208 +#define invalid_parameters_helper_type 1209 +#define invalid_lambda_parameters_type 1210 +#define invalid_lambda_parameters_helper_type 1211 +#define invalid_lambda_star_etc_type 1212 +#define invalid_lambda_kwds_type 1213 +#define invalid_double_type_comments_type 1214 +#define invalid_with_item_type 1215 +#define invalid_for_target_type 1216 +#define invalid_group_type 1217 +#define invalid_import_type 1218 +#define invalid_import_from_targets_type 1219 +#define invalid_with_stmt_type 1220 +#define invalid_with_stmt_indent_type 1221 +#define invalid_try_stmt_type 1222 +#define invalid_except_stmt_type 1223 +#define invalid_finally_stmt_type 1224 +#define invalid_except_stmt_indent_type 1225 +#define invalid_except_star_stmt_indent_type 1226 +#define invalid_match_stmt_type 1227 +#define invalid_case_block_type 1228 +#define invalid_as_pattern_type 1229 +#define invalid_class_pattern_type 1230 +#define invalid_class_argument_pattern_type 1231 +#define invalid_if_stmt_type 1232 +#define invalid_elif_stmt_type 1233 +#define invalid_else_stmt_type 1234 +#define invalid_while_stmt_type 1235 +#define invalid_for_stmt_type 1236 +#define invalid_def_raw_type 1237 +#define invalid_class_def_raw_type 1238 +#define invalid_double_starred_kvpairs_type 1239 +#define invalid_kvpair_type 1240 +#define invalid_starred_expression_type 1241 +#define invalid_replacement_field_type 1242 +#define invalid_conversion_character_type 1243 +#define _loop0_1_type 1244 +#define _loop0_2_type 1245 +#define _loop0_3_type 1246 +#define _loop1_4_type 1247 +#define _loop0_6_type 1248 +#define _gather_5_type 1249 +#define _tmp_7_type 1250 +#define _tmp_8_type 1251 +#define _tmp_9_type 1252 +#define _tmp_10_type 1253 +#define _tmp_11_type 1254 +#define _tmp_12_type 1255 +#define _tmp_13_type 1256 +#define _tmp_14_type 1257 +#define _loop1_15_type 1258 +#define _tmp_16_type 1259 +#define _tmp_17_type 1260 +#define _tmp_18_type 1261 +#define _loop0_20_type 1262 +#define _gather_19_type 1263 +#define _loop0_22_type 1264 +#define _gather_21_type 1265 +#define _tmp_23_type 1266 +#define _tmp_24_type 1267 +#define _loop0_25_type 1268 +#define _loop1_26_type 1269 +#define _loop0_28_type 1270 +#define _gather_27_type 1271 +#define _tmp_29_type 1272 +#define _loop0_31_type 1273 +#define _gather_30_type 1274 +#define _tmp_32_type 1275 +#define _loop1_33_type 1276 +#define _tmp_34_type 1277 +#define _tmp_35_type 1278 +#define _tmp_36_type 1279 +#define _loop0_37_type 1280 +#define _loop0_38_type 1281 +#define _loop0_39_type 1282 +#define _loop1_40_type 1283 +#define _loop0_41_type 1284 +#define _loop1_42_type 1285 +#define _loop1_43_type 1286 +#define _loop1_44_type 1287 +#define _loop0_45_type 1288 +#define _loop1_46_type 1289 +#define _loop0_47_type 1290 +#define _loop1_48_type 1291 +#define _loop0_49_type 1292 +#define _loop0_50_type 1293 +#define _loop1_51_type 1294 +#define _loop0_53_type 1295 +#define _gather_52_type 1296 +#define _loop0_55_type 1297 +#define _gather_54_type 1298 +#define _loop0_57_type 1299 +#define _gather_56_type 1300 +#define _loop0_59_type 1301 +#define _gather_58_type 1302 +#define _tmp_60_type 1303 +#define _loop1_61_type 1304 +#define _loop1_62_type 1305 +#define _tmp_63_type 1306 +#define _tmp_64_type 1307 +#define _loop1_65_type 1308 +#define _loop0_67_type 1309 +#define _gather_66_type 1310 +#define _tmp_68_type 1311 +#define _tmp_69_type 1312 +#define _tmp_70_type 1313 +#define _tmp_71_type 1314 +#define _loop0_73_type 1315 +#define _gather_72_type 1316 +#define _loop0_75_type 1317 +#define _gather_74_type 1318 +#define _tmp_76_type 1319 +#define _loop0_78_type 1320 +#define _gather_77_type 1321 +#define _loop0_80_type 1322 +#define _gather_79_type 1323 +#define _loop0_82_type 1324 +#define _gather_81_type 1325 +#define _loop1_83_type 1326 +#define _loop1_84_type 1327 +#define _loop0_86_type 1328 +#define _gather_85_type 1329 +#define _loop1_87_type 1330 +#define _loop1_88_type 1331 +#define _loop1_89_type 1332 +#define _tmp_90_type 1333 +#define _loop0_92_type 1334 +#define _gather_91_type 1335 +#define _tmp_93_type 1336 +#define _tmp_94_type 1337 +#define _tmp_95_type 1338 +#define _tmp_96_type 1339 +#define _tmp_97_type 1340 +#define _tmp_98_type 1341 +#define _loop0_99_type 1342 +#define _loop0_100_type 1343 +#define _loop0_101_type 1344 +#define _loop1_102_type 1345 +#define _loop0_103_type 1346 +#define _loop1_104_type 1347 +#define _loop1_105_type 1348 +#define _loop1_106_type 1349 +#define _loop0_107_type 1350 +#define _loop1_108_type 1351 +#define _loop0_109_type 1352 +#define _loop1_110_type 1353 +#define _loop0_111_type 1354 +#define _loop1_112_type 1355 +#define _tmp_113_type 1356 +#define _loop0_114_type 1357 +#define _loop1_115_type 1358 +#define _tmp_116_type 1359 +#define _loop0_118_type 1360 +#define _gather_117_type 1361 +#define _loop1_119_type 1362 +#define _loop0_120_type 1363 +#define _loop0_121_type 1364 +#define _tmp_122_type 1365 +#define _loop0_124_type 1366 +#define _gather_123_type 1367 +#define _tmp_125_type 1368 +#define _loop0_127_type 1369 +#define _gather_126_type 1370 +#define _loop0_129_type 1371 +#define _gather_128_type 1372 +#define _loop0_131_type 1373 +#define _gather_130_type 1374 +#define _loop0_133_type 1375 +#define _gather_132_type 1376 +#define _loop0_134_type 1377 +#define _loop0_136_type 1378 +#define _gather_135_type 1379 +#define _loop1_137_type 1380 +#define _tmp_138_type 1381 +#define _loop0_140_type 1382 +#define _gather_139_type 1383 +#define _loop0_142_type 1384 +#define _gather_141_type 1385 +#define _loop0_144_type 1386 +#define _gather_143_type 1387 +#define _loop0_146_type 1388 +#define _gather_145_type 1389 +#define _loop0_148_type 1390 +#define _gather_147_type 1391 +#define _tmp_149_type 1392 +#define _tmp_150_type 1393 +#define _tmp_151_type 1394 +#define _tmp_152_type 1395 +#define _tmp_153_type 1396 +#define _tmp_154_type 1397 +#define _tmp_155_type 1398 +#define _tmp_156_type 1399 +#define _tmp_157_type 1400 +#define _tmp_158_type 1401 +#define _tmp_159_type 1402 +#define _tmp_160_type 1403 +#define _loop0_161_type 1404 +#define _loop0_162_type 1405 +#define _loop0_163_type 1406 +#define _tmp_164_type 1407 +#define _tmp_165_type 1408 +#define _tmp_166_type 1409 +#define _tmp_167_type 1410 +#define _tmp_168_type 1411 +#define _loop0_169_type 1412 +#define _loop0_170_type 1413 +#define _loop0_171_type 1414 +#define _loop1_172_type 1415 +#define _tmp_173_type 1416 +#define _loop0_174_type 1417 +#define _tmp_175_type 1418 +#define _loop0_176_type 1419 +#define _loop1_177_type 1420 +#define _tmp_178_type 1421 +#define _tmp_179_type 1422 +#define _tmp_180_type 1423 +#define _loop0_181_type 1424 +#define _tmp_182_type 1425 +#define _tmp_183_type 1426 +#define _loop1_184_type 1427 +#define _tmp_185_type 1428 +#define _loop0_186_type 1429 +#define _loop0_187_type 1430 +#define _loop0_188_type 1431 +#define _loop0_190_type 1432 +#define _gather_189_type 1433 +#define _tmp_191_type 1434 +#define _loop0_192_type 1435 +#define _tmp_193_type 1436 +#define _loop0_194_type 1437 +#define _loop1_195_type 1438 +#define _loop1_196_type 1439 +#define _tmp_197_type 1440 +#define _tmp_198_type 1441 +#define _loop0_199_type 1442 +#define _tmp_200_type 1443 +#define _tmp_201_type 1444 +#define _tmp_202_type 1445 +#define _loop0_204_type 1446 +#define _gather_203_type 1447 +#define _loop0_206_type 1448 +#define _gather_205_type 1449 +#define _loop0_208_type 1450 +#define _gather_207_type 1451 +#define _loop0_210_type 1452 +#define _gather_209_type 1453 +#define _tmp_211_type 1454 +#define _loop0_212_type 1455 +#define _loop1_213_type 1456 +#define _tmp_214_type 1457 +#define _loop0_215_type 1458 +#define _loop1_216_type 1459 +#define _tmp_217_type 1460 +#define _tmp_218_type 1461 +#define _tmp_219_type 1462 +#define _tmp_220_type 1463 +#define _tmp_221_type 1464 +#define _tmp_222_type 1465 +#define _tmp_223_type 1466 +#define _tmp_224_type 1467 +#define _tmp_225_type 1468 +#define _tmp_226_type 1469 +#define _loop0_228_type 1470 +#define _gather_227_type 1471 +#define _tmp_229_type 1472 +#define _tmp_230_type 1473 +#define _tmp_231_type 1474 +#define _tmp_232_type 1475 +#define _tmp_233_type 1476 +#define _tmp_234_type 1477 +#define _tmp_235_type 1478 +#define _tmp_236_type 1479 +#define _tmp_237_type 1480 +#define _tmp_238_type 1481 +#define _tmp_239_type 1482 +#define _tmp_240_type 1483 +#define _tmp_241_type 1484 +#define _loop0_242_type 1485 +#define _tmp_243_type 1486 +#define _tmp_244_type 1487 +#define _tmp_245_type 1488 +#define _tmp_246_type 1489 +#define _tmp_247_type 1490 +#define _tmp_248_type 1491 +#define _tmp_249_type 1492 +#define _tmp_250_type 1493 +#define _tmp_251_type 1494 +#define _tmp_252_type 1495 +#define _tmp_253_type 1496 +#define _tmp_254_type 1497 +#define _tmp_255_type 1498 +#define _tmp_256_type 1499 +#define _tmp_257_type 1500 +#define _tmp_258_type 1501 +#define _tmp_259_type 1502 +#define _tmp_260_type 1503 +#define _tmp_261_type 1504 +#define _tmp_262_type 1505 +#define _tmp_263_type 1506 +#define _tmp_264_type 1507 +#define _tmp_265_type 1508 +#define _tmp_266_type 1509 +#define _tmp_267_type 1510 +#define _tmp_268_type 1511 +#define _tmp_269_type 1512 +#define _tmp_270_type 1513 +#define _tmp_271_type 1514 +#define _tmp_272_type 1515 +#define _tmp_273_type 1516 +#define _tmp_274_type 1517 static mod_ty file_rule(Parser *p); static mod_ty interactive_rule(Parser *p); @@ -1298,29 +911,6 @@ static asdl_seq *_gather_66_rule(Parser *p); static void *_tmp_68_rule(Parser *p); static void *_tmp_69_rule(Parser *p); static void *_tmp_70_rule(Parser *p); -<<<<<<< HEAD -static asdl_seq *_loop0_72_rule(Parser *p); -static asdl_seq *_gather_71_rule(Parser *p); -static asdl_seq *_loop0_74_rule(Parser *p); -static asdl_seq *_gather_73_rule(Parser *p); -static void *_tmp_75_rule(Parser *p); -static asdl_seq *_loop0_77_rule(Parser *p); -static asdl_seq *_gather_76_rule(Parser *p); -static asdl_seq *_loop0_79_rule(Parser *p); -static asdl_seq *_gather_78_rule(Parser *p); -static asdl_seq *_loop0_81_rule(Parser *p); -static asdl_seq *_gather_80_rule(Parser *p); -static asdl_seq *_loop1_82_rule(Parser *p); -static asdl_seq *_loop1_83_rule(Parser *p); -static asdl_seq *_loop0_85_rule(Parser *p); -static asdl_seq *_gather_84_rule(Parser *p); -static asdl_seq *_loop1_86_rule(Parser *p); -static asdl_seq *_loop1_87_rule(Parser *p); -static asdl_seq *_loop1_88_rule(Parser *p); -static void *_tmp_89_rule(Parser *p); -static asdl_seq *_loop0_91_rule(Parser *p); -static asdl_seq *_gather_90_rule(Parser *p); -======= static void *_tmp_71_rule(Parser *p); static asdl_seq *_loop0_73_rule(Parser *p); static asdl_seq *_gather_72_rule(Parser *p); @@ -1331,106 +921,74 @@ static asdl_seq *_loop0_78_rule(Parser *p); static asdl_seq *_gather_77_rule(Parser *p); static asdl_seq *_loop0_80_rule(Parser *p); static asdl_seq *_gather_79_rule(Parser *p); -static asdl_seq *_loop1_81_rule(Parser *p); -static asdl_seq *_loop1_82_rule(Parser *p); -static asdl_seq *_loop0_84_rule(Parser *p); -static asdl_seq *_gather_83_rule(Parser *p); -static asdl_seq *_loop1_85_rule(Parser *p); -static asdl_seq *_loop1_86_rule(Parser *p); +static asdl_seq *_loop0_82_rule(Parser *p); +static asdl_seq *_gather_81_rule(Parser *p); +static asdl_seq *_loop1_83_rule(Parser *p); +static asdl_seq *_loop1_84_rule(Parser *p); +static asdl_seq *_loop0_86_rule(Parser *p); +static asdl_seq *_gather_85_rule(Parser *p); static asdl_seq *_loop1_87_rule(Parser *p); -static void *_tmp_88_rule(Parser *p); -static asdl_seq *_loop0_90_rule(Parser *p); -static asdl_seq *_gather_89_rule(Parser *p); -static void *_tmp_91_rule(Parser *p); ->>>>>>> upstream/main -static void *_tmp_92_rule(Parser *p); +static asdl_seq *_loop1_88_rule(Parser *p); +static asdl_seq *_loop1_89_rule(Parser *p); +static void *_tmp_90_rule(Parser *p); +static asdl_seq *_loop0_92_rule(Parser *p); +static asdl_seq *_gather_91_rule(Parser *p); static void *_tmp_93_rule(Parser *p); static void *_tmp_94_rule(Parser *p); static void *_tmp_95_rule(Parser *p); static void *_tmp_96_rule(Parser *p); -static asdl_seq *_loop0_97_rule(Parser *p); -static asdl_seq *_loop0_98_rule(Parser *p); +static void *_tmp_97_rule(Parser *p); +static void *_tmp_98_rule(Parser *p); static asdl_seq *_loop0_99_rule(Parser *p); -static asdl_seq *_loop1_100_rule(Parser *p); +static asdl_seq *_loop0_100_rule(Parser *p); static asdl_seq *_loop0_101_rule(Parser *p); static asdl_seq *_loop1_102_rule(Parser *p); -static asdl_seq *_loop1_103_rule(Parser *p); +static asdl_seq *_loop0_103_rule(Parser *p); static asdl_seq *_loop1_104_rule(Parser *p); -static asdl_seq *_loop0_105_rule(Parser *p); +static asdl_seq *_loop1_105_rule(Parser *p); static asdl_seq *_loop1_106_rule(Parser *p); static asdl_seq *_loop0_107_rule(Parser *p); static asdl_seq *_loop1_108_rule(Parser *p); static asdl_seq *_loop0_109_rule(Parser *p); static asdl_seq *_loop1_110_rule(Parser *p); -<<<<<<< HEAD -static asdl_seq *_loop1_111_rule(Parser *p); -static void *_tmp_112_rule(Parser *p); +static asdl_seq *_loop0_111_rule(Parser *p); +static asdl_seq *_loop1_112_rule(Parser *p); +static void *_tmp_113_rule(Parser *p); static asdl_seq *_loop0_114_rule(Parser *p); -static asdl_seq *_gather_113_rule(Parser *p); static asdl_seq *_loop1_115_rule(Parser *p); -static asdl_seq *_loop0_116_rule(Parser *p); -static asdl_seq *_loop0_117_rule(Parser *p); -static void *_tmp_118_rule(Parser *p); -static asdl_seq *_loop0_120_rule(Parser *p); -static asdl_seq *_gather_119_rule(Parser *p); -static void *_tmp_121_rule(Parser *p); -static asdl_seq *_loop0_123_rule(Parser *p); -static asdl_seq *_gather_122_rule(Parser *p); -======= -static void *_tmp_111_rule(Parser *p); -static asdl_seq *_loop0_112_rule(Parser *p); -static asdl_seq *_loop1_113_rule(Parser *p); -static void *_tmp_114_rule(Parser *p); -static asdl_seq *_loop0_116_rule(Parser *p); -static asdl_seq *_gather_115_rule(Parser *p); -static asdl_seq *_loop1_117_rule(Parser *p); +static void *_tmp_116_rule(Parser *p); static asdl_seq *_loop0_118_rule(Parser *p); -static asdl_seq *_loop0_119_rule(Parser *p); -static void *_tmp_120_rule(Parser *p); -static asdl_seq *_loop0_122_rule(Parser *p); -static asdl_seq *_gather_121_rule(Parser *p); -static void *_tmp_123_rule(Parser *p); ->>>>>>> upstream/main -static asdl_seq *_loop0_125_rule(Parser *p); -static asdl_seq *_gather_124_rule(Parser *p); +static asdl_seq *_gather_117_rule(Parser *p); +static asdl_seq *_loop1_119_rule(Parser *p); +static asdl_seq *_loop0_120_rule(Parser *p); +static asdl_seq *_loop0_121_rule(Parser *p); +static void *_tmp_122_rule(Parser *p); +static asdl_seq *_loop0_124_rule(Parser *p); +static asdl_seq *_gather_123_rule(Parser *p); +static void *_tmp_125_rule(Parser *p); static asdl_seq *_loop0_127_rule(Parser *p); static asdl_seq *_gather_126_rule(Parser *p); static asdl_seq *_loop0_129_rule(Parser *p); static asdl_seq *_gather_128_rule(Parser *p); -<<<<<<< HEAD -static asdl_seq *_loop0_130_rule(Parser *p); -static asdl_seq *_loop0_132_rule(Parser *p); -static asdl_seq *_gather_131_rule(Parser *p); -static asdl_seq *_loop1_133_rule(Parser *p); -static void *_tmp_134_rule(Parser *p); -static asdl_seq *_loop0_136_rule(Parser *p); -static asdl_seq *_gather_135_rule(Parser *p); -======= static asdl_seq *_loop0_131_rule(Parser *p); static asdl_seq *_gather_130_rule(Parser *p); -static asdl_seq *_loop0_132_rule(Parser *p); +static asdl_seq *_loop0_133_rule(Parser *p); +static asdl_seq *_gather_132_rule(Parser *p); static asdl_seq *_loop0_134_rule(Parser *p); -static asdl_seq *_gather_133_rule(Parser *p); -static asdl_seq *_loop1_135_rule(Parser *p); -static void *_tmp_136_rule(Parser *p); ->>>>>>> upstream/main -static asdl_seq *_loop0_138_rule(Parser *p); -static asdl_seq *_gather_137_rule(Parser *p); +static asdl_seq *_loop0_136_rule(Parser *p); +static asdl_seq *_gather_135_rule(Parser *p); +static asdl_seq *_loop1_137_rule(Parser *p); +static void *_tmp_138_rule(Parser *p); static asdl_seq *_loop0_140_rule(Parser *p); static asdl_seq *_gather_139_rule(Parser *p); static asdl_seq *_loop0_142_rule(Parser *p); static asdl_seq *_gather_141_rule(Parser *p); static asdl_seq *_loop0_144_rule(Parser *p); static asdl_seq *_gather_143_rule(Parser *p); -<<<<<<< HEAD -static void *_tmp_145_rule(Parser *p); -static void *_tmp_146_rule(Parser *p); -======= static asdl_seq *_loop0_146_rule(Parser *p); static asdl_seq *_gather_145_rule(Parser *p); ->>>>>>> upstream/main -static void *_tmp_147_rule(Parser *p); -static void *_tmp_148_rule(Parser *p); +static asdl_seq *_loop0_148_rule(Parser *p); +static asdl_seq *_gather_147_rule(Parser *p); static void *_tmp_149_rule(Parser *p); static void *_tmp_150_rule(Parser *p); static void *_tmp_151_rule(Parser *p); @@ -1438,140 +996,79 @@ static void *_tmp_152_rule(Parser *p); static void *_tmp_153_rule(Parser *p); static void *_tmp_154_rule(Parser *p); static void *_tmp_155_rule(Parser *p); -<<<<<<< HEAD -static asdl_seq *_loop0_156_rule(Parser *p); -static asdl_seq *_loop0_157_rule(Parser *p); -static asdl_seq *_loop0_158_rule(Parser *p); -static void *_tmp_159_rule(Parser *p); -static void *_tmp_160_rule(Parser *p); -static void *_tmp_161_rule(Parser *p); -static void *_tmp_162_rule(Parser *p); -static void *_tmp_163_rule(Parser *p); -static asdl_seq *_loop0_164_rule(Parser *p); -static asdl_seq *_loop0_165_rule(Parser *p); -static asdl_seq *_loop0_166_rule(Parser *p); -static asdl_seq *_loop1_167_rule(Parser *p); -static void *_tmp_168_rule(Parser *p); -static asdl_seq *_loop0_169_rule(Parser *p); -static void *_tmp_170_rule(Parser *p); -static asdl_seq *_loop0_171_rule(Parser *p); -static asdl_seq *_loop1_172_rule(Parser *p); -static void *_tmp_173_rule(Parser *p); -static void *_tmp_174_rule(Parser *p); -static void *_tmp_175_rule(Parser *p); -static asdl_seq *_loop0_176_rule(Parser *p); -static void *_tmp_177_rule(Parser *p); -static void *_tmp_178_rule(Parser *p); -static asdl_seq *_loop1_179_rule(Parser *p); -static void *_tmp_180_rule(Parser *p); -static asdl_seq *_loop0_181_rule(Parser *p); -static asdl_seq *_loop0_182_rule(Parser *p); -static asdl_seq *_loop0_183_rule(Parser *p); -static asdl_seq *_loop0_185_rule(Parser *p); -static asdl_seq *_gather_184_rule(Parser *p); -static void *_tmp_186_rule(Parser *p); -static asdl_seq *_loop0_187_rule(Parser *p); -static void *_tmp_188_rule(Parser *p); -static asdl_seq *_loop0_189_rule(Parser *p); -static asdl_seq *_loop1_190_rule(Parser *p); -static asdl_seq *_loop1_191_rule(Parser *p); -static void *_tmp_192_rule(Parser *p); -static void *_tmp_193_rule(Parser *p); -static asdl_seq *_loop0_194_rule(Parser *p); -static void *_tmp_195_rule(Parser *p); -static void *_tmp_196_rule(Parser *p); -static void *_tmp_197_rule(Parser *p); -static asdl_seq *_loop0_199_rule(Parser *p); -static asdl_seq *_gather_198_rule(Parser *p); -static asdl_seq *_loop0_201_rule(Parser *p); -static asdl_seq *_gather_200_rule(Parser *p); -static asdl_seq *_loop0_203_rule(Parser *p); -static asdl_seq *_gather_202_rule(Parser *p); -static asdl_seq *_loop0_205_rule(Parser *p); -static asdl_seq *_gather_204_rule(Parser *p); -static void *_tmp_206_rule(Parser *p); -static asdl_seq *_loop0_207_rule(Parser *p); -static asdl_seq *_loop1_208_rule(Parser *p); -======= static void *_tmp_156_rule(Parser *p); static void *_tmp_157_rule(Parser *p); static void *_tmp_158_rule(Parser *p); -static asdl_seq *_loop0_159_rule(Parser *p); -static asdl_seq *_loop0_160_rule(Parser *p); +static void *_tmp_159_rule(Parser *p); +static void *_tmp_160_rule(Parser *p); static asdl_seq *_loop0_161_rule(Parser *p); -static void *_tmp_162_rule(Parser *p); -static void *_tmp_163_rule(Parser *p); +static asdl_seq *_loop0_162_rule(Parser *p); +static asdl_seq *_loop0_163_rule(Parser *p); static void *_tmp_164_rule(Parser *p); static void *_tmp_165_rule(Parser *p); static void *_tmp_166_rule(Parser *p); -static asdl_seq *_loop0_167_rule(Parser *p); -static asdl_seq *_loop0_168_rule(Parser *p); +static void *_tmp_167_rule(Parser *p); +static void *_tmp_168_rule(Parser *p); static asdl_seq *_loop0_169_rule(Parser *p); -static asdl_seq *_loop1_170_rule(Parser *p); -static void *_tmp_171_rule(Parser *p); -static asdl_seq *_loop0_172_rule(Parser *p); +static asdl_seq *_loop0_170_rule(Parser *p); +static asdl_seq *_loop0_171_rule(Parser *p); +static asdl_seq *_loop1_172_rule(Parser *p); static void *_tmp_173_rule(Parser *p); static asdl_seq *_loop0_174_rule(Parser *p); -static asdl_seq *_loop1_175_rule(Parser *p); -static void *_tmp_176_rule(Parser *p); -static void *_tmp_177_rule(Parser *p); +static void *_tmp_175_rule(Parser *p); +static asdl_seq *_loop0_176_rule(Parser *p); +static asdl_seq *_loop1_177_rule(Parser *p); static void *_tmp_178_rule(Parser *p); -static asdl_seq *_loop0_179_rule(Parser *p); +static void *_tmp_179_rule(Parser *p); static void *_tmp_180_rule(Parser *p); -static void *_tmp_181_rule(Parser *p); -static asdl_seq *_loop1_182_rule(Parser *p); +static asdl_seq *_loop0_181_rule(Parser *p); +static void *_tmp_182_rule(Parser *p); static void *_tmp_183_rule(Parser *p); -static asdl_seq *_loop0_184_rule(Parser *p); -static asdl_seq *_loop0_185_rule(Parser *p); +static asdl_seq *_loop1_184_rule(Parser *p); +static void *_tmp_185_rule(Parser *p); static asdl_seq *_loop0_186_rule(Parser *p); +static asdl_seq *_loop0_187_rule(Parser *p); static asdl_seq *_loop0_188_rule(Parser *p); -static asdl_seq *_gather_187_rule(Parser *p); -static void *_tmp_189_rule(Parser *p); static asdl_seq *_loop0_190_rule(Parser *p); +static asdl_seq *_gather_189_rule(Parser *p); static void *_tmp_191_rule(Parser *p); static asdl_seq *_loop0_192_rule(Parser *p); -static asdl_seq *_loop1_193_rule(Parser *p); -static asdl_seq *_loop1_194_rule(Parser *p); -static void *_tmp_195_rule(Parser *p); -static void *_tmp_196_rule(Parser *p); -static asdl_seq *_loop0_197_rule(Parser *p); +static void *_tmp_193_rule(Parser *p); +static asdl_seq *_loop0_194_rule(Parser *p); +static asdl_seq *_loop1_195_rule(Parser *p); +static asdl_seq *_loop1_196_rule(Parser *p); +static void *_tmp_197_rule(Parser *p); static void *_tmp_198_rule(Parser *p); -static void *_tmp_199_rule(Parser *p); +static asdl_seq *_loop0_199_rule(Parser *p); static void *_tmp_200_rule(Parser *p); -static asdl_seq *_loop0_202_rule(Parser *p); -static asdl_seq *_gather_201_rule(Parser *p); +static void *_tmp_201_rule(Parser *p); +static void *_tmp_202_rule(Parser *p); static asdl_seq *_loop0_204_rule(Parser *p); static asdl_seq *_gather_203_rule(Parser *p); static asdl_seq *_loop0_206_rule(Parser *p); static asdl_seq *_gather_205_rule(Parser *p); static asdl_seq *_loop0_208_rule(Parser *p); static asdl_seq *_gather_207_rule(Parser *p); ->>>>>>> upstream/main -static void *_tmp_209_rule(Parser *p); static asdl_seq *_loop0_210_rule(Parser *p); -static asdl_seq *_loop1_211_rule(Parser *p); -static void *_tmp_212_rule(Parser *p); -static asdl_seq *_loop0_213_rule(Parser *p); -static asdl_seq *_loop1_214_rule(Parser *p); -static void *_tmp_215_rule(Parser *p); -static void *_tmp_216_rule(Parser *p); +static asdl_seq *_gather_209_rule(Parser *p); +static void *_tmp_211_rule(Parser *p); +static asdl_seq *_loop0_212_rule(Parser *p); +static asdl_seq *_loop1_213_rule(Parser *p); +static void *_tmp_214_rule(Parser *p); +static asdl_seq *_loop0_215_rule(Parser *p); +static asdl_seq *_loop1_216_rule(Parser *p); static void *_tmp_217_rule(Parser *p); static void *_tmp_218_rule(Parser *p); static void *_tmp_219_rule(Parser *p); static void *_tmp_220_rule(Parser *p); static void *_tmp_221_rule(Parser *p); -<<<<<<< HEAD -static asdl_seq *_loop0_223_rule(Parser *p); -static asdl_seq *_gather_222_rule(Parser *p); -======= static void *_tmp_222_rule(Parser *p); static void *_tmp_223_rule(Parser *p); ->>>>>>> upstream/main static void *_tmp_224_rule(Parser *p); -static asdl_seq *_loop0_226_rule(Parser *p); -static asdl_seq *_gather_225_rule(Parser *p); -static void *_tmp_227_rule(Parser *p); -static void *_tmp_228_rule(Parser *p); +static void *_tmp_225_rule(Parser *p); +static void *_tmp_226_rule(Parser *p); +static asdl_seq *_loop0_228_rule(Parser *p); +static asdl_seq *_gather_227_rule(Parser *p); static void *_tmp_229_rule(Parser *p); static void *_tmp_230_rule(Parser *p); static void *_tmp_231_rule(Parser *p); @@ -1583,9 +1080,9 @@ static void *_tmp_236_rule(Parser *p); static void *_tmp_237_rule(Parser *p); static void *_tmp_238_rule(Parser *p); static void *_tmp_239_rule(Parser *p); -static asdl_seq *_loop0_240_rule(Parser *p); +static void *_tmp_240_rule(Parser *p); static void *_tmp_241_rule(Parser *p); -static void *_tmp_242_rule(Parser *p); +static asdl_seq *_loop0_242_rule(Parser *p); static void *_tmp_243_rule(Parser *p); static void *_tmp_244_rule(Parser *p); static void *_tmp_245_rule(Parser *p); @@ -1597,8 +1094,6 @@ static void *_tmp_250_rule(Parser *p); static void *_tmp_251_rule(Parser *p); static void *_tmp_252_rule(Parser *p); static void *_tmp_253_rule(Parser *p); -<<<<<<< HEAD -======= static void *_tmp_254_rule(Parser *p); static void *_tmp_255_rule(Parser *p); static void *_tmp_256_rule(Parser *p); @@ -1618,7 +1113,8 @@ static void *_tmp_269_rule(Parser *p); static void *_tmp_270_rule(Parser *p); static void *_tmp_271_rule(Parser *p); static void *_tmp_272_rule(Parser *p); ->>>>>>> upstream/main +static void *_tmp_273_rule(Parser *p); +static void *_tmp_274_rule(Parser *p); // file: statements? $ @@ -4908,13 +4404,9 @@ class_def_raw_rule(Parser *p) && (a = _PyPegen_name_token(p)) // NAME && -<<<<<<< HEAD (t = type_params_rule(p), !p->error_indicator) // type_params? && - (b = _tmp_33_rule(p), !p->error_indicator) // ['(' arguments? ')'] -======= (b = _tmp_34_rule(p), !p->error_indicator) // ['(' arguments? ')'] ->>>>>>> upstream/main && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -11232,7 +10724,7 @@ type_param_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_typeparam_seq* a; if ( - (a = (asdl_typeparam_seq*)_gather_80_rule(p)) // ','.type_param+ + (a = (asdl_typeparam_seq*)_gather_81_rule(p)) // ','.type_param+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -11481,11 +10973,7 @@ expressions_rule(Parser *p) if ( (a = expression_rule(p)) // expression && -<<<<<<< HEAD - (b = _loop1_82_rule(p)) // ((',' expression))+ -======= - (b = _loop1_81_rule(p)) // ((',' expression))+ ->>>>>>> upstream/main + (b = _loop1_83_rule(p)) // ((',' expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -11876,11 +11364,7 @@ star_expressions_rule(Parser *p) if ( (a = star_expression_rule(p)) // star_expression && -<<<<<<< HEAD - (b = _loop1_83_rule(p)) // ((',' star_expression))+ -======= - (b = _loop1_82_rule(p)) // ((',' star_expression))+ ->>>>>>> upstream/main + (b = _loop1_84_rule(p)) // ((',' star_expression))+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -12081,11 +11565,7 @@ star_named_expressions_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( -<<<<<<< HEAD - (a = (asdl_expr_seq*)_gather_84_rule(p)) // ','.star_named_expression+ -======= - (a = (asdl_expr_seq*)_gather_83_rule(p)) // ','.star_named_expression+ ->>>>>>> upstream/main + (a = (asdl_expr_seq*)_gather_85_rule(p)) // ','.star_named_expression+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -12385,11 +11865,7 @@ disjunction_rule(Parser *p) if ( (a = conjunction_rule(p)) // conjunction && -<<<<<<< HEAD - (b = _loop1_86_rule(p)) // (('or' conjunction))+ -======= - (b = _loop1_85_rule(p)) // (('or' conjunction))+ ->>>>>>> upstream/main + (b = _loop1_87_rule(p)) // (('or' conjunction))+ ) { D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); @@ -12478,11 +11954,7 @@ conjunction_rule(Parser *p) if ( (a = inversion_rule(p)) // inversion && -<<<<<<< HEAD - (b = _loop1_87_rule(p)) // (('and' inversion))+ -======= - (b = _loop1_86_rule(p)) // (('and' inversion))+ ->>>>>>> upstream/main + (b = _loop1_88_rule(p)) // (('and' inversion))+ ) { D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); @@ -12656,11 +12128,7 @@ comparison_rule(Parser *p) if ( (a = bitwise_or_rule(p)) // bitwise_or && -<<<<<<< HEAD - (b = _loop1_88_rule(p)) // compare_op_bitwise_or_pair+ -======= - (b = _loop1_87_rule(p)) // compare_op_bitwise_or_pair+ ->>>>>>> upstream/main + (b = _loop1_89_rule(p)) // compare_op_bitwise_or_pair+ ) { D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); @@ -12997,17 +12465,10 @@ noteq_bitwise_or_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); -<<<<<<< HEAD - void *_tmp_89_var; + void *_tmp_90_var; expr_ty a; if ( - (_tmp_89_var = _tmp_89_rule(p)) // '!=' -======= - void *_tmp_88_var; - expr_ty a; - if ( - (_tmp_88_var = _tmp_88_rule(p)) // '!=' ->>>>>>> upstream/main + (_tmp_90_var = _tmp_90_rule(p)) // '!=' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -15042,11 +14503,7 @@ slices_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( -<<<<<<< HEAD - (a = (asdl_expr_seq*)_gather_90_rule(p)) // ','.(slice | starred_expression)+ -======= - (a = (asdl_expr_seq*)_gather_89_rule(p)) // ','.(slice | starred_expression)+ ->>>>>>> upstream/main + (a = (asdl_expr_seq*)_gather_91_rule(p)) // ','.(slice | starred_expression)+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -15119,11 +14576,7 @@ slice_rule(Parser *p) && (b = expression_rule(p), !p->error_indicator) // expression? && -<<<<<<< HEAD - (c = _tmp_92_rule(p), !p->error_indicator) // [':' expression?] -======= - (c = _tmp_91_rule(p), !p->error_indicator) // [':' expression?] ->>>>>>> upstream/main + (c = _tmp_93_rule(p), !p->error_indicator) // [':' expression?] ) { D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); @@ -15337,7 +14790,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&(STRING | FSTRING_START) strings")); expr_ty strings_var; if ( - _PyPegen_lookahead(1, _tmp_92_rule, p) + _PyPegen_lookahead(1, _tmp_94_rule, p) && (strings_var = strings_rule(p)) // strings ) @@ -15375,15 +14828,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - void *_tmp_93_var; + void *_tmp_95_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' && - (_tmp_93_var = _tmp_93_rule(p)) // tuple | group | genexp + (_tmp_95_var = _tmp_95_rule(p)) // tuple | group | genexp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); - _res = _tmp_93_var; + _res = _tmp_95_var; goto done; } p->mark = _mark; @@ -15396,15 +14849,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - void *_tmp_94_var; + void *_tmp_96_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' && - (_tmp_94_var = _tmp_94_rule(p)) // list | listcomp + (_tmp_96_var = _tmp_96_rule(p)) // list | listcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); - _res = _tmp_94_var; + _res = _tmp_96_var; goto done; } p->mark = _mark; @@ -15417,15 +14870,15 @@ atom_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - void *_tmp_95_var; + void *_tmp_97_var; if ( _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' && - (_tmp_95_var = _tmp_95_rule(p)) // dict | set | dictcomp | setcomp + (_tmp_97_var = _tmp_97_rule(p)) // dict | set | dictcomp | setcomp ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); - _res = _tmp_95_var; + _res = _tmp_97_var; goto done; } p->mark = _mark; @@ -15497,7 +14950,7 @@ group_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && - (a = _tmp_96_rule(p)) // yield_expr | named_expression + (a = _tmp_98_rule(p)) // yield_expr | named_expression && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -15701,9 +15154,9 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default && - (b = (asdl_arg_seq*)_loop0_97_rule(p)) // lambda_param_no_default* + (b = (asdl_arg_seq*)_loop0_99_rule(p)) // lambda_param_no_default* && - (c = _loop0_98_rule(p)) // lambda_param_with_default* + (c = _loop0_100_rule(p)) // lambda_param_with_default* && (d = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15733,7 +15186,7 @@ lambda_parameters_rule(Parser *p) if ( (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default && - (b = _loop0_99_rule(p)) // lambda_param_with_default* + (b = _loop0_101_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15761,9 +15214,9 @@ lambda_parameters_rule(Parser *p) asdl_seq * b; void *c; if ( - (a = (asdl_arg_seq*)_loop1_100_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_102_rule(p)) // lambda_param_no_default+ && - (b = _loop0_101_rule(p)) // lambda_param_with_default* + (b = _loop0_103_rule(p)) // lambda_param_with_default* && (c = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15790,7 +15243,7 @@ lambda_parameters_rule(Parser *p) asdl_seq * a; void *b; if ( - (a = _loop1_102_rule(p)) // lambda_param_with_default+ + (a = _loop1_104_rule(p)) // lambda_param_with_default+ && (b = lambda_star_etc_rule(p), !p->error_indicator) // lambda_star_etc? ) @@ -15864,7 +15317,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal_1; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_103_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_105_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -15893,7 +15346,7 @@ lambda_slash_no_default_rule(Parser *p) Token * _literal; asdl_arg_seq* a; if ( - (a = (asdl_arg_seq*)_loop1_104_rule(p)) // lambda_param_no_default+ + (a = (asdl_arg_seq*)_loop1_106_rule(p)) // lambda_param_no_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -15946,9 +15399,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_105_rule(p)) // lambda_param_no_default* + (a = _loop0_107_rule(p)) // lambda_param_no_default* && - (b = _loop1_106_rule(p)) // lambda_param_with_default+ + (b = _loop1_108_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -15978,9 +15431,9 @@ lambda_slash_with_default_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( - (a = _loop0_107_rule(p)) // lambda_param_no_default* + (a = _loop0_109_rule(p)) // lambda_param_no_default* && - (b = _loop1_108_rule(p)) // lambda_param_with_default+ + (b = _loop1_110_rule(p)) // lambda_param_with_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -16058,7 +15511,7 @@ lambda_star_etc_rule(Parser *p) && (a = lambda_param_no_default_rule(p)) // lambda_param_no_default && - (b = _loop0_109_rule(p)) // lambda_param_maybe_default* + (b = _loop0_111_rule(p)) // lambda_param_maybe_default* && (c = lambda_kwds_rule(p), !p->error_indicator) // lambda_kwds? ) @@ -16091,7 +15544,7 @@ lambda_star_etc_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _loop1_110_rule(p)) // lambda_param_maybe_default+ + (b = _loop1_112_rule(p)) // lambda_param_maybe_default+ && (c = lambda_kwds_rule(p), !p->error_indicator) // lambda_kwds? ) @@ -16601,7 +16054,7 @@ fstring_replacement_field_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (a = _tmp_111_rule(p)) // yield_expr | star_expressions + (a = _tmp_113_rule(p)) // yield_expr | star_expressions && (debug_expr = _PyPegen_expect_token(p, 22), !p->error_indicator) // "="? && @@ -16740,7 +16193,7 @@ fstring_full_format_spec_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' && - (spec = _loop0_112_rule(p)) // fstring_format_spec* + (spec = _loop0_114_rule(p)) // fstring_format_spec* ) { D(fprintf(stderr, "%*c+ fstring_full_format_spec[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' fstring_format_spec*")); @@ -16913,11 +16366,7 @@ strings_rule(Parser *p) D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((fstring | string))+")); asdl_expr_seq* a; if ( -<<<<<<< HEAD - (a = _loop1_111_rule(p)) // STRING+ -======= - (a = (asdl_expr_seq*)_loop1_113_rule(p)) // ((fstring | string))+ ->>>>>>> upstream/main + (a = (asdl_expr_seq*)_loop1_115_rule(p)) // ((fstring | string))+ ) { D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((fstring | string))+")); @@ -17052,11 +16501,7 @@ tuple_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && -<<<<<<< HEAD - (a = _tmp_112_rule(p), !p->error_indicator) // [star_named_expression ',' star_named_expressions?] -======= - (a = _tmp_114_rule(p), !p->error_indicator) // [star_named_expression ',' star_named_expressions?] ->>>>>>> upstream/main + (a = _tmp_116_rule(p), !p->error_indicator) // [star_named_expression ',' star_named_expressions?] && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) @@ -17274,11 +16719,7 @@ double_starred_kvpairs_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_seq * a; if ( -<<<<<<< HEAD - (a = _gather_113_rule(p)) // ','.double_starred_kvpair+ -======= - (a = _gather_115_rule(p)) // ','.double_starred_kvpair+ ->>>>>>> upstream/main + (a = _gather_117_rule(p)) // ','.double_starred_kvpair+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -17440,11 +16881,7 @@ for_if_clauses_rule(Parser *p) D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); asdl_comprehension_seq* a; if ( -<<<<<<< HEAD - (a = (asdl_comprehension_seq*)_loop1_115_rule(p)) // for_if_clause+ -======= - (a = (asdl_comprehension_seq*)_loop1_117_rule(p)) // for_if_clause+ ->>>>>>> upstream/main + (a = (asdl_comprehension_seq*)_loop1_119_rule(p)) // for_if_clause+ ) { D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); @@ -17509,11 +16946,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && -<<<<<<< HEAD - (c = (asdl_expr_seq*)_loop0_116_rule(p)) // (('if' disjunction))* -======= - (c = (asdl_expr_seq*)_loop0_118_rule(p)) // (('if' disjunction))* ->>>>>>> upstream/main + (c = (asdl_expr_seq*)_loop0_120_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -17556,11 +16989,7 @@ for_if_clause_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && -<<<<<<< HEAD - (c = (asdl_expr_seq*)_loop0_117_rule(p)) // (('if' disjunction))* -======= - (c = (asdl_expr_seq*)_loop0_119_rule(p)) // (('if' disjunction))* ->>>>>>> upstream/main + (c = (asdl_expr_seq*)_loop0_121_rule(p)) // (('if' disjunction))* ) { D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); @@ -17823,11 +17252,7 @@ genexp_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' && -<<<<<<< HEAD - (a = _tmp_118_rule(p)) // assignment_expression | expression !':=' -======= - (a = _tmp_120_rule(p)) // assignment_expression | expression !':=' ->>>>>>> upstream/main + (a = _tmp_122_rule(p)) // assignment_expression | expression !':=' && (b = for_if_clauses_rule(p)) // for_if_clauses && @@ -18079,15 +17504,9 @@ args_rule(Parser *p) asdl_expr_seq* a; void *b; if ( -<<<<<<< HEAD - (a = (asdl_expr_seq*)_gather_119_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ + (a = (asdl_expr_seq*)_gather_123_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ && - (b = _tmp_121_rule(p), !p->error_indicator) // [',' kwargs] -======= - (a = (asdl_expr_seq*)_gather_121_rule(p)) // ','.(starred_expression | (assignment_expression | expression !':=') !'=')+ - && - (b = _tmp_123_rule(p), !p->error_indicator) // [',' kwargs] ->>>>>>> upstream/main + (b = _tmp_125_rule(p), !p->error_indicator) // [',' kwargs] ) { D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | (assignment_expression | expression !':=') !'=')+ [',' kwargs]")); @@ -18178,19 +17597,11 @@ kwargs_rule(Parser *p) asdl_seq * a; asdl_seq * b; if ( -<<<<<<< HEAD - (a = _gather_122_rule(p)) // ','.kwarg_or_starred+ - && - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (b = _gather_124_rule(p)) // ','.kwarg_or_double_starred+ -======= - (a = _gather_124_rule(p)) // ','.kwarg_or_starred+ + (a = _gather_126_rule(p)) // ','.kwarg_or_starred+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (b = _gather_126_rule(p)) // ','.kwarg_or_double_starred+ ->>>>>>> upstream/main + (b = _gather_128_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); @@ -18212,23 +17623,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); -<<<<<<< HEAD - asdl_seq * _gather_126_var; - if ( - (_gather_126_var = _gather_126_rule(p)) // ','.kwarg_or_starred+ - ) - { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_126_var; -======= - asdl_seq * _gather_128_var; + asdl_seq * _gather_130_var; if ( - (_gather_128_var = _gather_128_rule(p)) // ','.kwarg_or_starred+ + (_gather_130_var = _gather_130_rule(p)) // ','.kwarg_or_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); - _res = _gather_128_var; ->>>>>>> upstream/main + _res = _gather_130_var; goto done; } p->mark = _mark; @@ -18241,23 +17642,13 @@ kwargs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); -<<<<<<< HEAD - asdl_seq * _gather_128_var; + asdl_seq * _gather_132_var; if ( - (_gather_128_var = _gather_128_rule(p)) // ','.kwarg_or_double_starred+ + (_gather_132_var = _gather_132_rule(p)) // ','.kwarg_or_double_starred+ ) { D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_128_var; -======= - asdl_seq * _gather_130_var; - if ( - (_gather_130_var = _gather_130_rule(p)) // ','.kwarg_or_double_starred+ - ) - { - D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); - _res = _gather_130_var; ->>>>>>> upstream/main + _res = _gather_132_var; goto done; } p->mark = _mark; @@ -18650,11 +18041,7 @@ star_targets_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && -<<<<<<< HEAD - (b = _loop0_130_rule(p)) // ((',' star_target))* -======= - (b = _loop0_132_rule(p)) // ((',' star_target))* ->>>>>>> upstream/main + (b = _loop0_134_rule(p)) // ((',' star_target))* && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -18711,11 +18098,7 @@ star_targets_list_seq_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( -<<<<<<< HEAD - (a = (asdl_expr_seq*)_gather_131_rule(p)) // ','.star_target+ -======= - (a = (asdl_expr_seq*)_gather_133_rule(p)) // ','.star_target+ ->>>>>>> upstream/main + (a = (asdl_expr_seq*)_gather_135_rule(p)) // ','.star_target+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -18766,11 +18149,7 @@ star_targets_tuple_seq_rule(Parser *p) if ( (a = star_target_rule(p)) // star_target && -<<<<<<< HEAD - (b = _loop1_133_rule(p)) // ((',' star_target))+ -======= - (b = _loop1_135_rule(p)) // ((',' star_target))+ ->>>>>>> upstream/main + (b = _loop1_137_rule(p)) // ((',' star_target))+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -18859,11 +18238,7 @@ star_target_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && -<<<<<<< HEAD - (a = _tmp_134_rule(p)) // !'*' star_target -======= - (a = _tmp_136_rule(p)) // !'*' star_target ->>>>>>> upstream/main + (a = _tmp_138_rule(p)) // !'*' star_target ) { D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); @@ -19794,11 +19169,7 @@ del_targets_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings asdl_expr_seq* a; if ( -<<<<<<< HEAD - (a = (asdl_expr_seq*)_gather_135_rule(p)) // ','.del_target+ -======= - (a = (asdl_expr_seq*)_gather_137_rule(p)) // ','.del_target+ ->>>>>>> upstream/main + (a = (asdl_expr_seq*)_gather_139_rule(p)) // ','.del_target+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? ) @@ -20159,11 +19530,7 @@ type_expressions_rule(Parser *p) expr_ty b; expr_ty c; if ( -<<<<<<< HEAD - (a = _gather_137_rule(p)) // ','.expression+ -======= - (a = _gather_139_rule(p)) // ','.expression+ ->>>>>>> upstream/main + (a = _gather_141_rule(p)) // ','.expression+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -20202,11 +19569,7 @@ type_expressions_rule(Parser *p) asdl_seq * a; expr_ty b; if ( -<<<<<<< HEAD - (a = _gather_139_rule(p)) // ','.expression+ -======= - (a = _gather_141_rule(p)) // ','.expression+ ->>>>>>> upstream/main + (a = _gather_143_rule(p)) // ','.expression+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -20239,11 +19602,7 @@ type_expressions_rule(Parser *p) asdl_seq * a; expr_ty b; if ( -<<<<<<< HEAD - (a = _gather_141_rule(p)) // ','.expression+ -======= - (a = _gather_143_rule(p)) // ','.expression+ ->>>>>>> upstream/main + (a = _gather_145_rule(p)) // ','.expression+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -20363,11 +19722,7 @@ type_expressions_rule(Parser *p) D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+")); asdl_expr_seq* a; if ( -<<<<<<< HEAD - (a = (asdl_expr_seq*)_gather_143_rule(p)) // ','.expression+ -======= - (a = (asdl_expr_seq*)_gather_145_rule(p)) // ','.expression+ ->>>>>>> upstream/main + (a = (asdl_expr_seq*)_gather_147_rule(p)) // ','.expression+ ) { D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+")); @@ -20419,11 +19774,7 @@ func_type_comment_rule(Parser *p) && (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' && -<<<<<<< HEAD - _PyPegen_lookahead(1, _tmp_145_rule, p) -======= - _PyPegen_lookahead(1, _tmp_147_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(1, _tmp_149_rule, p) ) { D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); @@ -20552,11 +19903,7 @@ invalid_arguments_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (_opt_var = _tmp_146_rule(p), !p->error_indicator) // [args | expression for_if_clauses] -======= - (_opt_var = _tmp_148_rule(p), !p->error_indicator) // [args | expression for_if_clauses] ->>>>>>> upstream/main + (_opt_var = _tmp_150_rule(p), !p->error_indicator) // [args | expression for_if_clauses] ) { D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); @@ -20616,21 +19963,13 @@ invalid_arguments_rule(Parser *p) expr_ty a; Token * b; if ( -<<<<<<< HEAD - (_opt_var = _tmp_147_rule(p), !p->error_indicator) // [(args ',')] -======= - (_opt_var = _tmp_149_rule(p), !p->error_indicator) // [(args ',')] ->>>>>>> upstream/main + (_opt_var = _tmp_151_rule(p), !p->error_indicator) // [(args ',')] && (a = _PyPegen_name_token(p)) // NAME && (b = _PyPegen_expect_token(p, 22)) // token='=' && -<<<<<<< HEAD - _PyPegen_lookahead(1, _tmp_148_rule, p) -======= - _PyPegen_lookahead(1, _tmp_150_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(1, _tmp_152_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "[(args ',')] NAME '=' &(',' | ')')")); @@ -20769,11 +20108,7 @@ invalid_kwarg_rule(Parser *p) Token* a; Token * b; if ( -<<<<<<< HEAD - (a = (Token*)_tmp_149_rule(p)) // 'True' | 'False' | 'None' -======= - (a = (Token*)_tmp_151_rule(p)) // 'True' | 'False' | 'None' ->>>>>>> upstream/main + (a = (Token*)_tmp_153_rule(p)) // 'True' | 'False' | 'None' && (b = _PyPegen_expect_token(p, 22)) // token='=' ) @@ -20833,11 +20168,7 @@ invalid_kwarg_rule(Parser *p) expr_ty a; Token * b; if ( -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_150_rule, p) -======= - _PyPegen_lookahead(0, _tmp_152_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_154_rule, p) && (a = expression_rule(p)) // expression && @@ -21096,11 +20427,7 @@ invalid_expression_rule(Parser *p) expr_ty a; expr_ty b; if ( -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_151_rule, p) -======= - _PyPegen_lookahead(0, _tmp_153_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_155_rule, p) && (a = disjunction_rule(p)) // disjunction && @@ -21136,11 +20463,7 @@ invalid_expression_rule(Parser *p) && (b = disjunction_rule(p)) // disjunction && -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_152_rule, p) -======= - _PyPegen_lookahead(0, _tmp_154_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_156_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction !('else' | ':')")); @@ -21173,7 +20496,7 @@ invalid_expression_rule(Parser *p) && (b = _PyPegen_expect_token(p, 11)) // token=':' && - _PyPegen_lookahead(1, _tmp_155_rule, p) + _PyPegen_lookahead(1, _tmp_157_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' &(FSTRING_MIDDLE | fstring_replacement_field)")); @@ -21262,11 +20585,7 @@ invalid_named_expression_rule(Parser *p) && (b = bitwise_or_rule(p)) // bitwise_or && -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_153_rule, p) -======= - _PyPegen_lookahead(0, _tmp_156_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_158_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=')")); @@ -21292,11 +20611,7 @@ invalid_named_expression_rule(Parser *p) Token * b; expr_ty bitwise_or_var; if ( -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_154_rule, p) -======= - _PyPegen_lookahead(0, _tmp_157_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_159_rule, p) && (a = bitwise_or_rule(p)) // bitwise_or && @@ -21304,11 +20619,7 @@ invalid_named_expression_rule(Parser *p) && (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or && -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_155_rule, p) -======= - _PyPegen_lookahead(0, _tmp_158_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_160_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=')")); @@ -21389,11 +20700,7 @@ invalid_assignment_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); Token * _literal; Token * _literal_1; -<<<<<<< HEAD - asdl_seq * _loop0_156_var; -======= - asdl_seq * _loop0_159_var; ->>>>>>> upstream/main + asdl_seq * _loop0_161_var; expr_ty a; expr_ty expression_var; if ( @@ -21401,11 +20708,7 @@ invalid_assignment_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (_loop0_156_var = _loop0_156_rule(p)) // star_named_expressions* -======= - (_loop0_159_var = _loop0_159_rule(p)) // star_named_expressions* ->>>>>>> upstream/main + (_loop0_161_var = _loop0_161_rule(p)) // star_named_expressions* && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -21462,17 +20765,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop0_157_var; - expr_ty a; - if ( - (_loop0_157_var = _loop0_157_rule(p)) // ((star_targets '='))* -======= - asdl_seq * _loop0_160_var; + asdl_seq * _loop0_162_var; expr_ty a; if ( - (_loop0_160_var = _loop0_160_rule(p)) // ((star_targets '='))* ->>>>>>> upstream/main + (_loop0_162_var = _loop0_162_rule(p)) // ((star_targets '='))* && (a = star_expressions_rule(p)) // star_expressions && @@ -21499,17 +20795,10 @@ invalid_assignment_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop0_158_var; - expr_ty a; - if ( - (_loop0_158_var = _loop0_158_rule(p)) // ((star_targets '='))* -======= - asdl_seq * _loop0_161_var; + asdl_seq * _loop0_163_var; expr_ty a; if ( - (_loop0_161_var = _loop0_161_rule(p)) // ((star_targets '='))* ->>>>>>> upstream/main + (_loop0_163_var = _loop0_163_rule(p)) // ((star_targets '='))* && (a = yield_expr_rule(p)) // yield_expr && @@ -21535,11 +20824,7 @@ invalid_assignment_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); -<<<<<<< HEAD - void *_tmp_159_var; -======= - void *_tmp_162_var; ->>>>>>> upstream/main + void *_tmp_164_var; expr_ty a; AugOperator* augassign_var; if ( @@ -21547,11 +20832,7 @@ invalid_assignment_rule(Parser *p) && (augassign_var = augassign_rule(p)) // augassign && -<<<<<<< HEAD - (_tmp_159_var = _tmp_159_rule(p)) // yield_expr | star_expressions -======= - (_tmp_162_var = _tmp_162_rule(p)) // yield_expr | star_expressions ->>>>>>> upstream/main + (_tmp_164_var = _tmp_164_rule(p)) // yield_expr | star_expressions ) { D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); @@ -21777,19 +21058,11 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); -<<<<<<< HEAD - void *_tmp_160_var; - expr_ty a; - asdl_comprehension_seq* for_if_clauses_var; - if ( - (_tmp_160_var = _tmp_160_rule(p)) // '[' | '(' | '{' -======= - void *_tmp_163_var; + void *_tmp_165_var; expr_ty a; asdl_comprehension_seq* for_if_clauses_var; if ( - (_tmp_163_var = _tmp_163_rule(p)) // '[' | '(' | '{' ->>>>>>> upstream/main + (_tmp_165_var = _tmp_165_rule(p)) // '[' | '(' | '{' && (a = starred_expression_rule(p)) // starred_expression && @@ -21816,20 +21089,12 @@ invalid_comprehension_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions for_if_clauses")); Token * _literal; -<<<<<<< HEAD - void *_tmp_161_var; -======= - void *_tmp_164_var; ->>>>>>> upstream/main + void *_tmp_166_var; expr_ty a; asdl_expr_seq* b; asdl_comprehension_seq* for_if_clauses_var; if ( -<<<<<<< HEAD - (_tmp_161_var = _tmp_161_rule(p)) // '[' | '{' -======= - (_tmp_164_var = _tmp_164_rule(p)) // '[' | '{' ->>>>>>> upstream/main + (_tmp_166_var = _tmp_166_rule(p)) // '[' | '{' && (a = star_named_expression_rule(p)) // star_named_expression && @@ -21859,20 +21124,12 @@ invalid_comprehension_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' for_if_clauses")); -<<<<<<< HEAD - void *_tmp_162_var; -======= - void *_tmp_165_var; ->>>>>>> upstream/main + void *_tmp_167_var; expr_ty a; Token * b; asdl_comprehension_seq* for_if_clauses_var; if ( -<<<<<<< HEAD - (_tmp_162_var = _tmp_162_rule(p)) // '[' | '{' -======= - (_tmp_165_var = _tmp_165_rule(p)) // '[' | '{' ->>>>>>> upstream/main + (_tmp_167_var = _tmp_167_rule(p)) // '[' | '{' && (a = star_named_expression_rule(p)) // star_named_expression && @@ -22009,23 +21266,13 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slash_no_default | slash_with_default) param_maybe_default* '/'")); -<<<<<<< HEAD - asdl_seq * _loop0_164_var; - void *_tmp_163_var; - Token * a; - if ( - (_tmp_163_var = _tmp_163_rule(p)) // slash_no_default | slash_with_default - && - (_loop0_164_var = _loop0_164_rule(p)) // param_maybe_default* -======= - asdl_seq * _loop0_167_var; - void *_tmp_166_var; + asdl_seq * _loop0_169_var; + void *_tmp_168_var; Token * a; if ( - (_tmp_166_var = _tmp_166_rule(p)) // slash_no_default | slash_with_default + (_tmp_168_var = _tmp_168_rule(p)) // slash_no_default | slash_with_default && - (_loop0_167_var = _loop0_167_rule(p)) // param_maybe_default* ->>>>>>> upstream/main + (_loop0_169_var = _loop0_169_rule(p)) // param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -22049,11 +21296,7 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default? param_no_default* invalid_parameters_helper param_no_default")); -<<<<<<< HEAD - asdl_seq * _loop0_165_var; -======= - asdl_seq * _loop0_168_var; ->>>>>>> upstream/main + asdl_seq * _loop0_170_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings arg_ty a; @@ -22061,11 +21304,7 @@ invalid_parameters_rule(Parser *p) if ( (_opt_var = slash_no_default_rule(p), !p->error_indicator) // slash_no_default? && -<<<<<<< HEAD - (_loop0_165_var = _loop0_165_rule(p)) // param_no_default* -======= - (_loop0_168_var = _loop0_168_rule(p)) // param_no_default* ->>>>>>> upstream/main + (_loop0_170_var = _loop0_170_rule(p)) // param_no_default* && (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper && @@ -22091,31 +21330,18 @@ invalid_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* '(' param_no_default+ ','? ')'")); -<<<<<<< HEAD - asdl_seq * _loop0_166_var; - asdl_seq * _loop1_167_var; -======= - asdl_seq * _loop0_169_var; - asdl_seq * _loop1_170_var; ->>>>>>> upstream/main + asdl_seq * _loop0_171_var; + asdl_seq * _loop1_172_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; Token * b; if ( -<<<<<<< HEAD - (_loop0_166_var = _loop0_166_rule(p)) // param_no_default* - && - (a = _PyPegen_expect_token(p, 7)) // token='(' - && - (_loop1_167_var = _loop1_167_rule(p)) // param_no_default+ -======= - (_loop0_169_var = _loop0_169_rule(p)) // param_no_default* + (_loop0_171_var = _loop0_171_rule(p)) // param_no_default* && (a = _PyPegen_expect_token(p, 7)) // token='(' && - (_loop1_170_var = _loop1_170_rule(p)) // param_no_default+ ->>>>>>> upstream/main + (_loop1_172_var = _loop1_172_rule(p)) // param_no_default+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -22142,41 +21368,22 @@ invalid_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(slash_no_default | slash_with_default)] param_maybe_default* '*' (',' | param_no_default) param_maybe_default* '/'")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop0_169_var; - asdl_seq * _loop0_171_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_170_var; - Token * a; - if ( - (_opt_var = _tmp_168_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] - && - (_loop0_169_var = _loop0_169_rule(p)) // param_maybe_default* - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_170_var = _tmp_170_rule(p)) // ',' | param_no_default - && - (_loop0_171_var = _loop0_171_rule(p)) // param_maybe_default* -======= - asdl_seq * _loop0_172_var; asdl_seq * _loop0_174_var; + asdl_seq * _loop0_176_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_173_var; + void *_tmp_175_var; Token * a; if ( - (_opt_var = _tmp_171_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] + (_opt_var = _tmp_173_rule(p), !p->error_indicator) // [(slash_no_default | slash_with_default)] && - (_loop0_172_var = _loop0_172_rule(p)) // param_maybe_default* + (_loop0_174_var = _loop0_174_rule(p)) // param_maybe_default* && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_173_var = _tmp_173_rule(p)) // ',' | param_no_default + (_tmp_175_var = _tmp_175_rule(p)) // ',' | param_no_default && - (_loop0_174_var = _loop0_174_rule(p)) // param_maybe_default* ->>>>>>> upstream/main + (_loop0_176_var = _loop0_176_rule(p)) // param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -22201,17 +21408,10 @@ invalid_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default+ '/' '*'")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop1_172_var; - Token * a; - if ( - (_loop1_172_var = _loop1_172_rule(p)) // param_maybe_default+ -======= - asdl_seq * _loop1_175_var; + asdl_seq * _loop1_177_var; Token * a; if ( - (_loop1_175_var = _loop1_175_rule(p)) // param_maybe_default+ ->>>>>>> upstream/main + (_loop1_177_var = _loop1_177_rule(p)) // param_maybe_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -22261,11 +21461,7 @@ invalid_default_rule(Parser *p) if ( (a = _PyPegen_expect_token(p, 22)) // token='=' && -<<<<<<< HEAD - _PyPegen_lookahead(1, _tmp_173_rule, p) -======= - _PyPegen_lookahead(1, _tmp_176_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(1, _tmp_178_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' &(')' | ',')")); @@ -22311,20 +21507,12 @@ invalid_star_etc_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); -<<<<<<< HEAD - void *_tmp_174_var; -======= - void *_tmp_177_var; ->>>>>>> upstream/main + void *_tmp_179_var; Token * a; if ( (a = _PyPegen_expect_token(p, 16)) // token='*' && -<<<<<<< HEAD - (_tmp_174_var = _tmp_174_rule(p)) // ')' | ',' (')' | '**') -======= - (_tmp_177_var = _tmp_177_rule(p)) // ')' | ',' (')' | '**') ->>>>>>> upstream/main + (_tmp_179_var = _tmp_179_rule(p)) // ')' | ',' (')' | '**') ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); @@ -22407,36 +21595,20 @@ invalid_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop0_176_var; - void *_tmp_175_var; - void *_tmp_177_var; -======= - asdl_seq * _loop0_179_var; - void *_tmp_178_var; + asdl_seq * _loop0_181_var; void *_tmp_180_var; ->>>>>>> upstream/main + void *_tmp_182_var; Token * a; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && -<<<<<<< HEAD - (_tmp_175_var = _tmp_175_rule(p)) // param_no_default | ',' - && - (_loop0_176_var = _loop0_176_rule(p)) // param_maybe_default* - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_177_var = _tmp_177_rule(p)) // param_no_default | ',' -======= - (_tmp_178_var = _tmp_178_rule(p)) // param_no_default | ',' + (_tmp_180_var = _tmp_180_rule(p)) // param_no_default | ',' && - (_loop0_179_var = _loop0_179_rule(p)) // param_maybe_default* + (_loop0_181_var = _loop0_181_rule(p)) // param_maybe_default* && (a = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_180_var = _tmp_180_rule(p)) // param_no_default | ',' ->>>>>>> upstream/main + (_tmp_182_var = _tmp_182_rule(p)) // param_no_default | ',' ) { D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (param_no_default | ',') param_maybe_default* '*' (param_no_default | ',')")); @@ -22552,11 +21724,7 @@ invalid_kwds_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (a = (Token*)_tmp_178_rule(p)) // '*' | '**' | '/' -======= - (a = (Token*)_tmp_181_rule(p)) // '*' | '**' | '/' ->>>>>>> upstream/main + (a = (Token*)_tmp_183_rule(p)) // '*' | '**' | '/' ) { D(fprintf(stderr, "%*c+ invalid_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param ',' ('*' | '**' | '/')")); @@ -22622,23 +21790,13 @@ invalid_parameters_helper_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); -<<<<<<< HEAD - asdl_seq * _loop1_179_var; - if ( - (_loop1_179_var = _loop1_179_rule(p)) // param_with_default+ - ) - { - D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_179_var; -======= - asdl_seq * _loop1_182_var; + asdl_seq * _loop1_184_var; if ( - (_loop1_182_var = _loop1_182_rule(p)) // param_with_default+ + (_loop1_184_var = _loop1_184_rule(p)) // param_with_default+ ) { D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); - _res = _loop1_182_var; ->>>>>>> upstream/main + _res = _loop1_184_var; goto done; } p->mark = _mark; @@ -22704,23 +21862,13 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* '/'")); -<<<<<<< HEAD - asdl_seq * _loop0_181_var; - void *_tmp_180_var; - Token * a; - if ( - (_tmp_180_var = _tmp_180_rule(p)) // lambda_slash_no_default | lambda_slash_with_default - && - (_loop0_181_var = _loop0_181_rule(p)) // lambda_param_maybe_default* -======= - asdl_seq * _loop0_184_var; - void *_tmp_183_var; + asdl_seq * _loop0_186_var; + void *_tmp_185_var; Token * a; if ( - (_tmp_183_var = _tmp_183_rule(p)) // lambda_slash_no_default | lambda_slash_with_default + (_tmp_185_var = _tmp_185_rule(p)) // lambda_slash_no_default | lambda_slash_with_default && - (_loop0_184_var = _loop0_184_rule(p)) // lambda_param_maybe_default* ->>>>>>> upstream/main + (_loop0_186_var = _loop0_186_rule(p)) // lambda_param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -22744,11 +21892,7 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); -<<<<<<< HEAD - asdl_seq * _loop0_182_var; -======= - asdl_seq * _loop0_185_var; ->>>>>>> upstream/main + asdl_seq * _loop0_187_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings arg_ty a; @@ -22756,11 +21900,7 @@ invalid_lambda_parameters_rule(Parser *p) if ( (_opt_var = lambda_slash_no_default_rule(p), !p->error_indicator) // lambda_slash_no_default? && -<<<<<<< HEAD - (_loop0_182_var = _loop0_182_rule(p)) // lambda_param_no_default* -======= - (_loop0_185_var = _loop0_185_rule(p)) // lambda_param_no_default* ->>>>>>> upstream/main + (_loop0_187_var = _loop0_187_rule(p)) // lambda_param_no_default* && (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper && @@ -22786,31 +21926,18 @@ invalid_lambda_parameters_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* '(' ','.lambda_param+ ','? ')'")); -<<<<<<< HEAD - asdl_seq * _gather_184_var; - asdl_seq * _loop0_183_var; -======= - asdl_seq * _gather_187_var; - asdl_seq * _loop0_186_var; ->>>>>>> upstream/main + asdl_seq * _gather_189_var; + asdl_seq * _loop0_188_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; Token * b; if ( -<<<<<<< HEAD - (_loop0_183_var = _loop0_183_rule(p)) // lambda_param_no_default* - && - (a = _PyPegen_expect_token(p, 7)) // token='(' - && - (_gather_184_var = _gather_184_rule(p)) // ','.lambda_param+ -======= - (_loop0_186_var = _loop0_186_rule(p)) // lambda_param_no_default* + (_loop0_188_var = _loop0_188_rule(p)) // lambda_param_no_default* && (a = _PyPegen_expect_token(p, 7)) // token='(' && - (_gather_187_var = _gather_187_rule(p)) // ','.lambda_param+ ->>>>>>> upstream/main + (_gather_189_var = _gather_189_rule(p)) // ','.lambda_param+ && (_opt_var = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -22837,41 +21964,22 @@ invalid_lambda_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "[(lambda_slash_no_default | lambda_slash_with_default)] lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* '/'")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop0_187_var; - asdl_seq * _loop0_189_var; - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_188_var; - Token * a; - if ( - (_opt_var = _tmp_186_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] - && - (_loop0_187_var = _loop0_187_rule(p)) // lambda_param_maybe_default* - && - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_188_var = _tmp_188_rule(p)) // ',' | lambda_param_no_default - && - (_loop0_189_var = _loop0_189_rule(p)) // lambda_param_maybe_default* -======= - asdl_seq * _loop0_190_var; asdl_seq * _loop0_192_var; + asdl_seq * _loop0_194_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_191_var; + void *_tmp_193_var; Token * a; if ( - (_opt_var = _tmp_189_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] + (_opt_var = _tmp_191_rule(p), !p->error_indicator) // [(lambda_slash_no_default | lambda_slash_with_default)] && - (_loop0_190_var = _loop0_190_rule(p)) // lambda_param_maybe_default* + (_loop0_192_var = _loop0_192_rule(p)) // lambda_param_maybe_default* && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_191_var = _tmp_191_rule(p)) // ',' | lambda_param_no_default + (_tmp_193_var = _tmp_193_rule(p)) // ',' | lambda_param_no_default && - (_loop0_192_var = _loop0_192_rule(p)) // lambda_param_maybe_default* ->>>>>>> upstream/main + (_loop0_194_var = _loop0_194_rule(p)) // lambda_param_maybe_default* && (a = _PyPegen_expect_token(p, 17)) // token='/' ) @@ -22896,17 +22004,10 @@ invalid_lambda_parameters_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default+ '/' '*'")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop1_190_var; + asdl_seq * _loop1_195_var; Token * a; if ( - (_loop1_190_var = _loop1_190_rule(p)) // lambda_param_maybe_default+ -======= - asdl_seq * _loop1_193_var; - Token * a; - if ( - (_loop1_193_var = _loop1_193_rule(p)) // lambda_param_maybe_default+ ->>>>>>> upstream/main + (_loop1_195_var = _loop1_195_rule(p)) // lambda_param_maybe_default+ && (_literal = _PyPegen_expect_token(p, 17)) // token='/' && @@ -22978,23 +22079,13 @@ invalid_lambda_parameters_helper_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); -<<<<<<< HEAD - asdl_seq * _loop1_191_var; - if ( - (_loop1_191_var = _loop1_191_rule(p)) // lambda_param_with_default+ - ) - { - D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_191_var; -======= - asdl_seq * _loop1_194_var; + asdl_seq * _loop1_196_var; if ( - (_loop1_194_var = _loop1_194_rule(p)) // lambda_param_with_default+ + (_loop1_196_var = _loop1_196_rule(p)) // lambda_param_with_default+ ) { D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); - _res = _loop1_194_var; ->>>>>>> upstream/main + _res = _loop1_196_var; goto done; } p->mark = _mark; @@ -23031,19 +22122,11 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); Token * _literal; -<<<<<<< HEAD - void *_tmp_192_var; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_192_var = _tmp_192_rule(p)) // ':' | ',' (':' | '**') -======= - void *_tmp_195_var; + void *_tmp_197_var; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_195_var = _tmp_195_rule(p)) // ':' | ',' (':' | '**') ->>>>>>> upstream/main + (_tmp_197_var = _tmp_197_rule(p)) // ':' | ',' (':' | '**') ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); @@ -23096,36 +22179,20 @@ invalid_lambda_star_etc_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); Token * _literal; -<<<<<<< HEAD - asdl_seq * _loop0_194_var; - void *_tmp_193_var; - void *_tmp_195_var; -======= - asdl_seq * _loop0_197_var; - void *_tmp_196_var; + asdl_seq * _loop0_199_var; void *_tmp_198_var; ->>>>>>> upstream/main + void *_tmp_200_var; Token * a; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' && -<<<<<<< HEAD - (_tmp_193_var = _tmp_193_rule(p)) // lambda_param_no_default | ',' - && - (_loop0_194_var = _loop0_194_rule(p)) // lambda_param_maybe_default* - && - (a = _PyPegen_expect_token(p, 16)) // token='*' - && - (_tmp_195_var = _tmp_195_rule(p)) // lambda_param_no_default | ',' -======= - (_tmp_196_var = _tmp_196_rule(p)) // lambda_param_no_default | ',' + (_tmp_198_var = _tmp_198_rule(p)) // lambda_param_no_default | ',' && - (_loop0_197_var = _loop0_197_rule(p)) // lambda_param_maybe_default* + (_loop0_199_var = _loop0_199_rule(p)) // lambda_param_maybe_default* && (a = _PyPegen_expect_token(p, 16)) // token='*' && - (_tmp_198_var = _tmp_198_rule(p)) // lambda_param_no_default | ',' ->>>>>>> upstream/main + (_tmp_200_var = _tmp_200_rule(p)) // lambda_param_no_default | ',' ) { D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (lambda_param_no_default | ',') lambda_param_maybe_default* '*' (lambda_param_no_default | ',')")); @@ -23244,11 +22311,7 @@ invalid_lambda_kwds_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (a = (Token*)_tmp_196_rule(p)) // '*' | '**' | '/' -======= - (a = (Token*)_tmp_199_rule(p)) // '*' | '**' | '/' ->>>>>>> upstream/main + (a = (Token*)_tmp_201_rule(p)) // '*' | '**' | '/' ) { D(fprintf(stderr, "%*c+ invalid_lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param ',' ('*' | '**' | '/')")); @@ -23356,11 +22419,7 @@ invalid_with_item_rule(Parser *p) && (a = expression_rule(p)) // expression && -<<<<<<< HEAD - _PyPegen_lookahead(1, _tmp_197_rule, p) -======= - _PyPegen_lookahead(1, _tmp_200_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(1, _tmp_202_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); @@ -23641,11 +22700,7 @@ invalid_with_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ NEWLINE")); -<<<<<<< HEAD - asdl_seq * _gather_198_var; -======= - asdl_seq * _gather_201_var; ->>>>>>> upstream/main + asdl_seq * _gather_203_var; Token * _keyword; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings @@ -23655,11 +22710,7 @@ invalid_with_stmt_rule(Parser *p) && (_keyword = _PyPegen_expect_token(p, 615)) // token='with' && -<<<<<<< HEAD - (_gather_198_var = _gather_198_rule(p)) // ','.(expression ['as' star_target])+ -======= - (_gather_201_var = _gather_201_rule(p)) // ','.(expression ['as' star_target])+ ->>>>>>> upstream/main + (_gather_203_var = _gather_203_rule(p)) // ','.(expression ['as' star_target])+ && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -23683,11 +22734,7 @@ invalid_with_stmt_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE")); -<<<<<<< HEAD - asdl_seq * _gather_200_var; -======= - asdl_seq * _gather_203_var; ->>>>>>> upstream/main + asdl_seq * _gather_205_var; Token * _keyword; Token * _literal; Token * _literal_1; @@ -23703,11 +22750,7 @@ invalid_with_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && -<<<<<<< HEAD - (_gather_200_var = _gather_200_rule(p)) // ','.(expressions ['as' star_target])+ -======= - (_gather_203_var = _gather_203_rule(p)) // ','.(expressions ['as' star_target])+ ->>>>>>> upstream/main + (_gather_205_var = _gather_205_rule(p)) // ','.(expressions ['as' star_target])+ && (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -23757,11 +22800,7 @@ invalid_with_stmt_indent_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT")); -<<<<<<< HEAD - asdl_seq * _gather_202_var; -======= - asdl_seq * _gather_205_var; ->>>>>>> upstream/main + asdl_seq * _gather_207_var; Token * _literal; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings @@ -23772,11 +22811,7 @@ invalid_with_stmt_indent_rule(Parser *p) && (a = _PyPegen_expect_token(p, 615)) // token='with' && -<<<<<<< HEAD - (_gather_202_var = _gather_202_rule(p)) // ','.(expression ['as' star_target])+ -======= - (_gather_205_var = _gather_205_rule(p)) // ','.(expression ['as' star_target])+ ->>>>>>> upstream/main + (_gather_207_var = _gather_207_rule(p)) // ','.(expression ['as' star_target])+ && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -23804,11 +22839,7 @@ invalid_with_stmt_indent_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_with_stmt_indent[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT")); -<<<<<<< HEAD - asdl_seq * _gather_204_var; -======= - asdl_seq * _gather_207_var; ->>>>>>> upstream/main + asdl_seq * _gather_209_var; Token * _literal; Token * _literal_1; Token * _literal_2; @@ -23825,11 +22856,7 @@ invalid_with_stmt_indent_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && -<<<<<<< HEAD - (_gather_204_var = _gather_204_rule(p)) // ','.(expressions ['as' star_target])+ -======= - (_gather_207_var = _gather_207_rule(p)) // ','.(expressions ['as' star_target])+ ->>>>>>> upstream/main + (_gather_209_var = _gather_209_rule(p)) // ','.(expressions ['as' star_target])+ && (_opt_var_1 = _PyPegen_expect_token(p, 12), !p->error_indicator) // ','? && @@ -23927,11 +22954,7 @@ invalid_try_stmt_rule(Parser *p) && (block_var = block_rule(p)) // block && -<<<<<<< HEAD - _PyPegen_lookahead(0, _tmp_206_rule, p) -======= - _PyPegen_lookahead(0, _tmp_209_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(0, _tmp_211_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block !('except' | 'finally')")); @@ -23956,13 +22979,8 @@ invalid_try_stmt_rule(Parser *p) Token * _keyword; Token * _literal; Token * _literal_1; -<<<<<<< HEAD - asdl_seq * _loop0_207_var; - asdl_seq * _loop1_208_var; -======= - asdl_seq * _loop0_210_var; - asdl_seq * _loop1_211_var; ->>>>>>> upstream/main + asdl_seq * _loop0_212_var; + asdl_seq * _loop1_213_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; @@ -23973,15 +22991,9 @@ invalid_try_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && -<<<<<<< HEAD - (_loop0_207_var = _loop0_207_rule(p)) // block* + (_loop0_212_var = _loop0_212_rule(p)) // block* && - (_loop1_208_var = _loop1_208_rule(p)) // except_block+ -======= - (_loop0_210_var = _loop0_210_rule(p)) // block* - && - (_loop1_211_var = _loop1_211_rule(p)) // except_block+ ->>>>>>> upstream/main + (_loop1_213_var = _loop1_213_rule(p)) // except_block+ && (a = _PyPegen_expect_token(p, 637)) // token='except' && @@ -23989,11 +23001,7 @@ invalid_try_stmt_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && -<<<<<<< HEAD - (_opt_var = _tmp_209_rule(p), !p->error_indicator) // ['as' NAME] -======= - (_opt_var = _tmp_212_rule(p), !p->error_indicator) // ['as' NAME] ->>>>>>> upstream/main + (_opt_var = _tmp_214_rule(p), !p->error_indicator) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -24020,13 +23028,8 @@ invalid_try_stmt_rule(Parser *p) Token * _keyword; Token * _literal; Token * _literal_1; -<<<<<<< HEAD - asdl_seq * _loop0_210_var; - asdl_seq * _loop1_211_var; -======= - asdl_seq * _loop0_213_var; - asdl_seq * _loop1_214_var; ->>>>>>> upstream/main + asdl_seq * _loop0_215_var; + asdl_seq * _loop1_216_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings Token * a; @@ -24035,23 +23038,13 @@ invalid_try_stmt_rule(Parser *p) && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && -<<<<<<< HEAD - (_loop0_210_var = _loop0_210_rule(p)) // block* - && - (_loop1_211_var = _loop1_211_rule(p)) // except_star_block+ -======= - (_loop0_213_var = _loop0_213_rule(p)) // block* + (_loop0_215_var = _loop0_215_rule(p)) // block* && - (_loop1_214_var = _loop1_214_rule(p)) // except_star_block+ ->>>>>>> upstream/main + (_loop1_216_var = _loop1_216_rule(p)) // except_star_block+ && (a = _PyPegen_expect_token(p, 637)) // token='except' && -<<<<<<< HEAD - (_opt_var = _tmp_212_rule(p), !p->error_indicator) // [expression ['as' NAME]] -======= - (_opt_var = _tmp_215_rule(p), !p->error_indicator) // [expression ['as' NAME]] ->>>>>>> upstream/main + (_opt_var = _tmp_217_rule(p), !p->error_indicator) // [expression ['as' NAME]] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -24119,11 +23112,7 @@ invalid_except_stmt_rule(Parser *p) && (expressions_var = expressions_rule(p)) // expressions && -<<<<<<< HEAD - (_opt_var_1 = _tmp_213_rule(p), !p->error_indicator) // ['as' NAME] -======= - (_opt_var_1 = _tmp_216_rule(p), !p->error_indicator) // ['as' NAME] ->>>>>>> upstream/main + (_opt_var_1 = _tmp_218_rule(p), !p->error_indicator) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' ) @@ -24161,11 +23150,7 @@ invalid_except_stmt_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && -<<<<<<< HEAD - (_opt_var_1 = _tmp_214_rule(p), !p->error_indicator) // ['as' NAME] -======= - (_opt_var_1 = _tmp_217_rule(p), !p->error_indicator) // ['as' NAME] ->>>>>>> upstream/main + (_opt_var_1 = _tmp_219_rule(p), !p->error_indicator) // ['as' NAME] && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -24217,22 +23202,14 @@ invalid_except_stmt_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_except_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); Token * _literal; -<<<<<<< HEAD - void *_tmp_215_var; -======= - void *_tmp_218_var; ->>>>>>> upstream/main + void *_tmp_220_var; Token * a; if ( (a = _PyPegen_expect_token(p, 637)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && -<<<<<<< HEAD - (_tmp_215_var = _tmp_215_rule(p)) // NEWLINE | ':' -======= - (_tmp_218_var = _tmp_218_rule(p)) // NEWLINE | ':' ->>>>>>> upstream/main + (_tmp_220_var = _tmp_220_rule(p)) // NEWLINE | ':' ) { D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' '*' (NEWLINE | ':')")); @@ -24339,11 +23316,7 @@ invalid_except_stmt_indent_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && -<<<<<<< HEAD - (_opt_var = _tmp_216_rule(p), !p->error_indicator) // ['as' NAME] -======= - (_opt_var = _tmp_219_rule(p), !p->error_indicator) // ['as' NAME] ->>>>>>> upstream/main + (_opt_var = _tmp_221_rule(p), !p->error_indicator) // ['as' NAME] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -24438,11 +23411,7 @@ invalid_except_star_stmt_indent_rule(Parser *p) && (expression_var = expression_rule(p)) // expression && -<<<<<<< HEAD - (_opt_var = _tmp_217_rule(p), !p->error_indicator) // ['as' NAME] -======= - (_opt_var = _tmp_220_rule(p), !p->error_indicator) // ['as' NAME] ->>>>>>> upstream/main + (_opt_var = _tmp_222_rule(p), !p->error_indicator) // ['as' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -24811,11 +23780,7 @@ invalid_class_argument_pattern_rule(Parser *p) asdl_pattern_seq* a; asdl_seq* keyword_patterns_var; if ( -<<<<<<< HEAD - (_opt_var = _tmp_218_rule(p), !p->error_indicator) // [positional_patterns ','] -======= - (_opt_var = _tmp_221_rule(p), !p->error_indicator) // [positional_patterns ','] ->>>>>>> upstream/main + (_opt_var = _tmp_223_rule(p), !p->error_indicator) // [positional_patterns ','] && (keyword_patterns_var = keyword_patterns_rule(p)) // keyword_patterns && @@ -25309,11 +24274,7 @@ invalid_def_raw_rule(Parser *p) && (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' && -<<<<<<< HEAD - (_opt_var_2 = _tmp_219_rule(p), !p->error_indicator) // ['->' expression] -======= - (_opt_var_2 = _tmp_222_rule(p), !p->error_indicator) // ['->' expression] ->>>>>>> upstream/main + (_opt_var_2 = _tmp_224_rule(p), !p->error_indicator) // ['->' expression] && (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' && @@ -25373,11 +24334,7 @@ invalid_class_def_raw_rule(Parser *p) && (name_var = _PyPegen_name_token(p)) // NAME && -<<<<<<< HEAD - (_opt_var = _tmp_220_rule(p), !p->error_indicator) // ['(' arguments? ')'] -======= - (_opt_var = _tmp_223_rule(p), !p->error_indicator) // ['(' arguments? ')'] ->>>>>>> upstream/main + (_opt_var = _tmp_225_rule(p), !p->error_indicator) // ['(' arguments? ')'] && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -25412,11 +24369,7 @@ invalid_class_def_raw_rule(Parser *p) && (name_var = _PyPegen_name_token(p)) // NAME && -<<<<<<< HEAD - (_opt_var = _tmp_221_rule(p), !p->error_indicator) // ['(' arguments? ')'] -======= - (_opt_var = _tmp_224_rule(p), !p->error_indicator) // ['(' arguments? ')'] ->>>>>>> upstream/main + (_opt_var = _tmp_226_rule(p), !p->error_indicator) // ['(' arguments? ')'] && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -25467,19 +24420,11 @@ invalid_double_starred_kvpairs_rule(Parser *p) return NULL; } D(fprintf(stderr, "%*c> invalid_double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); -<<<<<<< HEAD - asdl_seq * _gather_222_var; - Token * _literal; - void *invalid_kvpair_var; - if ( - (_gather_222_var = _gather_222_rule(p)) // ','.double_starred_kvpair+ -======= - asdl_seq * _gather_225_var; + asdl_seq * _gather_227_var; Token * _literal; void *invalid_kvpair_var; if ( - (_gather_225_var = _gather_225_rule(p)) // ','.double_starred_kvpair+ ->>>>>>> upstream/main + (_gather_227_var = _gather_227_rule(p)) // ','.double_starred_kvpair+ && (_literal = _PyPegen_expect_token(p, 12)) // token=',' && @@ -25487,11 +24432,7 @@ invalid_double_starred_kvpairs_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ',' invalid_kvpair")); -<<<<<<< HEAD - _res = _PyPegen_dummy_name(p, _gather_222_var, _literal, invalid_kvpair_var); -======= - _res = _PyPegen_dummy_name(p, _gather_225_var, _literal, invalid_kvpair_var); ->>>>>>> upstream/main + _res = _PyPegen_dummy_name(p, _gather_227_var, _literal, invalid_kvpair_var); goto done; } p->mark = _mark; @@ -25544,11 +24485,7 @@ invalid_double_starred_kvpairs_rule(Parser *p) && (a = _PyPegen_expect_token(p, 11)) // token=':' && -<<<<<<< HEAD - _PyPegen_lookahead(1, _tmp_224_rule, p) -======= - _PyPegen_lookahead(1, _tmp_227_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(1, _tmp_229_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); @@ -25659,11 +24596,7 @@ invalid_kvpair_rule(Parser *p) && (a = _PyPegen_expect_token(p, 11)) // token=':' && -<<<<<<< HEAD - _PyPegen_lookahead(1, _tmp_225_rule, p) -======= - _PyPegen_lookahead(1, _tmp_228_rule, p) ->>>>>>> upstream/main + _PyPegen_lookahead(1, _tmp_230_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' &('}' | ',')")); @@ -25881,7 +24814,7 @@ invalid_replacement_field_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - _PyPegen_lookahead(0, _tmp_229_rule, p) + _PyPegen_lookahead(0, _tmp_231_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' !(yield_expr | star_expressions)")); @@ -25904,13 +24837,13 @@ invalid_replacement_field_rule(Parser *p) } D(fprintf(stderr, "%*c> invalid_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) !('=' | '!' | ':' | '}')")); Token * _literal; - void *_tmp_230_var; + void *_tmp_232_var; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_tmp_230_var = _tmp_230_rule(p)) // yield_expr | star_expressions + (_tmp_232_var = _tmp_232_rule(p)) // yield_expr | star_expressions && - _PyPegen_lookahead(0, _tmp_231_rule, p) + _PyPegen_lookahead(0, _tmp_233_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) !('=' | '!' | ':' | '}')")); @@ -25934,15 +24867,15 @@ invalid_replacement_field_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) '=' !('!' | ':' | '}')")); Token * _literal; Token * _literal_1; - void *_tmp_232_var; + void *_tmp_234_var; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_tmp_232_var = _tmp_232_rule(p)) // yield_expr | star_expressions + (_tmp_234_var = _tmp_234_rule(p)) // yield_expr | star_expressions && (_literal_1 = _PyPegen_expect_token(p, 22)) // token='=' && - _PyPegen_lookahead(0, _tmp_233_rule, p) + _PyPegen_lookahead(0, _tmp_235_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) '=' !('!' | ':' | '}')")); @@ -25967,12 +24900,12 @@ invalid_replacement_field_rule(Parser *p) Token * _literal; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings - void *_tmp_234_var; + void *_tmp_236_var; void *invalid_conversion_character_var; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_tmp_234_var = _tmp_234_rule(p)) // yield_expr | star_expressions + (_tmp_236_var = _tmp_236_rule(p)) // yield_expr | star_expressions && (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? && @@ -25980,7 +24913,7 @@ invalid_replacement_field_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ invalid_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) '='? invalid_conversion_character")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_234_var, _opt_var, invalid_conversion_character_var); + _res = _PyPegen_dummy_name(p, _literal, _tmp_236_var, _opt_var, invalid_conversion_character_var); goto done; } p->mark = _mark; @@ -25998,17 +24931,17 @@ invalid_replacement_field_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings void *_opt_var_1; UNUSED(_opt_var_1); // Silence compiler warnings - void *_tmp_235_var; + void *_tmp_237_var; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_tmp_235_var = _tmp_235_rule(p)) // yield_expr | star_expressions + (_tmp_237_var = _tmp_237_rule(p)) // yield_expr | star_expressions && (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? && - (_opt_var_1 = _tmp_236_rule(p), !p->error_indicator) // ['!' NAME] + (_opt_var_1 = _tmp_238_rule(p), !p->error_indicator) // ['!' NAME] && - _PyPegen_lookahead(0, _tmp_237_rule, p) + _PyPegen_lookahead(0, _tmp_239_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_replacement_field[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) '='? ['!' NAME] !(':' | '}')")); @@ -26032,24 +24965,24 @@ invalid_replacement_field_rule(Parser *p) D(fprintf(stderr, "%*c> invalid_replacement_field[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' (yield_expr | star_expressions) '='? ['!' NAME] ':' fstring_format_spec* !'}'")); Token * _literal; Token * _literal_1; - asdl_seq * _loop0_240_var; + asdl_seq * _loop0_242_var; void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings void *_opt_var_1; UNUSED(_opt_var_1); // Silence compiler warnings - void *_tmp_238_var; + void *_tmp_240_var; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_tmp_238_var = _tmp_238_rule(p)) // yield_expr | star_expressions + (_tmp_240_var = _tmp_240_rule(p)) // yield_expr | star_expressions && (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? && - (_opt_var_1 = _tmp_239_rule(p), !p->error_indicator) // ['!' NAME] + (_opt_var_1 = _tmp_241_rule(p), !p->error_indicator) // ['!' NAME] && (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' && - (_loop0_240_var = _loop0_240_rule(p)) // fstring_format_spec* + (_loop0_242_var = _loop0_242_rule(p)) // fstring_format_spec* && _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' ) @@ -26078,15 +25011,15 @@ invalid_replacement_field_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings void *_opt_var_1; UNUSED(_opt_var_1); // Silence compiler warnings - void *_tmp_241_var; + void *_tmp_243_var; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' && - (_tmp_241_var = _tmp_241_rule(p)) // yield_expr | star_expressions + (_tmp_243_var = _tmp_243_rule(p)) // yield_expr | star_expressions && (_opt_var = _PyPegen_expect_token(p, 22), !p->error_indicator) // '='? && - (_opt_var_1 = _tmp_242_rule(p), !p->error_indicator) // ['!' NAME] + (_opt_var_1 = _tmp_244_rule(p), !p->error_indicator) // ['!' NAME] && _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 26) // token='}' ) @@ -26134,7 +25067,7 @@ invalid_conversion_character_rule(Parser *p) if ( (_literal = _PyPegen_expect_token(p, 54)) // token='!' && - _PyPegen_lookahead(1, _tmp_243_rule, p) + _PyPegen_lookahead(1, _tmp_245_rule, p) ) { D(fprintf(stderr, "%*c+ invalid_conversion_character[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' &(':' | '}')")); @@ -27078,23 +26011,13 @@ _loop1_15_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_226_var; - while ( - (_tmp_226_var = _tmp_226_rule(p)) // star_targets '=' - ) - { - _res = _tmp_226_var; -======= D(fprintf(stderr, "%*c> _loop1_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_244_var; + void *_tmp_246_var; while ( - (_tmp_244_var = _tmp_244_rule(p)) // star_targets '=' + (_tmp_246_var = _tmp_246_rule(p)) // star_targets '=' ) { - _res = _tmp_244_var; ->>>>>>> upstream/main + _res = _tmp_246_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27667,23 +26590,13 @@ _loop0_25_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_227_var; - while ( - (_tmp_227_var = _tmp_227_rule(p)) // '.' | '...' - ) - { - _res = _tmp_227_var; -======= D(fprintf(stderr, "%*c> _loop0_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_245_var; + void *_tmp_247_var; while ( - (_tmp_245_var = _tmp_245_rule(p)) // '.' | '...' + (_tmp_247_var = _tmp_247_rule(p)) // '.' | '...' ) { - _res = _tmp_245_var; ->>>>>>> upstream/main + _res = _tmp_247_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -27745,23 +26658,13 @@ _loop1_26_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_228_var; - while ( - (_tmp_228_var = _tmp_228_rule(p)) // '.' | '...' - ) - { - _res = _tmp_228_var; -======= D(fprintf(stderr, "%*c> _loop1_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); - void *_tmp_246_var; + void *_tmp_248_var; while ( - (_tmp_246_var = _tmp_246_rule(p)) // '.' | '...' + (_tmp_248_var = _tmp_248_rule(p)) // '.' | '...' ) { - _res = _tmp_246_var; ->>>>>>> upstream/main + _res = _tmp_248_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -28160,23 +27063,13 @@ _loop1_33_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_229_var; - while ( - (_tmp_229_var = _tmp_229_rule(p)) // '@' named_expression NEWLINE - ) - { - _res = _tmp_229_var; -======= D(fprintf(stderr, "%*c> _loop1_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); - void *_tmp_247_var; + void *_tmp_249_var; while ( - (_tmp_247_var = _tmp_247_rule(p)) // '@' named_expression NEWLINE + (_tmp_249_var = _tmp_249_rule(p)) // '@' named_expression NEWLINE ) { - _res = _tmp_247_var; ->>>>>>> upstream/main + _res = _tmp_249_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31203,10 +30096,9 @@ _gather_79_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_81: ',' type_param +// _loop0_82: ',' type_param static asdl_seq * -_loop0_81_rule(Parser *p) +_loop0_82_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31232,7 +30124,7 @@ _loop0_81_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' type_param")); + D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' type_param")); Token * _literal; typeparam_ty elem; while ( @@ -31264,7 +30156,7 @@ _loop0_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_81[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' type_param")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31281,9 +30173,9 @@ _loop0_81_rule(Parser *p) return _seq; } -// _gather_80: type_param _loop0_81 +// _gather_81: type_param _loop0_82 static asdl_seq * -_gather_80_rule(Parser *p) +_gather_81_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31295,27 +30187,27 @@ _gather_80_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // type_param _loop0_81 + { // type_param _loop0_82 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_param _loop0_81")); + D(fprintf(stderr, "%*c> _gather_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_param _loop0_82")); typeparam_ty elem; asdl_seq * seq; if ( (elem = type_param_rule(p)) // type_param && - (seq = _loop0_81_rule(p)) // _loop0_81 + (seq = _loop0_82_rule(p)) // _loop0_82 ) { - D(fprintf(stderr, "%*c+ _gather_80[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_param _loop0_81")); + D(fprintf(stderr, "%*c+ _gather_81[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_param _loop0_82")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_80[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_param _loop0_81")); + D(fprintf(stderr, "%*c%s _gather_81[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_param _loop0_82")); } _res = NULL; done: @@ -31323,14 +30215,9 @@ _gather_80_rule(Parser *p) return _res; } -// _loop1_82: (',' expression) +// _loop1_83: (',' expression) static asdl_seq * -_loop1_82_rule(Parser *p) -======= -// _loop1_81: (',' expression) -static asdl_seq * -_loop1_81_rule(Parser *p) ->>>>>>> upstream/main +_loop1_83_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31356,23 +30243,13 @@ _loop1_81_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_230_var; - while ( - (_tmp_230_var = _tmp_230_rule(p)) // ',' expression - ) - { - _res = _tmp_230_var; -======= - D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); - void *_tmp_248_var; + D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); + void *_tmp_250_var; while ( - (_tmp_248_var = _tmp_248_rule(p)) // ',' expression + (_tmp_250_var = _tmp_250_rule(p)) // ',' expression ) { - _res = _tmp_248_var; ->>>>>>> upstream/main + _res = _tmp_250_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31389,11 +30266,7 @@ _loop1_81_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); } if (_n == 0 || p->error_indicator) { @@ -31415,15 +30288,9 @@ _loop1_81_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_83: (',' star_expression) -static asdl_seq * -_loop1_83_rule(Parser *p) -======= -// _loop1_82: (',' star_expression) +// _loop1_84: (',' star_expression) static asdl_seq * -_loop1_82_rule(Parser *p) ->>>>>>> upstream/main +_loop1_84_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31449,23 +30316,13 @@ _loop1_82_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_231_var; - while ( - (_tmp_231_var = _tmp_231_rule(p)) // ',' star_expression - ) - { - _res = _tmp_231_var; -======= - D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); - void *_tmp_249_var; + D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); + void *_tmp_251_var; while ( - (_tmp_249_var = _tmp_249_rule(p)) // ',' star_expression + (_tmp_251_var = _tmp_251_rule(p)) // ',' star_expression ) { - _res = _tmp_249_var; ->>>>>>> upstream/main + _res = _tmp_251_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31482,11 +30339,7 @@ _loop1_82_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); } if (_n == 0 || p->error_indicator) { @@ -31508,15 +30361,9 @@ _loop1_82_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_85: ',' star_named_expression +// _loop0_86: ',' star_named_expression static asdl_seq * -_loop0_85_rule(Parser *p) -======= -// _loop0_84: ',' star_named_expression -static asdl_seq * -_loop0_84_rule(Parser *p) ->>>>>>> upstream/main +_loop0_86_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31542,11 +30389,7 @@ _loop0_84_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); -======= - D(fprintf(stderr, "%*c> _loop0_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); Token * _literal; expr_ty elem; while ( @@ -31578,11 +30421,7 @@ _loop0_84_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_84[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_86[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -31599,15 +30438,9 @@ _loop0_84_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_84: star_named_expression _loop0_85 -static asdl_seq * -_gather_84_rule(Parser *p) -======= -// _gather_83: star_named_expression _loop0_84 +// _gather_85: star_named_expression _loop0_86 static asdl_seq * -_gather_83_rule(Parser *p) ->>>>>>> upstream/main +_gather_85_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31619,47 +30452,27 @@ _gather_83_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // star_named_expression _loop0_85 -======= - { // star_named_expression _loop0_84 ->>>>>>> upstream/main + { // star_named_expression _loop0_86 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_85")); -======= - D(fprintf(stderr, "%*c> _gather_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_84")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _gather_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_86")); expr_ty elem; asdl_seq * seq; if ( (elem = star_named_expression_rule(p)) // star_named_expression && -<<<<<<< HEAD - (seq = _loop0_85_rule(p)) // _loop0_85 + (seq = _loop0_86_rule(p)) // _loop0_86 ) { - D(fprintf(stderr, "%*c+ _gather_84[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_85")); -======= - (seq = _loop0_84_rule(p)) // _loop0_84 - ) - { - D(fprintf(stderr, "%*c+ _gather_83[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_84")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_85[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_86")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_84[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_85")); -======= - D(fprintf(stderr, "%*c%s _gather_83[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_84")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_85[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_86")); } _res = NULL; done: @@ -31667,15 +30480,9 @@ _gather_83_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop1_86: ('or' conjunction) -static asdl_seq * -_loop1_86_rule(Parser *p) -======= -// _loop1_85: ('or' conjunction) +// _loop1_87: ('or' conjunction) static asdl_seq * -_loop1_85_rule(Parser *p) ->>>>>>> upstream/main +_loop1_87_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31701,23 +30508,13 @@ _loop1_85_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_232_var; + D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); + void *_tmp_252_var; while ( - (_tmp_232_var = _tmp_232_rule(p)) // 'or' conjunction + (_tmp_252_var = _tmp_252_rule(p)) // 'or' conjunction ) { - _res = _tmp_232_var; -======= - D(fprintf(stderr, "%*c> _loop1_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); - void *_tmp_250_var; - while ( - (_tmp_250_var = _tmp_250_rule(p)) // 'or' conjunction - ) - { - _res = _tmp_250_var; ->>>>>>> upstream/main + _res = _tmp_252_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31734,11 +30531,7 @@ _loop1_85_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_85[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); } if (_n == 0 || p->error_indicator) { @@ -31760,15 +30553,9 @@ _loop1_85_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_87: ('and' inversion) +// _loop1_88: ('and' inversion) static asdl_seq * -_loop1_87_rule(Parser *p) -======= -// _loop1_86: ('and' inversion) -static asdl_seq * -_loop1_86_rule(Parser *p) ->>>>>>> upstream/main +_loop1_88_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31794,23 +30581,13 @@ _loop1_86_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_233_var; - while ( - (_tmp_233_var = _tmp_233_rule(p)) // 'and' inversion - ) - { - _res = _tmp_233_var; -======= - D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); - void *_tmp_251_var; + D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); + void *_tmp_253_var; while ( - (_tmp_251_var = _tmp_251_rule(p)) // 'and' inversion + (_tmp_253_var = _tmp_253_rule(p)) // 'and' inversion ) { - _res = _tmp_251_var; ->>>>>>> upstream/main + _res = _tmp_253_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -31827,11 +30604,7 @@ _loop1_86_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); } if (_n == 0 || p->error_indicator) { @@ -31853,15 +30626,9 @@ _loop1_86_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_88: compare_op_bitwise_or_pair +// _loop1_89: compare_op_bitwise_or_pair static asdl_seq * -_loop1_88_rule(Parser *p) -======= -// _loop1_87: compare_op_bitwise_or_pair -static asdl_seq * -_loop1_87_rule(Parser *p) ->>>>>>> upstream/main +_loop1_89_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31887,11 +30654,7 @@ _loop1_87_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); -======= - D(fprintf(stderr, "%*c> _loop1_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); CmpopExprPair* compare_op_bitwise_or_pair_var; while ( (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair @@ -31914,11 +30677,7 @@ _loop1_87_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_87[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); } if (_n == 0 || p->error_indicator) { @@ -31940,15 +30699,9 @@ _loop1_87_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_89: '!=' -static void * -_tmp_89_rule(Parser *p) -======= -// _tmp_88: '!=' +// _tmp_90: '!=' static void * -_tmp_88_rule(Parser *p) ->>>>>>> upstream/main +_tmp_90_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -31965,21 +30718,13 @@ _tmp_88_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); -======= - D(fprintf(stderr, "%*c> _tmp_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); Token * tok; if ( (tok = _PyPegen_expect_token(p, 28)) // token='!=' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); -======= - D(fprintf(stderr, "%*c+ _tmp_88[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_90[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); _res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -31989,11 +30734,7 @@ _tmp_88_rule(Parser *p) goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_89[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_88[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_90[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); } _res = NULL; @@ -32002,15 +30743,9 @@ _tmp_88_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_91: ',' (slice | starred_expression) +// _loop0_92: ',' (slice | starred_expression) static asdl_seq * -_loop0_91_rule(Parser *p) -======= -// _loop0_90: ',' (slice | starred_expression) -static asdl_seq * -_loop0_90_rule(Parser *p) ->>>>>>> upstream/main +_loop0_92_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32036,21 +30771,13 @@ _loop0_90_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); -======= - D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (slice | starred_expression)")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (elem = _tmp_234_rule(p)) // slice | starred_expression -======= - (elem = _tmp_252_rule(p)) // slice | starred_expression ->>>>>>> upstream/main + (elem = _tmp_254_rule(p)) // slice | starred_expression ) { _res = elem; @@ -32076,11 +30803,7 @@ _loop0_90_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (slice | starred_expression)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -32097,15 +30820,9 @@ _loop0_90_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_90: (slice | starred_expression) _loop0_91 -static asdl_seq * -_gather_90_rule(Parser *p) -======= -// _gather_89: (slice | starred_expression) _loop0_90 +// _gather_91: (slice | starred_expression) _loop0_92 static asdl_seq * -_gather_89_rule(Parser *p) ->>>>>>> upstream/main +_gather_91_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32117,49 +30834,27 @@ _gather_89_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // (slice | starred_expression) _loop0_91 -======= - { // (slice | starred_expression) _loop0_90 ->>>>>>> upstream/main + { // (slice | starred_expression) _loop0_92 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_91")); + D(fprintf(stderr, "%*c> _gather_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_92")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_234_rule(p)) // slice | starred_expression + (elem = _tmp_254_rule(p)) // slice | starred_expression && - (seq = _loop0_91_rule(p)) // _loop0_91 + (seq = _loop0_92_rule(p)) // _loop0_92 ) { - D(fprintf(stderr, "%*c+ _gather_90[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_91")); -======= - D(fprintf(stderr, "%*c> _gather_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_90")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_252_rule(p)) // slice | starred_expression - && - (seq = _loop0_90_rule(p)) // _loop0_90 - ) - { - D(fprintf(stderr, "%*c+ _gather_89[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_90")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(slice | starred_expression) _loop0_92")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_90[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_91")); -======= - D(fprintf(stderr, "%*c%s _gather_89[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_90")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_91[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(slice | starred_expression) _loop0_92")); } _res = NULL; done: @@ -32167,15 +30862,9 @@ _gather_89_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_92: ':' expression? -static void * -_tmp_92_rule(Parser *p) -======= -// _tmp_91: ':' expression? +// _tmp_93: ':' expression? static void * -_tmp_91_rule(Parser *p) ->>>>>>> upstream/main +_tmp_93_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32192,11 +30881,7 @@ _tmp_91_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); -======= - D(fprintf(stderr, "%*c> _tmp_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); Token * _literal; void *d; if ( @@ -32205,11 +30890,7 @@ _tmp_91_rule(Parser *p) (d = expression_rule(p), !p->error_indicator) // expression? ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); -======= - D(fprintf(stderr, "%*c+ _tmp_91[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); _res = d; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -32219,11 +30900,7 @@ _tmp_91_rule(Parser *p) goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_91[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); } _res = NULL; @@ -32232,13 +30909,9 @@ _tmp_91_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_93: tuple | group | genexp +// _tmp_94: STRING | FSTRING_START static void * -======= -// _tmp_92: STRING | FSTRING_START -static void * -_tmp_92_rule(Parser *p) +_tmp_94_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32255,18 +30928,18 @@ _tmp_92_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); expr_ty string_var; if ( (string_var = _PyPegen_string_token(p)) // STRING ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING")); + D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING")); _res = string_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); } { // FSTRING_START @@ -32274,18 +30947,18 @@ _tmp_92_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); + D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); Token * fstring_start_var; if ( (fstring_start_var = _PyPegen_expect_token(p, FSTRING_START)) // token='FSTRING_START' ) { - D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); + D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "FSTRING_START")); _res = fstring_start_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "FSTRING_START")); } _res = NULL; @@ -32294,10 +30967,9 @@ _tmp_92_rule(Parser *p) return _res; } -// _tmp_93: tuple | group | genexp +// _tmp_95: tuple | group | genexp static void * ->>>>>>> upstream/main -_tmp_93_rule(Parser *p) +_tmp_95_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32314,18 +30986,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // group @@ -32333,18 +31005,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); expr_ty group_var; if ( (group_var = group_rule(p)) // group ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); _res = group_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); } { // genexp @@ -32352,18 +31024,18 @@ _tmp_93_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_93[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } _res = NULL; @@ -32372,9 +31044,9 @@ _tmp_93_rule(Parser *p) return _res; } -// _tmp_94: list | listcomp +// _tmp_96: list | listcomp static void * -_tmp_94_rule(Parser *p) +_tmp_96_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32391,18 +31063,18 @@ _tmp_94_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // listcomp @@ -32410,18 +31082,18 @@ _tmp_94_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); expr_ty listcomp_var; if ( (listcomp_var = listcomp_rule(p)) // listcomp ) { - D(fprintf(stderr, "%*c+ _tmp_94[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); + D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); _res = listcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_94[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); } _res = NULL; @@ -32430,9 +31102,9 @@ _tmp_94_rule(Parser *p) return _res; } -// _tmp_95: dict | set | dictcomp | setcomp +// _tmp_97: dict | set | dictcomp | setcomp static void * -_tmp_95_rule(Parser *p) +_tmp_97_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32449,18 +31121,18 @@ _tmp_95_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); expr_ty dict_var; if ( (dict_var = dict_rule(p)) // dict ) { - D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); + D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); _res = dict_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); } { // set @@ -32468,18 +31140,18 @@ _tmp_95_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); expr_ty set_var; if ( (set_var = set_rule(p)) // set ) { - D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); + D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); _res = set_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); } { // dictcomp @@ -32487,18 +31159,18 @@ _tmp_95_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); expr_ty dictcomp_var; if ( (dictcomp_var = dictcomp_rule(p)) // dictcomp ) { - D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); + D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); _res = dictcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); } { // setcomp @@ -32506,18 +31178,18 @@ _tmp_95_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); expr_ty setcomp_var; if ( (setcomp_var = setcomp_rule(p)) // setcomp ) { - D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); + D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); _res = setcomp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); } _res = NULL; @@ -32526,9 +31198,9 @@ _tmp_95_rule(Parser *p) return _res; } -// _tmp_96: yield_expr | named_expression +// _tmp_98: yield_expr | named_expression static void * -_tmp_96_rule(Parser *p) +_tmp_98_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32545,18 +31217,18 @@ _tmp_96_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // named_expression @@ -32564,18 +31236,18 @@ _tmp_96_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); expr_ty named_expression_var; if ( (named_expression_var = named_expression_rule(p)) // named_expression ) { - D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); + D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); _res = named_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); } _res = NULL; @@ -32584,213 +31256,9 @@ _tmp_96_rule(Parser *p) return _res; } -// _loop0_97: lambda_param_no_default -static asdl_seq * -_loop0_97_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - _res = lambda_param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_97[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_98: lambda_param_with_default -static asdl_seq * -_loop0_98_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; - while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default - ) - { - _res = lambda_param_with_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_99: lambda_param_with_default +// _loop0_99: lambda_param_no_default static asdl_seq * _loop0_99_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; - while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default - ) - { - _res = lambda_param_with_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop1_100: lambda_param_no_default -static asdl_seq * -_loop1_100_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32816,7 +31284,7 @@ _loop1_100_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -32839,14 +31307,77 @@ _loop1_100_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_100[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_99[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } - if (_n == 0 || p->error_indicator) { + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); p->level--; return NULL; } + for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_100: lambda_param_with_default +static asdl_seq * +_loop0_100_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + Py_ssize_t _children_capacity = 1; + Py_ssize_t _n = 0; + { // lambda_param_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + if (_n == _children_capacity) { + _children_capacity *= 2; + void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); + if (!_new_children) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + _children = _new_children; + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { PyMem_Free(_children); @@ -32929,9 +31460,82 @@ _loop0_101_rule(Parser *p) return _seq; } -// _loop1_102: lambda_param_with_default +// _loop1_102: lambda_param_no_default static asdl_seq * _loop1_102_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + Py_ssize_t _children_capacity = 1; + Py_ssize_t _n = 0; + { // lambda_param_no_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + while ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default + ) + { + _res = lambda_param_no_default_var; + if (_n == _children_capacity) { + _children_capacity *= 2; + void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); + if (!_new_children) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + _children = _new_children; + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop0_103: lambda_param_with_default +static asdl_seq * +_loop0_103_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -32957,7 +31561,7 @@ _loop1_102_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -32980,7 +31584,75 @@ _loop1_102_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_102[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); + } + asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); + if (!_seq) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); + PyMem_Free(_children); + p->level--; + return _seq; +} + +// _loop1_104: lambda_param_with_default +static asdl_seq * +_loop1_104_rule(Parser *p) +{ + if (p->level++ == MAXSTACK) { + p->error_indicator = 1; + PyErr_NoMemory(); + } + if (p->error_indicator) { + p->level--; + return NULL; + } + void *_res = NULL; + int _mark = p->mark; + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + Py_ssize_t _children_capacity = 1; + Py_ssize_t _n = 0; + { // lambda_param_with_default + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + NameDefaultPair* lambda_param_with_default_var; + while ( + (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default + ) + { + _res = lambda_param_with_default_var; + if (_n == _children_capacity) { + _children_capacity *= 2; + void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); + if (!_new_children) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + _children = _new_children; + } + _children[_n++] = _res; + _mark = p->mark; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -33002,9 +31674,9 @@ _loop1_102_rule(Parser *p) return _seq; } -// _loop1_103: lambda_param_no_default +// _loop1_105: lambda_param_no_default static asdl_seq * -_loop1_103_rule(Parser *p) +_loop1_105_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33030,7 +31702,7 @@ _loop1_103_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -33053,7 +31725,7 @@ _loop1_103_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -33075,9 +31747,9 @@ _loop1_103_rule(Parser *p) return _seq; } -// _loop1_104: lambda_param_no_default +// _loop1_106: lambda_param_no_default static asdl_seq * -_loop1_104_rule(Parser *p) +_loop1_106_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33103,7 +31775,7 @@ _loop1_104_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -33126,7 +31798,7 @@ _loop1_104_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -33148,9 +31820,9 @@ _loop1_104_rule(Parser *p) return _seq; } -// _loop0_105: lambda_param_no_default +// _loop0_107: lambda_param_no_default static asdl_seq * -_loop0_105_rule(Parser *p) +_loop0_107_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33176,7 +31848,7 @@ _loop0_105_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -33199,7 +31871,7 @@ _loop0_105_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33216,9 +31888,9 @@ _loop0_105_rule(Parser *p) return _seq; } -// _loop1_106: lambda_param_with_default +// _loop1_108: lambda_param_with_default static asdl_seq * -_loop1_106_rule(Parser *p) +_loop1_108_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33244,7 +31916,7 @@ _loop1_106_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -33267,7 +31939,7 @@ _loop1_106_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -33289,9 +31961,9 @@ _loop1_106_rule(Parser *p) return _seq; } -// _loop0_107: lambda_param_no_default +// _loop0_109: lambda_param_no_default static asdl_seq * -_loop0_107_rule(Parser *p) +_loop0_109_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33317,7 +31989,7 @@ _loop0_107_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -33340,7 +32012,7 @@ _loop0_107_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_107[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33357,9 +32029,9 @@ _loop0_107_rule(Parser *p) return _seq; } -// _loop1_108: lambda_param_with_default +// _loop1_110: lambda_param_with_default static asdl_seq * -_loop1_108_rule(Parser *p) +_loop1_110_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33385,7 +32057,7 @@ _loop1_108_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -33408,7 +32080,7 @@ _loop1_108_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_108[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -33430,9 +32102,9 @@ _loop1_108_rule(Parser *p) return _seq; } -// _loop0_109: lambda_param_maybe_default +// _loop0_111: lambda_param_maybe_default static asdl_seq * -_loop0_109_rule(Parser *p) +_loop0_111_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33458,7 +32130,7 @@ _loop0_109_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -33481,7 +32153,7 @@ _loop0_109_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_111[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33498,9 +32170,9 @@ _loop0_109_rule(Parser *p) return _seq; } -// _loop1_110: lambda_param_maybe_default +// _loop1_112: lambda_param_maybe_default static asdl_seq * -_loop1_110_rule(Parser *p) +_loop1_112_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33526,7 +32198,7 @@ _loop1_110_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -33549,7 +32221,7 @@ _loop1_110_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_110[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_112[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -33571,14 +32243,9 @@ _loop1_110_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_111: STRING -static asdl_seq * -_loop1_111_rule(Parser *p) -======= -// _tmp_111: yield_expr | star_expressions +// _tmp_113: yield_expr | star_expressions static void * -_tmp_111_rule(Parser *p) +_tmp_113_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33595,18 +32262,18 @@ _tmp_111_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -33614,18 +32281,18 @@ _tmp_111_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -33634,10 +32301,9 @@ _tmp_111_rule(Parser *p) return _res; } -// _loop0_112: fstring_format_spec +// _loop0_114: fstring_format_spec static asdl_seq * -_loop0_112_rule(Parser *p) ->>>>>>> upstream/main +_loop0_114_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33663,13 +32329,8 @@ _loop0_112_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); - expr_ty string_var; -======= - D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); + D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); expr_ty fstring_format_spec_var; ->>>>>>> upstream/main while ( (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec ) @@ -33691,11 +32352,7 @@ _loop0_112_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_111[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); -======= - D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_format_spec")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33712,9 +32369,9 @@ _loop0_112_rule(Parser *p) return _seq; } -// _loop1_113: (fstring | string) +// _loop1_115: (fstring | string) static asdl_seq * -_loop1_113_rule(Parser *p) +_loop1_115_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33740,13 +32397,13 @@ _loop1_113_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(fstring | string)")); - void *_tmp_253_var; + D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(fstring | string)")); + void *_tmp_255_var; while ( - (_tmp_253_var = _tmp_253_rule(p)) // fstring | string + (_tmp_255_var = _tmp_255_rule(p)) // fstring | string ) { - _res = _tmp_253_var; + _res = _tmp_255_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -33763,9 +32420,8 @@ _loop1_113_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_113[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(fstring | string)")); ->>>>>>> upstream/main } if (_n == 0 || p->error_indicator) { PyMem_Free(_children); @@ -33786,15 +32442,9 @@ _loop1_113_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_112: star_named_expression ',' star_named_expressions? -static void * -_tmp_112_rule(Parser *p) -======= -// _tmp_114: star_named_expression ',' star_named_expressions? +// _tmp_116: star_named_expression ',' star_named_expressions? static void * -_tmp_114_rule(Parser *p) ->>>>>>> upstream/main +_tmp_116_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33811,11 +32461,7 @@ _tmp_114_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); -======= - D(fprintf(stderr, "%*c> _tmp_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); Token * _literal; expr_ty y; void *z; @@ -33827,11 +32473,7 @@ _tmp_114_rule(Parser *p) (z = star_named_expressions_rule(p), !p->error_indicator) // star_named_expressions? ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); -======= - D(fprintf(stderr, "%*c+ _tmp_114[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); _res = _PyPegen_seq_insert_in_front ( p , y , z ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -33841,11 +32483,7 @@ _tmp_114_rule(Parser *p) goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_114[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); } _res = NULL; @@ -33854,15 +32492,9 @@ _tmp_114_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_114: ',' double_starred_kvpair +// _loop0_118: ',' double_starred_kvpair static asdl_seq * -_loop0_114_rule(Parser *p) -======= -// _loop0_116: ',' double_starred_kvpair -static asdl_seq * -_loop0_116_rule(Parser *p) ->>>>>>> upstream/main +_loop0_118_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33888,11 +32520,7 @@ _loop0_116_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); -======= - D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -33924,11 +32552,7 @@ _loop0_116_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -33945,15 +32569,9 @@ _loop0_116_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_113: double_starred_kvpair _loop0_114 -static asdl_seq * -_gather_113_rule(Parser *p) -======= -// _gather_115: double_starred_kvpair _loop0_116 +// _gather_117: double_starred_kvpair _loop0_118 static asdl_seq * -_gather_115_rule(Parser *p) ->>>>>>> upstream/main +_gather_117_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -33965,47 +32583,27 @@ _gather_115_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // double_starred_kvpair _loop0_114 -======= - { // double_starred_kvpair _loop0_116 ->>>>>>> upstream/main + { // double_starred_kvpair _loop0_118 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_114")); -======= - D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_116")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_118")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && -<<<<<<< HEAD - (seq = _loop0_114_rule(p)) // _loop0_114 - ) - { - D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_114")); -======= - (seq = _loop0_116_rule(p)) // _loop0_116 + (seq = _loop0_118_rule(p)) // _loop0_118 ) { - D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_116")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_118")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_114")); -======= - D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_116")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_118")); } _res = NULL; done: @@ -34013,15 +32611,9 @@ _gather_115_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop1_115: for_if_clause +// _loop1_119: for_if_clause static asdl_seq * -_loop1_115_rule(Parser *p) -======= -// _loop1_117: for_if_clause -static asdl_seq * -_loop1_117_rule(Parser *p) ->>>>>>> upstream/main +_loop1_119_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34047,11 +32639,7 @@ _loop1_117_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); -======= - D(fprintf(stderr, "%*c> _loop1_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop1_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); comprehension_ty for_if_clause_var; while ( (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause @@ -34074,11 +32662,7 @@ _loop1_117_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_115[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_117[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_119[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); } if (_n == 0 || p->error_indicator) { @@ -34100,15 +32684,9 @@ _loop1_117_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_116: ('if' disjunction) -static asdl_seq * -_loop0_116_rule(Parser *p) -======= -// _loop0_118: ('if' disjunction) +// _loop0_120: ('if' disjunction) static asdl_seq * -_loop0_118_rule(Parser *p) ->>>>>>> upstream/main +_loop0_120_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34134,23 +32712,13 @@ _loop0_118_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_235_var; - while ( - (_tmp_235_var = _tmp_235_rule(p)) // 'if' disjunction - ) - { - _res = _tmp_235_var; -======= - D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_254_var; + D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_256_var; while ( - (_tmp_254_var = _tmp_254_rule(p)) // 'if' disjunction + (_tmp_256_var = _tmp_256_rule(p)) // 'if' disjunction ) { - _res = _tmp_254_var; ->>>>>>> upstream/main + _res = _tmp_256_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -34167,11 +32735,7 @@ _loop0_118_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_120[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34188,15 +32752,9 @@ _loop0_118_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_117: ('if' disjunction) -static asdl_seq * -_loop0_117_rule(Parser *p) -======= -// _loop0_119: ('if' disjunction) +// _loop0_121: ('if' disjunction) static asdl_seq * -_loop0_119_rule(Parser *p) ->>>>>>> upstream/main +_loop0_121_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34222,23 +32780,13 @@ _loop0_119_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_236_var; - while ( - (_tmp_236_var = _tmp_236_rule(p)) // 'if' disjunction - ) - { - _res = _tmp_236_var; -======= - D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); - void *_tmp_255_var; + D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); + void *_tmp_257_var; while ( - (_tmp_255_var = _tmp_255_rule(p)) // 'if' disjunction + (_tmp_257_var = _tmp_257_rule(p)) // 'if' disjunction ) { - _res = _tmp_255_var; ->>>>>>> upstream/main + _res = _tmp_257_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -34255,11 +32803,7 @@ _loop0_119_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34276,15 +32820,9 @@ _loop0_119_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_118: assignment_expression | expression !':=' -static void * -_tmp_118_rule(Parser *p) -======= -// _tmp_120: assignment_expression | expression !':=' +// _tmp_122: assignment_expression | expression !':=' static void * -_tmp_120_rule(Parser *p) ->>>>>>> upstream/main +_tmp_122_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34301,30 +32839,18 @@ _tmp_120_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); -======= - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); expr_ty assignment_expression_var; if ( (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); -======= - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); _res = assignment_expression_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); } { // expression !':=' @@ -34332,11 +32858,7 @@ _tmp_120_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); -======= - D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression @@ -34344,20 +32866,12 @@ _tmp_120_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); -======= - D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); _res = expression_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_118[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_122[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); } _res = NULL; @@ -34366,15 +32880,9 @@ _tmp_120_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_120: ',' (starred_expression | (assignment_expression | expression !':=') !'=') +// _loop0_124: ',' (starred_expression | (assignment_expression | expression !':=') !'=') static asdl_seq * -_loop0_120_rule(Parser *p) -======= -// _loop0_122: ',' (starred_expression | (assignment_expression | expression !':=') !'=') -static asdl_seq * -_loop0_122_rule(Parser *p) ->>>>>>> upstream/main +_loop0_124_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34400,21 +32908,13 @@ _loop0_122_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); -======= - D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (elem = _tmp_237_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' -======= - (elem = _tmp_256_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' ->>>>>>> upstream/main + (elem = _tmp_258_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' ) { _res = elem; @@ -34440,11 +32940,7 @@ _loop0_122_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_120[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | (assignment_expression | expression !':=') !'=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34461,17 +32957,10 @@ _loop0_122_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_119: -// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120 -static asdl_seq * -_gather_119_rule(Parser *p) -======= -// _gather_121: -// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_122 +// _gather_123: +// | (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124 static asdl_seq * -_gather_121_rule(Parser *p) ->>>>>>> upstream/main +_gather_123_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34483,49 +32972,27 @@ _gather_121_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120 -======= - { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_122 ->>>>>>> upstream/main + { // (starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120")); + D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_237_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' + (elem = _tmp_258_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' && - (seq = _loop0_120_rule(p)) // _loop0_120 + (seq = _loop0_124_rule(p)) // _loop0_124 ) { - D(fprintf(stderr, "%*c+ _gather_119[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120")); -======= - D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_122")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_256_rule(p)) // starred_expression | (assignment_expression | expression !':=') !'=' - && - (seq = _loop0_122_rule(p)) // _loop0_122 - ) - { - D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_122")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_119[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_120")); -======= - D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_122")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | (assignment_expression | expression !':=') !'=') _loop0_124")); } _res = NULL; done: @@ -34533,15 +33000,9 @@ _gather_121_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_121: ',' kwargs +// _tmp_125: ',' kwargs static void * -_tmp_121_rule(Parser *p) -======= -// _tmp_123: ',' kwargs -static void * -_tmp_123_rule(Parser *p) ->>>>>>> upstream/main +_tmp_125_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34558,11 +33019,7 @@ _tmp_123_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); -======= - D(fprintf(stderr, "%*c> _tmp_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); Token * _literal; asdl_seq* k; if ( @@ -34571,11 +33028,7 @@ _tmp_123_rule(Parser *p) (k = kwargs_rule(p)) // kwargs ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); -======= - D(fprintf(stderr, "%*c+ _tmp_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); _res = k; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -34585,11 +33038,7 @@ _tmp_123_rule(Parser *p) goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_121[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_123[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); } _res = NULL; @@ -34598,10 +33047,9 @@ _tmp_123_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_123: ',' kwarg_or_starred +// _loop0_127: ',' kwarg_or_starred static asdl_seq * -_loop0_123_rule(Parser *p) +_loop0_127_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34627,7 +33075,7 @@ _loop0_123_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -34659,7 +33107,7 @@ _loop0_123_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_123[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34676,9 +33124,9 @@ _loop0_123_rule(Parser *p) return _seq; } -// _gather_122: kwarg_or_starred _loop0_123 +// _gather_126: kwarg_or_starred _loop0_127 static asdl_seq * -_gather_122_rule(Parser *p) +_gather_126_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34690,27 +33138,27 @@ _gather_122_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_123 + { // kwarg_or_starred _loop0_127 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_123")); + D(fprintf(stderr, "%*c> _gather_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_127")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_123_rule(p)) // _loop0_123 + (seq = _loop0_127_rule(p)) // _loop0_127 ) { - D(fprintf(stderr, "%*c+ _gather_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_123")); + D(fprintf(stderr, "%*c+ _gather_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_127")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_122[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_123")); + D(fprintf(stderr, "%*c%s _gather_126[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_127")); } _res = NULL; done: @@ -34718,12 +33166,9 @@ _gather_122_rule(Parser *p) return _res; } -// _loop0_125: ',' kwarg_or_double_starred -======= -// _loop0_125: ',' kwarg_or_starred ->>>>>>> upstream/main +// _loop0_129: ',' kwarg_or_double_starred static asdl_seq * -_loop0_125_rule(Parser *p) +_loop0_129_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34749,7 +33194,7 @@ _loop0_125_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -34781,7 +33226,7 @@ _loop0_125_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_125[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34798,9 +33243,9 @@ _loop0_125_rule(Parser *p) return _seq; } -// _gather_124: kwarg_or_double_starred _loop0_125 +// _gather_128: kwarg_or_double_starred _loop0_129 static asdl_seq * -_gather_124_rule(Parser *p) +_gather_128_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34812,27 +33257,27 @@ _gather_124_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_125 + { // kwarg_or_double_starred _loop0_129 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_125")); + D(fprintf(stderr, "%*c> _gather_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_129")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_125_rule(p)) // _loop0_125 + (seq = _loop0_129_rule(p)) // _loop0_129 ) { - D(fprintf(stderr, "%*c+ _gather_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_125")); + D(fprintf(stderr, "%*c+ _gather_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_129")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_124[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_125")); + D(fprintf(stderr, "%*c%s _gather_128[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_129")); } _res = NULL; done: @@ -34840,9 +33285,9 @@ _gather_124_rule(Parser *p) return _res; } -// _loop0_127: ',' kwarg_or_starred +// _loop0_131: ',' kwarg_or_starred static asdl_seq * -_loop0_127_rule(Parser *p) +_loop0_131_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34868,7 +33313,7 @@ _loop0_127_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); + D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -34900,7 +33345,7 @@ _loop0_127_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_127[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -34917,9 +33362,9 @@ _loop0_127_rule(Parser *p) return _seq; } -// _gather_126: kwarg_or_starred _loop0_127 +// _gather_130: kwarg_or_starred _loop0_131 static asdl_seq * -_gather_126_rule(Parser *p) +_gather_130_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34931,27 +33376,27 @@ _gather_126_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_starred _loop0_127 + { // kwarg_or_starred _loop0_131 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_127")); + D(fprintf(stderr, "%*c> _gather_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_131")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred && - (seq = _loop0_127_rule(p)) // _loop0_127 + (seq = _loop0_131_rule(p)) // _loop0_131 ) { - D(fprintf(stderr, "%*c+ _gather_126[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_127")); + D(fprintf(stderr, "%*c+ _gather_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_131")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_126[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_127")); + D(fprintf(stderr, "%*c%s _gather_130[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_131")); } _res = NULL; done: @@ -34959,9 +33404,9 @@ _gather_126_rule(Parser *p) return _res; } -// _loop0_129: ',' kwarg_or_double_starred +// _loop0_133: ',' kwarg_or_double_starred static asdl_seq * -_loop0_129_rule(Parser *p) +_loop0_133_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -34987,7 +33432,7 @@ _loop0_129_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); Token * _literal; KeywordOrStarred* elem; while ( @@ -35019,7 +33464,7 @@ _loop0_129_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35036,9 +33481,9 @@ _loop0_129_rule(Parser *p) return _seq; } -// _gather_128: kwarg_or_double_starred _loop0_129 +// _gather_132: kwarg_or_double_starred _loop0_133 static asdl_seq * -_gather_128_rule(Parser *p) +_gather_132_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35050,27 +33495,27 @@ _gather_128_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_129 + { // kwarg_or_double_starred _loop0_133 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_129")); + D(fprintf(stderr, "%*c> _gather_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_133")); KeywordOrStarred* elem; asdl_seq * seq; if ( (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred && - (seq = _loop0_129_rule(p)) // _loop0_129 + (seq = _loop0_133_rule(p)) // _loop0_133 ) { - D(fprintf(stderr, "%*c+ _gather_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_129")); + D(fprintf(stderr, "%*c+ _gather_132[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_133")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_128[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_129")); + D(fprintf(stderr, "%*c%s _gather_132[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_133")); } _res = NULL; done: @@ -35078,15 +33523,9 @@ _gather_128_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_130: (',' star_target) +// _loop0_134: (',' star_target) static asdl_seq * -_loop0_130_rule(Parser *p) -======= -// _loop0_129: ',' kwarg_or_starred -static asdl_seq * -_loop0_129_rule(Parser *p) ->>>>>>> upstream/main +_loop0_134_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35107,19 +33546,18 @@ _loop0_129_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // ',' kwarg_or_starred + { // (',' star_target) if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_238_var; + D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_259_var; while ( - (_tmp_238_var = _tmp_238_rule(p)) // ',' star_target + (_tmp_259_var = _tmp_259_rule(p)) // ',' star_target ) { - _res = _tmp_238_var; + _res = _tmp_259_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -35136,7 +33574,7 @@ _loop0_129_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -35153,9 +33591,9 @@ _loop0_129_rule(Parser *p) return _seq; } -// _loop0_132: ',' star_target +// _loop0_136: ',' star_target static asdl_seq * -_loop0_132_rule(Parser *p) +_loop0_136_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35181,16 +33619,13 @@ _loop0_132_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); -======= - D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; - KeywordOrStarred* elem; + expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + (elem = star_target_rule(p)) // star_target ) { _res = elem; @@ -35216,13 +33651,8 @@ _loop0_132_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); -======= - D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); ->>>>>>> upstream/main } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -35238,15 +33668,9 @@ _loop0_132_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_131: star_target _loop0_132 -static asdl_seq * -_gather_131_rule(Parser *p) -======= -// _gather_128: kwarg_or_starred _loop0_129 +// _gather_135: star_target _loop0_136 static asdl_seq * -_gather_128_rule(Parser *p) ->>>>>>> upstream/main +_gather_135_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35258,48 +33682,27 @@ _gather_128_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // star_target _loop0_132 -======= - { // kwarg_or_starred _loop0_129 ->>>>>>> upstream/main + { // star_target _loop0_136 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_132")); + D(fprintf(stderr, "%*c> _gather_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_136")); expr_ty elem; -======= - D(fprintf(stderr, "%*c> _gather_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_129")); - KeywordOrStarred* elem; ->>>>>>> upstream/main asdl_seq * seq; if ( - (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred + (elem = star_target_rule(p)) // star_target && -<<<<<<< HEAD - (seq = _loop0_132_rule(p)) // _loop0_132 - ) - { - D(fprintf(stderr, "%*c+ _gather_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_132")); -======= - (seq = _loop0_129_rule(p)) // _loop0_129 + (seq = _loop0_136_rule(p)) // _loop0_136 ) { - D(fprintf(stderr, "%*c+ _gather_128[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_129")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_136")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_131[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_132")); -======= - D(fprintf(stderr, "%*c%s _gather_128[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_129")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_135[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_136")); } _res = NULL; done: @@ -35307,14 +33710,9 @@ _gather_128_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop1_133: (',' star_target) +// _loop1_137: (',' star_target) static asdl_seq * -_loop1_133_rule(Parser *p) -======= -// _loop0_131: ',' kwarg_or_double_starred -static asdl_seq * -_loop0_131_rule(Parser *p) +_loop1_137_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35335,27 +33733,18 @@ _loop0_131_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // ',' kwarg_or_double_starred + { // (',' star_target) if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); - Token * _literal; - KeywordOrStarred* elem; + D(fprintf(stderr, "%*c> _loop1_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); + void *_tmp_260_var; while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + (_tmp_260_var = _tmp_260_rule(p)) // ',' star_target ) { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } + _res = _tmp_260_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -35372,8 +33761,13 @@ _loop0_131_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_131[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); + D(fprintf(stderr, "%*c%s _loop1_137[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); + } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -35389,9 +33783,9 @@ _loop0_131_rule(Parser *p) return _seq; } -// _gather_130: kwarg_or_double_starred _loop0_131 -static asdl_seq * -_gather_130_rule(Parser *p) +// _tmp_138: !'*' star_target +static void * +_tmp_138_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35401,29 +33795,28 @@ _gather_130_rule(Parser *p) p->level--; return NULL; } - asdl_seq * _res = NULL; + void * _res = NULL; int _mark = p->mark; - { // kwarg_or_double_starred _loop0_131 + { // !'*' star_target if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_131")); - KeywordOrStarred* elem; - asdl_seq * seq; + D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + expr_ty star_target_var; if ( - (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' && - (seq = _loop0_131_rule(p)) // _loop0_131 + (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _gather_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_131")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); + D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); + _res = star_target_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_130[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_131")); + D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); } _res = NULL; done: @@ -35431,10 +33824,9 @@ _gather_130_rule(Parser *p) return _res; } -// _loop0_132: (',' star_target) +// _loop0_140: ',' del_target static asdl_seq * -_loop0_132_rule(Parser *p) ->>>>>>> upstream/main +_loop0_140_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35455,28 +33847,27 @@ _loop0_132_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // (',' star_target) + { // ',' del_target if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_239_var; - while ( - (_tmp_239_var = _tmp_239_rule(p)) // ',' star_target - ) - { - _res = _tmp_239_var; -======= - D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_257_var; + D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + Token * _literal; + expr_ty elem; while ( - (_tmp_257_var = _tmp_257_rule(p)) // ',' star_target + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = del_target_rule(p)) // del_target ) { - _res = _tmp_257_var; ->>>>>>> upstream/main + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -35493,12 +33884,8 @@ _loop0_132_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_133[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); + D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -35514,10 +33901,9 @@ _loop0_132_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_134: !'*' star_target -static void * -_tmp_134_rule(Parser *p) +// _gather_139: del_target _loop0_140 +static asdl_seq * +_gather_139_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35527,28 +33913,29 @@ _tmp_134_rule(Parser *p) p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; - { // !'*' star_target + { // del_target _loop0_140 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - expr_ty star_target_var; + D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_140")); + expr_ty elem; + asdl_seq * seq; if ( - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' + (elem = del_target_rule(p)) // del_target && - (star_target_var = star_target_rule(p)) // star_target + (seq = _loop0_140_rule(p)) // _loop0_140 ) { - D(fprintf(stderr, "%*c+ _tmp_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - _res = star_target_var; + D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_140")); + _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); + D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_140")); } _res = NULL; done: @@ -35556,12 +33943,9 @@ _tmp_134_rule(Parser *p) return _res; } -// _loop0_136: ',' del_target -======= -// _loop0_134: ',' star_target ->>>>>>> upstream/main +// _loop0_142: ',' expression static asdl_seq * -_loop0_136_rule(Parser *p) +_loop0_142_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35582,22 +33966,18 @@ _loop0_136_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // ',' star_target + { // ',' expression if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); -======= - D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = star_target_rule(p)) // star_target + (elem = expression_rule(p)) // expression ) { _res = elem; @@ -35623,12 +34003,8 @@ _loop0_136_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); -======= - D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -35644,9 +34020,9 @@ _loop0_136_rule(Parser *p) return _seq; } -// _gather_133: star_target _loop0_134 +// _gather_141: expression _loop0_142 static asdl_seq * -_gather_133_rule(Parser *p) +_gather_141_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35658,27 +34034,27 @@ _gather_133_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // star_target _loop0_134 + { // expression _loop0_142 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_134")); + D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); expr_ty elem; asdl_seq * seq; if ( - (elem = star_target_rule(p)) // star_target + (elem = expression_rule(p)) // expression && - (seq = _loop0_134_rule(p)) // _loop0_134 + (seq = _loop0_142_rule(p)) // _loop0_142 ) { - D(fprintf(stderr, "%*c+ _gather_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_134")); + D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_133[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_134")); + D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_142")); } _res = NULL; done: @@ -35686,9 +34062,9 @@ _gather_133_rule(Parser *p) return _res; } -// _loop1_135: (',' star_target) +// _loop0_144: ',' expression static asdl_seq * -_loop1_135_rule(Parser *p) +_loop0_144_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35709,18 +34085,27 @@ _loop1_135_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // (',' star_target) + { // ',' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); - void *_tmp_258_var; + D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + Token * _literal; + expr_ty elem; while ( - (_tmp_258_var = _tmp_258_rule(p)) // ',' star_target + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + && + (elem = expression_rule(p)) // expression ) { - _res = _tmp_258_var; + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -35737,14 +34122,8 @@ _loop1_135_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -35760,15 +34139,9 @@ _loop1_135_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_135: del_target _loop0_136 +// _gather_143: expression _loop0_144 static asdl_seq * -_gather_135_rule(Parser *p) -======= -// _tmp_136: !'*' star_target -static void * -_tmp_136_rule(Parser *p) ->>>>>>> upstream/main +_gather_143_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35778,50 +34151,29 @@ _tmp_136_rule(Parser *p) p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // del_target _loop0_136 -======= - { // !'*' star_target ->>>>>>> upstream/main + { // expression _loop0_144 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_136")); + D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_144")); expr_ty elem; asdl_seq * seq; if ( - (elem = del_target_rule(p)) // del_target -======= - D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - expr_ty star_target_var; - if ( - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' ->>>>>>> upstream/main + (elem = expression_rule(p)) // expression && - (star_target_var = star_target_rule(p)) // star_target + (seq = _loop0_144_rule(p)) // _loop0_144 ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _gather_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_136")); + D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_144")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_135[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_136")); -======= - D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); - _res = star_target_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_144")); } _res = NULL; done: @@ -35829,9 +34181,9 @@ _tmp_136_rule(Parser *p) return _res; } -// _loop0_138: ',' del_target +// _loop0_146: ',' expression static asdl_seq * -_loop0_138_rule(Parser *p) +_loop0_146_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -35852,18 +34204,18 @@ _loop0_138_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // ',' del_target + { // ',' expression if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); + D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = del_target_rule(p)) // del_target + (elem = expression_rule(p)) // expression ) { _res = elem; @@ -35889,364 +34241,7 @@ _loop0_138_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_138[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_137: del_target _loop0_138 -static asdl_seq * -_gather_137_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // del_target _loop0_138 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_138")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = del_target_rule(p)) // del_target - && - (seq = _loop0_138_rule(p)) // _loop0_138 - ) - { - D(fprintf(stderr, "%*c+ _gather_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_138")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_137[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_138")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_140: ',' expression -static asdl_seq * -_loop0_140_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = expression_rule(p)) // expression - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_140[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_139: expression _loop0_140 -static asdl_seq * -_gather_139_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // expression _loop0_140 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_140")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = expression_rule(p)) // expression - && - (seq = _loop0_140_rule(p)) // _loop0_140 - ) - { - D(fprintf(stderr, "%*c+ _gather_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_140")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_139[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_140")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_142: ',' expression -static asdl_seq * -_loop0_142_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = expression_rule(p)) // expression - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_142[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_141: expression _loop0_142 -static asdl_seq * -_gather_141_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // expression _loop0_142 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); - expr_ty elem; - asdl_seq * seq; - if ( - (elem = expression_rule(p)) // expression - && - (seq = _loop0_142_rule(p)) // _loop0_142 - ) - { - D(fprintf(stderr, "%*c+ _gather_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_142")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_141[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_142")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_144: ',' expression -static asdl_seq * -_loop0_144_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); - Token * _literal; - expr_ty elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = expression_rule(p)) // expression - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_144[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36263,9 +34258,9 @@ _loop0_144_rule(Parser *p) return _seq; } -// _gather_143: expression _loop0_144 +// _gather_145: expression _loop0_146 static asdl_seq * -_gather_143_rule(Parser *p) +_gather_145_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36277,27 +34272,27 @@ _gather_143_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_144 + { // expression _loop0_146 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_144")); + D(fprintf(stderr, "%*c> _gather_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_146")); expr_ty elem; asdl_seq * seq; if ( (elem = expression_rule(p)) // expression && - (seq = _loop0_144_rule(p)) // _loop0_144 + (seq = _loop0_146_rule(p)) // _loop0_146 ) { - D(fprintf(stderr, "%*c+ _gather_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_144")); + D(fprintf(stderr, "%*c+ _gather_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_146")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_143[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_144")); + D(fprintf(stderr, "%*c%s _gather_145[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_146")); } _res = NULL; done: @@ -36305,14 +34300,9 @@ _gather_143_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_145: NEWLINE INDENT -static void * -_tmp_145_rule(Parser *p) -======= -// _loop0_146: ',' expression +// _loop0_148: ',' expression static asdl_seq * -_loop0_146_rule(Parser *p) +_loop0_148_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36338,7 +34328,7 @@ _loop0_146_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _loop0_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty elem; while ( @@ -36370,7 +34360,7 @@ _loop0_146_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_148[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -36387,9 +34377,9 @@ _loop0_146_rule(Parser *p) return _seq; } -// _gather_145: expression _loop0_146 +// _gather_147: expression _loop0_148 static asdl_seq * -_gather_145_rule(Parser *p) +_gather_147_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36401,27 +34391,27 @@ _gather_145_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // expression _loop0_146 + { // expression _loop0_148 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_146")); + D(fprintf(stderr, "%*c> _gather_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_148")); expr_ty elem; asdl_seq * seq; if ( (elem = expression_rule(p)) // expression && - (seq = _loop0_146_rule(p)) // _loop0_146 + (seq = _loop0_148_rule(p)) // _loop0_148 ) { - D(fprintf(stderr, "%*c+ _gather_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_146")); + D(fprintf(stderr, "%*c+ _gather_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_148")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_145[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_146")); + D(fprintf(stderr, "%*c%s _gather_147[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_148")); } _res = NULL; done: @@ -36429,10 +34419,9 @@ _gather_145_rule(Parser *p) return _res; } -// _tmp_147: NEWLINE INDENT +// _tmp_149: NEWLINE INDENT static void * -_tmp_147_rule(Parser *p) ->>>>>>> upstream/main +_tmp_149_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36449,11 +34438,7 @@ _tmp_147_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); -======= - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); Token * indent_var; Token * newline_var; if ( @@ -36462,20 +34447,12 @@ _tmp_147_rule(Parser *p) (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); -======= - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); _res = _PyPegen_dummy_name(p, newline_var, indent_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); } _res = NULL; @@ -36484,15 +34461,9 @@ _tmp_147_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_146: args | expression for_if_clauses +// _tmp_150: args | expression for_if_clauses static void * -_tmp_146_rule(Parser *p) -======= -// _tmp_148: args | expression for_if_clauses -static void * -_tmp_148_rule(Parser *p) ->>>>>>> upstream/main +_tmp_150_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36509,30 +34480,18 @@ _tmp_148_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); -======= - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); expr_ty args_var; if ( (args_var = args_rule(p)) // args ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); -======= - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); _res = args_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); } { // expression for_if_clauses @@ -36540,11 +34499,7 @@ _tmp_148_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); -======= - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); expr_ty expression_var; asdl_comprehension_seq* for_if_clauses_var; if ( @@ -36553,20 +34508,12 @@ _tmp_148_rule(Parser *p) (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); -======= - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); } _res = NULL; @@ -36575,15 +34522,9 @@ _tmp_148_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_147: args ',' +// _tmp_151: args ',' static void * -_tmp_147_rule(Parser *p) -======= -// _tmp_149: args ',' -static void * -_tmp_149_rule(Parser *p) ->>>>>>> upstream/main +_tmp_151_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36600,11 +34541,7 @@ _tmp_149_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); -======= - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','")); Token * _literal; expr_ty args_var; if ( @@ -36613,20 +34550,12 @@ _tmp_149_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); -======= - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','")); _res = _PyPegen_dummy_name(p, args_var, _literal); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','")); } _res = NULL; @@ -36635,15 +34564,9 @@ _tmp_149_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_148: ',' | ')' -static void * -_tmp_148_rule(Parser *p) -======= -// _tmp_150: ',' | ')' +// _tmp_152: ',' | ')' static void * -_tmp_150_rule(Parser *p) ->>>>>>> upstream/main +_tmp_152_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36660,30 +34583,18 @@ _tmp_150_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); -======= - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); -======= - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // ')' @@ -36691,30 +34602,18 @@ _tmp_150_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); -======= - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); -======= - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } _res = NULL; @@ -36723,15 +34622,9 @@ _tmp_150_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_149: 'True' | 'False' | 'None' -static void * -_tmp_149_rule(Parser *p) -======= -// _tmp_151: 'True' | 'False' | 'None' +// _tmp_153: 'True' | 'False' | 'None' static void * -_tmp_151_rule(Parser *p) ->>>>>>> upstream/main +_tmp_153_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36748,30 +34641,18 @@ _tmp_151_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); -======= - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 601)) // token='True' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); -======= - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); _res = _keyword; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); } { // 'False' @@ -36779,30 +34660,18 @@ _tmp_151_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); -======= - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 603)) // token='False' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); -======= - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); _res = _keyword; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); } { // 'None' @@ -36810,30 +34679,18 @@ _tmp_151_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); -======= - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 602)) // token='None' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); -======= - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); _res = _keyword; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); } _res = NULL; @@ -36842,15 +34699,9 @@ _tmp_151_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_150: NAME '=' -static void * -_tmp_150_rule(Parser *p) -======= -// _tmp_152: NAME '=' +// _tmp_154: NAME '=' static void * -_tmp_152_rule(Parser *p) ->>>>>>> upstream/main +_tmp_154_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36867,11 +34718,7 @@ _tmp_152_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); -======= - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '='")); Token * _literal; expr_ty name_var; if ( @@ -36880,20 +34727,12 @@ _tmp_152_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); -======= - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '='")); _res = _PyPegen_dummy_name(p, name_var, _literal); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '='")); } _res = NULL; @@ -36902,15 +34741,9 @@ _tmp_152_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_151: NAME STRING | SOFT_KEYWORD -static void * -_tmp_151_rule(Parser *p) -======= -// _tmp_153: NAME STRING | SOFT_KEYWORD +// _tmp_155: NAME STRING | SOFT_KEYWORD static void * -_tmp_153_rule(Parser *p) ->>>>>>> upstream/main +_tmp_155_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -36927,11 +34760,7 @@ _tmp_153_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); -======= - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME STRING")); expr_ty name_var; expr_ty string_var; if ( @@ -36940,20 +34769,12 @@ _tmp_153_rule(Parser *p) (string_var = _PyPegen_string_token(p)) // STRING ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); -======= - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME STRING")); _res = _PyPegen_dummy_name(p, name_var, string_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME STRING")); } { // SOFT_KEYWORD @@ -36961,30 +34782,18 @@ _tmp_153_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); -======= - D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); expr_ty soft_keyword_var; if ( (soft_keyword_var = _PyPegen_soft_keyword_token(p)) // SOFT_KEYWORD ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); -======= - D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "SOFT_KEYWORD")); _res = soft_keyword_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "SOFT_KEYWORD")); } _res = NULL; @@ -36993,15 +34802,9 @@ _tmp_153_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_152: 'else' | ':' +// _tmp_156: 'else' | ':' static void * -_tmp_152_rule(Parser *p) -======= -// _tmp_154: 'else' | ':' -static void * -_tmp_154_rule(Parser *p) ->>>>>>> upstream/main +_tmp_156_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37018,30 +34821,18 @@ _tmp_154_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); -======= - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 645)) // token='else' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); -======= - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); _res = _keyword; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else'")); } { // ':' @@ -37049,30 +34840,18 @@ _tmp_154_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); -======= - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_152[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); -======= - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_152[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } _res = NULL; @@ -37081,12 +34860,9 @@ _tmp_154_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_153: '=' | ':=' -======= -// _tmp_155: FSTRING_MIDDLE | fstring_replacement_field +// _tmp_157: FSTRING_MIDDLE | fstring_replacement_field static void * -_tmp_155_rule(Parser *p) +_tmp_157_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37103,18 +34879,18 @@ _tmp_155_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "FSTRING_MIDDLE")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "FSTRING_MIDDLE")); Token * fstring_middle_var; if ( (fstring_middle_var = _PyPegen_expect_token(p, FSTRING_MIDDLE)) // token='FSTRING_MIDDLE' ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "FSTRING_MIDDLE")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "FSTRING_MIDDLE")); _res = fstring_middle_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "FSTRING_MIDDLE")); } { // fstring_replacement_field @@ -37122,18 +34898,18 @@ _tmp_155_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_replacement_field")); + D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_replacement_field")); expr_ty fstring_replacement_field_var; if ( (fstring_replacement_field_var = fstring_replacement_field_rule(p)) // fstring_replacement_field ) { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring_replacement_field")); + D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring_replacement_field")); _res = fstring_replacement_field_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_replacement_field")); } _res = NULL; @@ -37142,9 +34918,9 @@ _tmp_155_rule(Parser *p) return _res; } -// _tmp_156: '=' | ':=' +// _tmp_158: '=' | ':=' static void * -_tmp_156_rule(Parser *p) +_tmp_158_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37161,18 +34937,18 @@ _tmp_156_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } { // ':=' @@ -37180,18 +34956,18 @@ _tmp_156_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 53)) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); } _res = NULL; @@ -37200,9 +34976,9 @@ _tmp_156_rule(Parser *p) return _res; } -// _tmp_157: list | tuple | genexp | 'True' | 'None' | 'False' +// _tmp_159: list | tuple | genexp | 'True' | 'None' | 'False' static void * -_tmp_157_rule(Parser *p) +_tmp_159_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37219,18 +34995,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); expr_ty list_var; if ( (list_var = list_rule(p)) // list ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); _res = list_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); } { // tuple @@ -37238,18 +35014,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); expr_ty tuple_var; if ( (tuple_var = tuple_rule(p)) // tuple ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); _res = tuple_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); } { // genexp @@ -37257,18 +35033,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); expr_ty genexp_var; if ( (genexp_var = genexp_rule(p)) // genexp ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); _res = genexp_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); } { // 'True' @@ -37276,18 +35052,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 601)) // token='True' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); } { // 'None' @@ -37295,18 +35071,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 602)) // token='None' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); } { // 'False' @@ -37314,18 +35090,18 @@ _tmp_157_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 603)) // token='False' ) { - D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); + D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); _res = _keyword; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); } _res = NULL; @@ -37334,10 +35110,9 @@ _tmp_157_rule(Parser *p) return _res; } -// _tmp_158: '=' | ':=' ->>>>>>> upstream/main +// _tmp_160: '=' | ':=' static void * -_tmp_158_rule(Parser *p) +_tmp_160_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37354,18 +35129,18 @@ _tmp_158_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } { // ':=' @@ -37373,18 +35148,18 @@ _tmp_158_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 53)) // token=':=' ) { - D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); + D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); } _res = NULL; @@ -37393,10 +35168,9 @@ _tmp_158_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_154: list | tuple | genexp | 'True' | 'None' | 'False' -static void * -_tmp_154_rule(Parser *p) +// _loop0_161: star_named_expressions +static asdl_seq * +_loop0_161_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37406,251 +35180,46 @@ _tmp_154_rule(Parser *p) p->level--; return NULL; } - void * _res = NULL; + void *_res = NULL; int _mark = p->mark; - { // list + void **_children = PyMem_Malloc(sizeof(void *)); + if (!_children) { + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + Py_ssize_t _children_capacity = 1; + Py_ssize_t _n = 0; + { // star_named_expressions if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); - expr_ty list_var; - if ( - (list_var = list_rule(p)) // list + D(fprintf(stderr, "%*c> _loop0_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); + asdl_expr_seq* star_named_expressions_var; + while ( + (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); - _res = list_var; - goto done; + _res = star_named_expressions_var; + if (_n == _children_capacity) { + _children_capacity *= 2; + void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); + if (!_new_children) { + PyMem_Free(_children); + p->error_indicator = 1; + PyErr_NoMemory(); + p->level--; + return NULL; + } + _children = _new_children; + } + _children[_n++] = _res; + _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); - } - { // tuple - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); - expr_ty tuple_var; - if ( - (tuple_var = tuple_rule(p)) // tuple - ) - { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); - _res = tuple_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); - } - { // genexp - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); - expr_ty genexp_var; - if ( - (genexp_var = genexp_rule(p)) // genexp - ) - { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); - _res = genexp_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); - } - { // 'True' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 600)) // token='True' - ) - { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); - } - { // 'None' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 601)) // token='None' - ) - { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); - } - { // 'False' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); - Token * _keyword; - if ( - (_keyword = _PyPegen_expect_token(p, 602)) // token='False' - ) - { - D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); - _res = _keyword; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_155: '=' | ':=' -static void * -_tmp_155_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); - } - { // ':=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 53)) // token=':=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_155[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_155[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_156: star_named_expressions -static asdl_seq * -_loop0_156_rule(Parser *p) -======= -// _loop0_159: star_named_expressions -static asdl_seq * -_loop0_159_rule(Parser *p) ->>>>>>> upstream/main -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // star_named_expressions - if (p->error_indicator) { - p->level--; - return NULL; - } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); -======= - D(fprintf(stderr, "%*c> _loop0_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); ->>>>>>> upstream/main - asdl_expr_seq* star_named_expressions_var; - while ( - (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions - ) - { - _res = star_named_expressions_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_156[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_159[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_161[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -37667,15 +35236,9 @@ _loop0_159_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_157: (star_targets '=') -static asdl_seq * -_loop0_157_rule(Parser *p) -======= -// _loop0_160: (star_targets '=') +// _loop0_162: (star_targets '=') static asdl_seq * -_loop0_160_rule(Parser *p) ->>>>>>> upstream/main +_loop0_162_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37701,23 +35264,13 @@ _loop0_160_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_240_var; - while ( - (_tmp_240_var = _tmp_240_rule(p)) // star_targets '=' - ) - { - _res = _tmp_240_var; -======= - D(fprintf(stderr, "%*c> _loop0_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_259_var; + D(fprintf(stderr, "%*c> _loop0_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_261_var; while ( - (_tmp_259_var = _tmp_259_rule(p)) // star_targets '=' + (_tmp_261_var = _tmp_261_rule(p)) // star_targets '=' ) { - _res = _tmp_259_var; ->>>>>>> upstream/main + _res = _tmp_261_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -37734,11 +35287,7 @@ _loop0_160_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_157[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_160[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_162[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -37755,15 +35304,9 @@ _loop0_160_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_158: (star_targets '=') -static asdl_seq * -_loop0_158_rule(Parser *p) -======= -// _loop0_161: (star_targets '=') +// _loop0_163: (star_targets '=') static asdl_seq * -_loop0_161_rule(Parser *p) ->>>>>>> upstream/main +_loop0_163_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37789,23 +35332,13 @@ _loop0_161_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_241_var; - while ( - (_tmp_241_var = _tmp_241_rule(p)) // star_targets '=' - ) - { - _res = _tmp_241_var; -======= - D(fprintf(stderr, "%*c> _loop0_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); - void *_tmp_260_var; + D(fprintf(stderr, "%*c> _loop0_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); + void *_tmp_262_var; while ( - (_tmp_260_var = _tmp_260_rule(p)) // star_targets '=' + (_tmp_262_var = _tmp_262_rule(p)) // star_targets '=' ) { - _res = _tmp_260_var; ->>>>>>> upstream/main + _res = _tmp_262_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -37822,11 +35355,7 @@ _loop0_161_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_158[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_161[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_163[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -37843,15 +35372,9 @@ _loop0_161_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_159: yield_expr | star_expressions -static void * -_tmp_159_rule(Parser *p) -======= -// _tmp_162: yield_expr | star_expressions +// _tmp_164: yield_expr | star_expressions static void * -_tmp_162_rule(Parser *p) ->>>>>>> upstream/main +_tmp_164_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -37868,30 +35391,18 @@ _tmp_162_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); -======= - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); -======= - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -37899,169 +35410,19 @@ _tmp_162_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); -======= - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); -======= - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_159[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _tmp_160: '[' | '(' | '{' -======= -// _tmp_163: '[' | '(' | '{' -static void * -_tmp_163_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '[' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - ) - { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); - } - { // '(' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 7)) // token='(' - ) - { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); - } - { // '{' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - ) - { - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_164: '[' | '{' -static void * -_tmp_164_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '[' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 9)) // token='[' - ) - { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); - } - { // '{' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 25)) // token='{' - ) - { - D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); - _res = _literal; - goto done; - } - p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; done: @@ -38069,8 +35430,7 @@ _tmp_164_rule(Parser *p) return _res; } -// _tmp_165: '[' | '{' ->>>>>>> upstream/main +// _tmp_165: '[' | '(' | '{' static void * _tmp_165_rule(Parser *p) { @@ -38108,18 +35468,18 @@ _tmp_165_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 7)) // token='(' ) { - D(fprintf(stderr, "%*c+ _tmp_160[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); + D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_160[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); } { // '{' @@ -38147,10 +35507,9 @@ _tmp_165_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_161: '[' | '{' +// _tmp_166: '[' | '{' static void * -_tmp_161_rule(Parser *p) +_tmp_166_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38167,18 +35526,18 @@ _tmp_161_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '{' @@ -38186,18 +35545,18 @@ _tmp_161_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_161[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -38206,9 +35565,9 @@ _tmp_161_rule(Parser *p) return _res; } -// _tmp_162: '[' | '{' +// _tmp_167: '[' | '{' static void * -_tmp_162_rule(Parser *p) +_tmp_167_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38225,18 +35584,18 @@ _tmp_162_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 9)) // token='[' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); } { // '{' @@ -38244,18 +35603,18 @@ _tmp_162_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 25)) // token='{' ) { - D(fprintf(stderr, "%*c+ _tmp_162[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); + D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_162[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); } _res = NULL; @@ -38264,14 +35623,9 @@ _tmp_162_rule(Parser *p) return _res; } -// _tmp_163: slash_no_default | slash_with_default -static void * -_tmp_163_rule(Parser *p) -======= -// _tmp_166: slash_no_default | slash_with_default +// _tmp_168: slash_no_default | slash_with_default static void * -_tmp_166_rule(Parser *p) ->>>>>>> upstream/main +_tmp_168_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38288,30 +35642,18 @@ _tmp_166_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); -======= - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); asdl_arg_seq* slash_no_default_var; if ( (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); _res = slash_no_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); } { // slash_with_default @@ -38319,30 +35661,18 @@ _tmp_166_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); -======= - D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); SlashWithDefault* slash_with_default_var; if ( (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); _res = slash_with_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); } _res = NULL; @@ -38351,15 +35681,9 @@ _tmp_166_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_164: param_maybe_default -static asdl_seq * -_loop0_164_rule(Parser *p) -======= -// _loop0_167: param_maybe_default +// _loop0_169: param_maybe_default static asdl_seq * -_loop0_167_rule(Parser *p) ->>>>>>> upstream/main +_loop0_169_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38385,7 +35709,7 @@ _loop0_167_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -38408,7 +35732,7 @@ _loop0_167_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_164[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -38425,10 +35749,9 @@ _loop0_167_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_165: param_no_default +// _loop0_170: param_no_default static asdl_seq * -_loop0_165_rule(Parser *p) +_loop0_170_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38454,7 +35777,7 @@ _loop0_165_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; while ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -38477,7 +35800,7 @@ _loop0_165_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_165[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_170[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -38494,9 +35817,9 @@ _loop0_165_rule(Parser *p) return _seq; } -// _loop0_166: param_no_default +// _loop0_171: param_no_default static asdl_seq * -_loop0_166_rule(Parser *p) +_loop0_171_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38522,7 +35845,7 @@ _loop0_166_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; while ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -38545,7 +35868,7 @@ _loop0_166_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_166[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_171[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -38562,9 +35885,9 @@ _loop0_166_rule(Parser *p) return _seq; } -// _loop1_167: param_no_default +// _loop1_172: param_no_default static asdl_seq * -_loop1_167_rule(Parser *p) +_loop1_172_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38590,7 +35913,7 @@ _loop1_167_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _loop1_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; while ( (param_no_default_var = param_no_default_rule(p)) // param_no_default @@ -38613,7 +35936,7 @@ _loop1_167_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_167[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_172[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } if (_n == 0 || p->error_indicator) { @@ -38635,14 +35958,9 @@ _loop1_167_rule(Parser *p) return _seq; } -// _tmp_168: slash_no_default | slash_with_default +// _tmp_173: slash_no_default | slash_with_default static void * -_tmp_168_rule(Parser *p) -======= -// _loop0_168: param_no_default -static asdl_seq * -_loop0_168_rule(Parser *p) ->>>>>>> upstream/main +_tmp_173_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38652,104 +35970,55 @@ _loop0_168_rule(Parser *p) p->level--; return NULL; } - void *_res = NULL; + void * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD { // slash_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); asdl_arg_seq* slash_no_default_var; if ( (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); _res = slash_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); } { // slash_with_default -======= - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_no_default ->>>>>>> upstream/main if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); SlashWithDefault* slash_with_default_var; if ( (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default ) { - D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); + D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); _res = slash_with_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); -======= - D(fprintf(stderr, "%*c> _loop0_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; - while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default - ) - { - _res = param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_168[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); ->>>>>>> upstream/main - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); + _res = NULL; + done: p->level--; - return _seq; + return _res; } -// _loop0_169: param_no_default +// _loop0_174: param_maybe_default static asdl_seq * -_loop0_169_rule(Parser *p) +_loop0_174_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38770,18 +36039,18 @@ _loop0_169_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // param_no_default + { // param_maybe_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; + D(fprintf(stderr, "%*c> _loop0_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default ) { - _res = param_no_default_var; + _res = param_maybe_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -38798,8 +36067,8 @@ _loop0_169_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_169[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c%s _loop0_174[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -38815,10 +36084,9 @@ _loop0_169_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_170: ',' | param_no_default +// _tmp_175: ',' | param_no_default static void * -_tmp_170_rule(Parser *p) +_tmp_175_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38835,18 +36103,18 @@ _tmp_170_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // param_no_default @@ -38854,18 +36122,18 @@ _tmp_170_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; if ( (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); _res = param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } _res = NULL; @@ -38874,12 +36142,9 @@ _tmp_170_rule(Parser *p) return _res; } -// _loop0_171: param_maybe_default -======= -// _loop1_170: param_no_default ->>>>>>> upstream/main +// _loop0_176: param_maybe_default static asdl_seq * -_loop0_171_rule(Parser *p) +_loop0_176_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -38900,18 +36165,18 @@ _loop0_171_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // param_no_default + { // param_maybe_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; + D(fprintf(stderr, "%*c> _loop0_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); + NameDefaultPair* param_maybe_default_var; while ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default + (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default ) { - _res = param_no_default_var; + _res = param_maybe_default_var; if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -38928,13 +36193,8 @@ _loop0_171_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_170[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _loop0_176[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -38950,67 +36210,9 @@ _loop0_171_rule(Parser *p) return _seq; } -// _tmp_171: slash_no_default | slash_with_default -static void * -_tmp_171_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // slash_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default")); - asdl_arg_seq* slash_no_default_var; - if ( - (slash_no_default_var = slash_no_default_rule(p)) // slash_no_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default")); - _res = slash_no_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default")); - } - { // slash_with_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); - SlashWithDefault* slash_with_default_var; - if ( - (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); - _res = slash_with_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_172: param_maybe_default +// _loop1_177: param_maybe_default static asdl_seq * -_loop0_172_rule(Parser *p) +_loop1_177_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39036,11 +36238,7 @@ _loop0_172_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); -======= - D(fprintf(stderr, "%*c> _loop0_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop1_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -39063,10 +36261,14 @@ _loop0_172_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_171[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_177[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } + if (_n == 0 || p->error_indicator) { + PyMem_Free(_children); + p->level--; + return NULL; + } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { PyMem_Free(_children); @@ -39081,298 +36283,9 @@ _loop0_172_rule(Parser *p) return _seq; } -// _loop1_172: param_maybe_default -static asdl_seq * -_loop1_172_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_maybe_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); - NameDefaultPair* param_maybe_default_var; - while ( - (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default - ) - { - _res = param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_172[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_172[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -<<<<<<< HEAD -// _tmp_173: ')' | ',' -======= -// _tmp_173: ',' | param_no_default ->>>>>>> upstream/main -static void * -_tmp_173_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; -<<<<<<< HEAD - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } -======= ->>>>>>> upstream/main - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } - { // param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); - arg_ty param_no_default_var; - if ( - (param_no_default_var = param_no_default_rule(p)) // param_no_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); - _res = param_no_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_174: ')' | ',' (')' | '**') -static void * -_tmp_174_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } - { // ',' (')' | '**') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - Token * _literal; - void *_tmp_242_var; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_tmp_242_var = _tmp_242_rule(p)) // ')' | '**' - ) - { - D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_242_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop1_175: param_maybe_default -static asdl_seq * -_loop1_175_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // param_maybe_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop1_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); - NameDefaultPair* param_maybe_default_var; - while ( - (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default - ) - { - _res = param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_175[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _tmp_176: ')' | ',' +// _tmp_178: ')' | ',' static void * -_tmp_176_rule(Parser *p) +_tmp_178_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39389,18 +36302,18 @@ _tmp_176_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' @@ -39408,18 +36321,18 @@ _tmp_176_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -39428,9 +36341,9 @@ _tmp_176_rule(Parser *p) return _res; } -// _tmp_177: ')' | ',' (')' | '**') +// _tmp_179: ')' | ',' (')' | '**') static void * -_tmp_177_rule(Parser *p) +_tmp_179_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39447,18 +36360,18 @@ _tmp_177_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // ',' (')' | '**') @@ -39466,21 +36379,21 @@ _tmp_177_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); Token * _literal; - void *_tmp_261_var; + void *_tmp_263_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_261_var = _tmp_261_rule(p)) // ')' | '**' + (_tmp_263_var = _tmp_263_rule(p)) // ')' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_261_var); + D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_263_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); } _res = NULL; @@ -39489,9 +36402,9 @@ _tmp_177_rule(Parser *p) return _res; } -// _tmp_178: param_no_default | ',' +// _tmp_180: param_no_default | ',' static void * -_tmp_178_rule(Parser *p) +_tmp_180_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39508,18 +36421,18 @@ _tmp_178_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; if ( (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); _res = param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } { // ',' @@ -39527,18 +36440,18 @@ _tmp_178_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -39547,15 +36460,9 @@ _tmp_178_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_176: param_maybe_default -static asdl_seq * -_loop0_176_rule(Parser *p) -======= -// _loop0_179: param_maybe_default +// _loop0_181: param_maybe_default static asdl_seq * -_loop0_179_rule(Parser *p) ->>>>>>> upstream/main +_loop0_181_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39581,11 +36488,7 @@ _loop0_179_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); -======= - D(fprintf(stderr, "%*c> _loop0_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); NameDefaultPair* param_maybe_default_var; while ( (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default @@ -39608,11 +36511,7 @@ _loop0_179_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_176[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_179[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_181[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -39629,15 +36528,9 @@ _loop0_179_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_177: param_no_default | ',' -static void * -_tmp_177_rule(Parser *p) -======= -// _tmp_180: param_no_default | ',' +// _tmp_182: param_no_default | ',' static void * -_tmp_180_rule(Parser *p) ->>>>>>> upstream/main +_tmp_182_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39654,30 +36547,18 @@ _tmp_180_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); -======= - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); arg_ty param_no_default_var; if ( (param_no_default_var = param_no_default_rule(p)) // param_no_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default")); _res = param_no_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); } { // ',' @@ -39685,30 +36566,18 @@ _tmp_180_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); -======= - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); -======= - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_182[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -39717,15 +36586,9 @@ _tmp_180_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_178: '*' | '**' | '/' +// _tmp_183: '*' | '**' | '/' static void * -_tmp_178_rule(Parser *p) -======= -// _tmp_181: '*' | '**' | '/' -static void * -_tmp_181_rule(Parser *p) ->>>>>>> upstream/main +_tmp_183_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39742,30 +36605,18 @@ _tmp_181_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); -======= - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); -======= - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -39773,30 +36624,18 @@ _tmp_181_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); -======= - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); -======= - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } { // '/' @@ -39804,30 +36643,18 @@ _tmp_181_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); -======= - D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 17)) // token='/' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); -======= - D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); } _res = NULL; @@ -39836,15 +36663,9 @@ _tmp_181_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop1_179: param_with_default -static asdl_seq * -_loop1_179_rule(Parser *p) -======= -// _loop1_182: param_with_default +// _loop1_184: param_with_default static asdl_seq * -_loop1_182_rule(Parser *p) ->>>>>>> upstream/main +_loop1_184_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39870,11 +36691,7 @@ _loop1_182_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); -======= - D(fprintf(stderr, "%*c> _loop1_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop1_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); NameDefaultPair* param_with_default_var; while ( (param_with_default_var = param_with_default_rule(p)) // param_with_default @@ -39897,11 +36714,7 @@ _loop1_182_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_179[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_182[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_184[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -39923,15 +36736,9 @@ _loop1_182_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_180: lambda_slash_no_default | lambda_slash_with_default +// _tmp_185: lambda_slash_no_default | lambda_slash_with_default static void * -_tmp_180_rule(Parser *p) -======= -// _tmp_183: lambda_slash_no_default | lambda_slash_with_default -static void * -_tmp_183_rule(Parser *p) ->>>>>>> upstream/main +_tmp_185_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -39948,30 +36755,18 @@ _tmp_183_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); -======= - D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); asdl_arg_seq* lambda_slash_no_default_var; if ( (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); _res = lambda_slash_no_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default")); } { // lambda_slash_with_default @@ -39979,30 +36774,18 @@ _tmp_183_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); -======= - D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); SlashWithDefault* lambda_slash_with_default_var; if ( (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); _res = lambda_slash_with_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); } _res = NULL; @@ -40011,15 +36794,9 @@ _tmp_183_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_181: lambda_param_maybe_default +// _loop0_186: lambda_param_maybe_default static asdl_seq * -_loop0_181_rule(Parser *p) -======= -// _loop0_184: lambda_param_maybe_default -static asdl_seq * -_loop0_184_rule(Parser *p) ->>>>>>> upstream/main +_loop0_186_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40045,11 +36822,7 @@ _loop0_184_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); -======= - D(fprintf(stderr, "%*c> _loop0_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -40072,11 +36845,7 @@ _loop0_184_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_181[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_184[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_186[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -40093,15 +36862,9 @@ _loop0_184_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_182: lambda_param_no_default -static asdl_seq * -_loop0_182_rule(Parser *p) -======= -// _loop0_185: lambda_param_no_default +// _loop0_187: lambda_param_no_default static asdl_seq * -_loop0_185_rule(Parser *p) ->>>>>>> upstream/main +_loop0_187_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40127,11 +36890,7 @@ _loop0_185_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); -======= - D(fprintf(stderr, "%*c> _loop0_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -40154,11 +36913,7 @@ _loop0_185_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_182[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_185[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_187[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -40175,12 +36930,9 @@ _loop0_185_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop0_183: lambda_param_no_default -======= -// _loop0_186: lambda_param_no_default +// _loop0_188: lambda_param_no_default static asdl_seq * -_loop0_186_rule(Parser *p) +_loop0_188_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40206,7 +36958,7 @@ _loop0_186_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _loop0_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; while ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default @@ -40229,76 +36981,7 @@ _loop0_186_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_186[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _loop0_188: ',' lambda_param ->>>>>>> upstream/main -static asdl_seq * -_loop0_188_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - while ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - _res = lambda_param_no_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_183[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_188[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -40315,9 +36998,9 @@ _loop0_188_rule(Parser *p) return _seq; } -// _loop0_185: ',' lambda_param +// _loop0_190: ',' lambda_param static asdl_seq * -_loop0_185_rule(Parser *p) +_loop0_190_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40343,11 +37026,7 @@ _loop0_185_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); -======= - D(fprintf(stderr, "%*c> _loop0_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' lambda_param")); Token * _literal; arg_ty elem; while ( @@ -40379,11 +37058,7 @@ _loop0_185_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_185[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_188[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_190[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' lambda_param")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -40400,15 +37075,9 @@ _loop0_185_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_184: lambda_param _loop0_185 +// _gather_189: lambda_param _loop0_190 static asdl_seq * -_gather_184_rule(Parser *p) -======= -// _gather_187: lambda_param _loop0_188 -static asdl_seq * -_gather_187_rule(Parser *p) ->>>>>>> upstream/main +_gather_189_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40420,47 +37089,27 @@ _gather_187_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // lambda_param _loop0_185 -======= - { // lambda_param _loop0_188 ->>>>>>> upstream/main + { // lambda_param _loop0_190 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_185")); -======= - D(fprintf(stderr, "%*c> _gather_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_188")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _gather_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_190")); arg_ty elem; asdl_seq * seq; if ( (elem = lambda_param_rule(p)) // lambda_param && -<<<<<<< HEAD - (seq = _loop0_185_rule(p)) // _loop0_185 - ) - { - D(fprintf(stderr, "%*c+ _gather_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_185")); -======= - (seq = _loop0_188_rule(p)) // _loop0_188 + (seq = _loop0_190_rule(p)) // _loop0_190 ) { - D(fprintf(stderr, "%*c+ _gather_187[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_188")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param _loop0_190")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_184[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_185")); -======= - D(fprintf(stderr, "%*c%s _gather_187[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_188")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_189[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param _loop0_190")); } _res = NULL; done: @@ -40468,15 +37117,9 @@ _gather_187_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_186: lambda_slash_no_default | lambda_slash_with_default -static void * -_tmp_186_rule(Parser *p) -======= -// _tmp_189: lambda_slash_no_default | lambda_slash_with_default +// _tmp_191: lambda_slash_no_default | lambda_slash_with_default static void * -_tmp_189_rule(Parser *p) ->>>>>>> upstream/main +_tmp_191_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40493,30 +37136,18 @@ _tmp_189_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); -======= - D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); asdl_arg_seq* lambda_slash_no_default_var; if ( (lambda_slash_no_default_var = lambda_slash_no_default_rule(p)) // lambda_slash_no_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default")); _res = lambda_slash_no_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_189[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default")); } { // lambda_slash_with_default @@ -40524,30 +37155,18 @@ _tmp_189_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_186[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); -======= - D(fprintf(stderr, "%*c> _tmp_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); SlashWithDefault* lambda_slash_with_default_var; if ( (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_186[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_189[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); _res = lambda_slash_with_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_186[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_189[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); } _res = NULL; @@ -40556,15 +37175,9 @@ _tmp_189_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_187: lambda_param_maybe_default -static asdl_seq * -_loop0_187_rule(Parser *p) -======= -// _loop0_190: lambda_param_maybe_default +// _loop0_192: lambda_param_maybe_default static asdl_seq * -_loop0_190_rule(Parser *p) ->>>>>>> upstream/main +_loop0_192_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40590,11 +37203,7 @@ _loop0_190_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_187[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); -======= - D(fprintf(stderr, "%*c> _loop0_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -40617,11 +37226,7 @@ _loop0_190_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_187[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_190[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_192[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -40638,15 +37243,9 @@ _loop0_190_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_188: ',' | lambda_param_no_default +// _tmp_193: ',' | lambda_param_no_default static void * -_tmp_188_rule(Parser *p) -======= -// _tmp_191: ',' | lambda_param_no_default -static void * -_tmp_191_rule(Parser *p) ->>>>>>> upstream/main +_tmp_193_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40663,30 +37262,18 @@ _tmp_191_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); -======= - D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); -======= - D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_188[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // lambda_param_no_default @@ -40694,30 +37281,18 @@ _tmp_191_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_188[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); -======= - D(fprintf(stderr, "%*c> _tmp_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; if ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_188[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); -======= - D(fprintf(stderr, "%*c+ _tmp_191[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_193[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); _res = lambda_param_no_default_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_188[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_191[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_193[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } _res = NULL; @@ -40726,15 +37301,9 @@ _tmp_191_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_189: lambda_param_maybe_default -static asdl_seq * -_loop0_189_rule(Parser *p) -======= -// _loop0_192: lambda_param_maybe_default +// _loop0_194: lambda_param_maybe_default static asdl_seq * -_loop0_192_rule(Parser *p) ->>>>>>> upstream/main +_loop0_194_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40760,11 +37329,7 @@ _loop0_192_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_189[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); -======= - D(fprintf(stderr, "%*c> _loop0_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -40787,11 +37352,7 @@ _loop0_192_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_189[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_192[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_194[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -40808,10 +37369,9 @@ _loop0_192_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_190: lambda_param_maybe_default +// _loop1_195: lambda_param_maybe_default static asdl_seq * -_loop1_190_rule(Parser *p) +_loop1_195_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40837,7 +37397,7 @@ _loop1_190_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_190[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop1_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default @@ -40860,7 +37420,7 @@ _loop1_190_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_190[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_195[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } if (_n == 0 || p->error_indicator) { @@ -40882,9 +37442,9 @@ _loop1_190_rule(Parser *p) return _seq; } -// _loop1_191: lambda_param_with_default +// _loop1_196: lambda_param_with_default static asdl_seq * -_loop1_191_rule(Parser *p) +_loop1_196_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40910,7 +37470,7 @@ _loop1_191_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_191[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); + D(fprintf(stderr, "%*c> _loop1_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); NameDefaultPair* lambda_param_with_default_var; while ( (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default @@ -40933,7 +37493,7 @@ _loop1_191_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_191[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop1_196[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); } if (_n == 0 || p->error_indicator) { @@ -40955,9 +37515,9 @@ _loop1_191_rule(Parser *p) return _seq; } -// _tmp_192: ':' | ',' (':' | '**') +// _tmp_197: ':' | ',' (':' | '**') static void * -_tmp_192_rule(Parser *p) +_tmp_197_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -40974,18 +37534,18 @@ _tmp_192_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_192[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_192[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // ',' (':' | '**') @@ -40993,21 +37553,21 @@ _tmp_192_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_192[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); Token * _literal; - void *_tmp_243_var; + void *_tmp_264_var; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (_tmp_243_var = _tmp_243_rule(p)) // ':' | '**' + (_tmp_264_var = _tmp_264_rule(p)) // ':' | '**' ) { - D(fprintf(stderr, "%*c+ _tmp_192[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_243_var); + D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); + _res = _PyPegen_dummy_name(p, _literal, _tmp_264_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_192[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); } _res = NULL; @@ -41016,14 +37576,9 @@ _tmp_192_rule(Parser *p) return _res; } -// _tmp_193: lambda_param_no_default | ',' +// _tmp_198: lambda_param_no_default | ',' static void * -_tmp_193_rule(Parser *p) -======= -// _loop1_193: lambda_param_maybe_default -static asdl_seq * -_loop1_193_rule(Parser *p) ->>>>>>> upstream/main +_tmp_198_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41033,76 +37588,55 @@ _loop1_193_rule(Parser *p) p->level--; return NULL; } - void *_res = NULL; + void * _res = NULL; int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // lambda_param_maybe_default + { // lambda_param_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop1_193[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); - NameDefaultPair* lambda_param_maybe_default_var; - while ( - (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + D(fprintf(stderr, "%*c> _tmp_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + arg_ty lambda_param_no_default_var; + if ( + (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - _res = lambda_param_maybe_default_var; - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; + D(fprintf(stderr, "%*c+ _tmp_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + _res = lambda_param_no_default_var; + goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop1_193[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_198[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; + { // ',' + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> _tmp_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + Token * _literal; + if ( + (_literal = _PyPegen_expect_token(p, 12)) // token=',' + ) + { + D(fprintf(stderr, "%*c+ _tmp_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + _res = _literal; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s _tmp_198[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); + _res = NULL; + done: p->level--; - return _seq; + return _res; } -<<<<<<< HEAD -// _loop0_194: lambda_param_maybe_default -static asdl_seq * -_loop0_194_rule(Parser *p) -======= -// _loop1_194: lambda_param_with_default +// _loop0_199: lambda_param_maybe_default static asdl_seq * -_loop1_194_rule(Parser *p) ->>>>>>> upstream/main +_loop0_199_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41123,32 +37657,18 @@ _loop1_194_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; -<<<<<<< HEAD { // lambda_param_maybe_default -======= - { // lambda_param_with_default ->>>>>>> upstream/main if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c> _loop0_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); NameDefaultPair* lambda_param_maybe_default_var; while ( (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default ) { _res = lambda_param_maybe_default_var; -======= - D(fprintf(stderr, "%*c> _loop1_194[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); - NameDefaultPair* lambda_param_with_default_var; - while ( - (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default - ) - { - _res = lambda_param_with_default_var; ->>>>>>> upstream/main if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -41165,8 +37685,7 @@ _loop1_194_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_194[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_199[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -41177,37 +37696,15 @@ _loop1_194_rule(Parser *p) p->level--; return NULL; } -======= - D(fprintf(stderr, "%*c%s _loop1_194[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); - } - if (_n == 0 || p->error_indicator) { - PyMem_Free(_children); - p->level--; - return NULL; - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } ->>>>>>> upstream/main for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); PyMem_Free(_children); p->level--; return _seq; } -<<<<<<< HEAD -// _tmp_195: lambda_param_no_default | ',' -======= -// _tmp_195: ':' | ',' (':' | '**') ->>>>>>> upstream/main +// _tmp_200: lambda_param_no_default | ',' static void * -_tmp_195_rule(Parser *p) +_tmp_200_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41219,24 +37716,23 @@ _tmp_195_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD { // lambda_param_no_default if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); arg_ty lambda_param_no_default_var; if ( (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default ) { - D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); + D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); _res = lambda_param_no_default_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); } { // ',' @@ -41244,18 +37740,18 @@ _tmp_195_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } _res = NULL; @@ -41264,9 +37760,9 @@ _tmp_195_rule(Parser *p) return _res; } -// _tmp_196: '*' | '**' | '/' +// _tmp_201: '*' | '**' | '/' static void * -_tmp_196_rule(Parser *p) +_tmp_201_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41283,18 +37779,18 @@ _tmp_196_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c> _tmp_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 16)) // token='*' ) { - D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); + D(fprintf(stderr, "%*c+ _tmp_201[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_201[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); } { // '**' @@ -41302,18 +37798,18 @@ _tmp_196_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_201[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_201[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } { // '/' @@ -41321,18 +37817,18 @@ _tmp_196_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c> _tmp_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 17)) // token='/' ) { - D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); + D(fprintf(stderr, "%*c+ _tmp_201[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_201[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); } _res = NULL; @@ -41341,9 +37837,9 @@ _tmp_196_rule(Parser *p) return _res; } -// _tmp_197: ',' | ')' | ':' +// _tmp_202: ',' | ')' | ':' static void * -_tmp_197_rule(Parser *p) +_tmp_202_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41360,18 +37856,18 @@ _tmp_197_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_202[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); } { // ')' @@ -41379,134 +37875,48 @@ _tmp_197_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_202[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } -======= ->>>>>>> upstream/main { // ':' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_197[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_197[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_202[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } - { // ',' (':' | '**') - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_195[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - Token * _literal; - void *_tmp_262_var; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (_tmp_262_var = _tmp_262_rule(p)) // ':' | '**' - ) - { - D(fprintf(stderr, "%*c+ _tmp_195[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); - _res = _PyPegen_dummy_name(p, _literal, _tmp_262_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_195[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _loop0_199: ',' (expression ['as' star_target]) -======= -// _tmp_196: lambda_param_no_default | ',' -static void * -_tmp_196_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - if ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - _res = lambda_param_no_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); - } - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_196[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_196[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_196[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } _res = NULL; done: p->level--; return _res; } -// _loop0_197: lambda_param_maybe_default ->>>>>>> upstream/main +// _loop0_204: ',' (expression ['as' star_target]) static asdl_seq * -_loop0_199_rule(Parser *p) +_loop0_204_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41527,27 +37937,27 @@ _loop0_199_rule(Parser *p) } Py_ssize_t _children_capacity = 1; Py_ssize_t _n = 0; - { // lambda_param_maybe_default + { // ',' (expression ['as' star_target]) if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_244_rule(p)) // expression ['as' star_target] -======= - D(fprintf(stderr, "%*c> _loop0_197[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); - NameDefaultPair* lambda_param_maybe_default_var; - while ( - (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default + (elem = _tmp_265_rule(p)) // expression ['as' star_target] ) { - _res = lambda_param_maybe_default_var; + _res = elem; + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + PyMem_Free(_children); + p->level--; + return NULL; + } if (_n == _children_capacity) { _children_capacity *= 2; void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); @@ -41564,8 +37974,8 @@ _loop0_199_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_197[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); + D(fprintf(stderr, "%*c%s _loop0_204[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); if (!_seq) { @@ -41581,79 +37991,9 @@ _loop0_199_rule(Parser *p) return _seq; } -// _tmp_198: lambda_param_no_default | ',' -static void * -_tmp_198_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // lambda_param_no_default - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - arg_ty lambda_param_no_default_var; - if ( - (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default - ) - { - D(fprintf(stderr, "%*c+ _tmp_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); - _res = lambda_param_no_default_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_198[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); - } - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' ->>>>>>> upstream/main - ) - { - D(fprintf(stderr, "%*c+ _tmp_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_199[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); -======= - D(fprintf(stderr, "%*c%s _tmp_198[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _gather_198: (expression ['as' star_target]) _loop0_199 +// _gather_203: (expression ['as' star_target]) _loop0_204 static asdl_seq * -_gather_198_rule(Parser *p) -======= -// _tmp_199: '*' | '**' | '/' -static void * -_tmp_199_rule(Parser *p) ->>>>>>> upstream/main +_gather_203_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41663,167 +38003,29 @@ _tmp_199_rule(Parser *p) p->level--; return NULL; } - void * _res = NULL; + asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // (expression ['as' star_target]) _loop0_199 -======= - { // '*' ->>>>>>> upstream/main + { // (expression ['as' star_target]) _loop0_204 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_198[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_199")); + D(fprintf(stderr, "%*c> _gather_203[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_204")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_244_rule(p)) // expression ['as' star_target] + (elem = _tmp_265_rule(p)) // expression ['as' star_target] && - (seq = _loop0_199_rule(p)) // _loop0_199 + (seq = _loop0_204_rule(p)) // _loop0_204 ) { - D(fprintf(stderr, "%*c+ _gather_198[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_199")); + D(fprintf(stderr, "%*c+ _gather_203[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_204")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_198[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_199")); -======= - D(fprintf(stderr, "%*c> _tmp_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 16)) // token='*' - ) - { - D(fprintf(stderr, "%*c+ _tmp_199[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_199[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); - } - { // '**' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' - ) - { - D(fprintf(stderr, "%*c+ _tmp_199[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_199[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); - } - { // '/' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_199[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 17)) // token='/' - ) - { - D(fprintf(stderr, "%*c+ _tmp_199[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_199[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/'")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _loop0_201: ',' (expressions ['as' star_target]) -======= -// _tmp_200: ',' | ')' | ':' -static void * -_tmp_200_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_200[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c%s _gather_203[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_204")); } _res = NULL; done: @@ -41831,10 +38033,9 @@ _tmp_200_rule(Parser *p) return _res; } -// _loop0_202: ',' (expression ['as' star_target]) ->>>>>>> upstream/main +// _loop0_206: ',' (expressions ['as' star_target]) static asdl_seq * -_loop0_202_rule(Parser *p) +_loop0_206_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -41860,302 +38061,13 @@ _loop0_202_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); -======= - D(fprintf(stderr, "%*c> _loop0_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && -<<<<<<< HEAD - (elem = _tmp_245_rule(p)) // expressions ['as' star_target] -======= - (elem = _tmp_263_rule(p)) // expression ['as' star_target] ->>>>>>> upstream/main - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_201[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); -======= - D(fprintf(stderr, "%*c%s _loop0_202[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); ->>>>>>> upstream/main - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -<<<<<<< HEAD -// _gather_200: (expressions ['as' star_target]) _loop0_201 -======= -// _gather_201: (expression ['as' star_target]) _loop0_202 ->>>>>>> upstream/main -static asdl_seq * -_gather_201_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; -<<<<<<< HEAD - { // (expressions ['as' star_target]) _loop0_201 -======= - { // (expression ['as' star_target]) _loop0_202 ->>>>>>> upstream/main - if (p->error_indicator) { - p->level--; - return NULL; - } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_200[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_201")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_245_rule(p)) // expressions ['as' star_target] -======= - D(fprintf(stderr, "%*c> _gather_201[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_202")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_263_rule(p)) // expression ['as' star_target] ->>>>>>> upstream/main - && - (seq = _loop0_202_rule(p)) // _loop0_202 - ) - { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _gather_200[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_201")); -======= - D(fprintf(stderr, "%*c+ _gather_201[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_202")); ->>>>>>> upstream/main - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_200[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_201")); -======= - D(fprintf(stderr, "%*c%s _gather_201[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_202")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _loop0_203: ',' (expression ['as' star_target]) -======= -// _loop0_204: ',' (expressions ['as' star_target]) ->>>>>>> upstream/main -static asdl_seq * -_loop0_204_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' (expression ['as' star_target]) - if (p->error_indicator) { - p->level--; - return NULL; - } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_203[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); -======= - D(fprintf(stderr, "%*c> _loop0_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); ->>>>>>> upstream/main - Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && -<<<<<<< HEAD - (elem = _tmp_246_rule(p)) // expression ['as' star_target] -======= - (elem = _tmp_264_rule(p)) // expressions ['as' star_target] ->>>>>>> upstream/main - ) - { - _res = elem; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - PyMem_Free(_children); - p->level--; - return NULL; - } - if (_n == _children_capacity) { - _children_capacity *= 2; - void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); - if (!_new_children) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - _children = _new_children; - } - _children[_n++] = _res; - _mark = p->mark; - } - p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_203[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); - } - asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); - if (!_seq) { - PyMem_Free(_children); - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); - PyMem_Free(_children); - p->level--; - return _seq; -} - -// _gather_202: (expression ['as' star_target]) _loop0_203 -static asdl_seq * -_gather_202_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - asdl_seq * _res = NULL; - int _mark = p->mark; - { // (expression ['as' star_target]) _loop0_203 - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _gather_202[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_203")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_246_rule(p)) // expression ['as' star_target] - && - (seq = _loop0_203_rule(p)) // _loop0_203 - ) - { - D(fprintf(stderr, "%*c+ _gather_202[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_203")); - _res = _PyPegen_seq_insert_in_front(p, elem, seq); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_202[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_203")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _loop0_205: ',' (expressions ['as' star_target]) -static asdl_seq * -_loop0_205_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void *_res = NULL; - int _mark = p->mark; - void **_children = PyMem_Malloc(sizeof(void *)); - if (!_children) { - p->error_indicator = 1; - PyErr_NoMemory(); - p->level--; - return NULL; - } - Py_ssize_t _children_capacity = 1; - Py_ssize_t _n = 0; - { // ',' (expressions ['as' star_target]) - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _loop0_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); - Token * _literal; - void *elem; - while ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (elem = _tmp_247_rule(p)) // expressions ['as' star_target] + (elem = _tmp_266_rule(p)) // expressions ['as' star_target] ) { _res = elem; @@ -42181,10 +38093,7 @@ _loop0_205_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_205[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_204[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_206[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -42201,15 +38110,9 @@ _loop0_205_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_204: (expressions ['as' star_target]) _loop0_205 -static asdl_seq * -_gather_204_rule(Parser *p) -======= -// _gather_203: (expressions ['as' star_target]) _loop0_204 +// _gather_205: (expressions ['as' star_target]) _loop0_206 static asdl_seq * -_gather_203_rule(Parser *p) ->>>>>>> upstream/main +_gather_205_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42221,49 +38124,27 @@ _gather_203_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // (expressions ['as' star_target]) _loop0_205 -======= - { // (expressions ['as' star_target]) _loop0_204 ->>>>>>> upstream/main + { // (expressions ['as' star_target]) _loop0_206 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_204[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_205")); - void *elem; - asdl_seq * seq; - if ( - (elem = _tmp_247_rule(p)) // expressions ['as' star_target] - && - (seq = _loop0_205_rule(p)) // _loop0_205 - ) - { - D(fprintf(stderr, "%*c+ _gather_204[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_205")); -======= - D(fprintf(stderr, "%*c> _gather_203[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_204")); + D(fprintf(stderr, "%*c> _gather_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_206")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_264_rule(p)) // expressions ['as' star_target] + (elem = _tmp_266_rule(p)) // expressions ['as' star_target] && - (seq = _loop0_204_rule(p)) // _loop0_204 + (seq = _loop0_206_rule(p)) // _loop0_206 ) { - D(fprintf(stderr, "%*c+ _gather_203[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_204")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_205[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_206")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_204[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_205")); -======= - D(fprintf(stderr, "%*c%s _gather_203[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_204")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _gather_205[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_206")); } _res = NULL; done: @@ -42271,14 +38152,9 @@ _gather_203_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_206: 'except' | 'finally' -static void * -_tmp_206_rule(Parser *p) -======= -// _loop0_206: ',' (expression ['as' star_target]) +// _loop0_208: ',' (expression ['as' star_target]) static asdl_seq * -_loop0_206_rule(Parser *p) +_loop0_208_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42304,13 +38180,13 @@ _loop0_206_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_208[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_265_rule(p)) // expression ['as' star_target] + (elem = _tmp_267_rule(p)) // expression ['as' star_target] ) { _res = elem; @@ -42336,7 +38212,7 @@ _loop0_206_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_206[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_208[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -42353,9 +38229,9 @@ _loop0_206_rule(Parser *p) return _seq; } -// _gather_205: (expression ['as' star_target]) _loop0_206 +// _gather_207: (expression ['as' star_target]) _loop0_208 static asdl_seq * -_gather_205_rule(Parser *p) +_gather_207_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42367,27 +38243,27 @@ _gather_205_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expression ['as' star_target]) _loop0_206 + { // (expression ['as' star_target]) _loop0_208 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_205[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_206")); + D(fprintf(stderr, "%*c> _gather_207[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_208")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_265_rule(p)) // expression ['as' star_target] + (elem = _tmp_267_rule(p)) // expression ['as' star_target] && - (seq = _loop0_206_rule(p)) // _loop0_206 + (seq = _loop0_208_rule(p)) // _loop0_208 ) { - D(fprintf(stderr, "%*c+ _gather_205[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_206")); + D(fprintf(stderr, "%*c+ _gather_207[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_208")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_205[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_206")); + D(fprintf(stderr, "%*c%s _gather_207[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_208")); } _res = NULL; done: @@ -42395,9 +38271,9 @@ _gather_205_rule(Parser *p) return _res; } -// _loop0_208: ',' (expressions ['as' star_target]) +// _loop0_210: ',' (expressions ['as' star_target]) static asdl_seq * -_loop0_208_rule(Parser *p) +_loop0_210_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42423,13 +38299,13 @@ _loop0_208_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_208[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); + D(fprintf(stderr, "%*c> _loop0_210[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); Token * _literal; void *elem; while ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' && - (elem = _tmp_266_rule(p)) // expressions ['as' star_target] + (elem = _tmp_268_rule(p)) // expressions ['as' star_target] ) { _res = elem; @@ -42455,7 +38331,7 @@ _loop0_208_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_208[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_210[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -42472,9 +38348,9 @@ _loop0_208_rule(Parser *p) return _seq; } -// _gather_207: (expressions ['as' star_target]) _loop0_208 +// _gather_209: (expressions ['as' star_target]) _loop0_210 static asdl_seq * -_gather_207_rule(Parser *p) +_gather_209_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42486,27 +38362,27 @@ _gather_207_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; - { // (expressions ['as' star_target]) _loop0_208 + { // (expressions ['as' star_target]) _loop0_210 if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _gather_207[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_208")); + D(fprintf(stderr, "%*c> _gather_209[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_210")); void *elem; asdl_seq * seq; if ( - (elem = _tmp_266_rule(p)) // expressions ['as' star_target] + (elem = _tmp_268_rule(p)) // expressions ['as' star_target] && - (seq = _loop0_208_rule(p)) // _loop0_208 + (seq = _loop0_210_rule(p)) // _loop0_210 ) { - D(fprintf(stderr, "%*c+ _gather_207[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_208")); + D(fprintf(stderr, "%*c+ _gather_209[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_210")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _gather_207[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_208")); + D(fprintf(stderr, "%*c%s _gather_209[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_210")); } _res = NULL; done: @@ -42514,10 +38390,9 @@ _gather_207_rule(Parser *p) return _res; } -// _tmp_209: 'except' | 'finally' +// _tmp_211: 'except' | 'finally' static void * -_tmp_209_rule(Parser *p) ->>>>>>> upstream/main +_tmp_211_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42534,30 +38409,18 @@ _tmp_209_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); -======= - D(fprintf(stderr, "%*c> _tmp_209[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_211[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 637)) // token='except' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_206[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); -======= - D(fprintf(stderr, "%*c+ _tmp_209[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_211[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); _res = _keyword; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_206[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_209[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_211[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except'")); } { // 'finally' @@ -42565,30 +38428,18 @@ _tmp_209_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_206[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); -======= - D(fprintf(stderr, "%*c> _tmp_209[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_211[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); Token * _keyword; if ( (_keyword = _PyPegen_expect_token(p, 633)) // token='finally' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_206[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); -======= - D(fprintf(stderr, "%*c+ _tmp_209[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_211[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); _res = _keyword; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_206[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_209[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_211[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally'")); } _res = NULL; @@ -42597,15 +38448,9 @@ _tmp_209_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_207: block +// _loop0_212: block static asdl_seq * -_loop0_207_rule(Parser *p) -======= -// _loop0_210: block -static asdl_seq * -_loop0_210_rule(Parser *p) ->>>>>>> upstream/main +_loop0_212_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42631,11 +38476,7 @@ _loop0_210_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_207[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); -======= - D(fprintf(stderr, "%*c> _loop0_210[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_212[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); asdl_stmt_seq* block_var; while ( (block_var = block_rule(p)) // block @@ -42658,11 +38499,7 @@ _loop0_210_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_207[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_210[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_212[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "block")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -42679,15 +38516,9 @@ _loop0_210_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_208: except_block -static asdl_seq * -_loop1_208_rule(Parser *p) -======= -// _loop1_211: except_block +// _loop1_213: except_block static asdl_seq * -_loop1_211_rule(Parser *p) ->>>>>>> upstream/main +_loop1_213_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42713,11 +38544,7 @@ _loop1_211_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_208[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); -======= - D(fprintf(stderr, "%*c> _loop1_211[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop1_213[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); excepthandler_ty except_block_var; while ( (except_block_var = except_block_rule(p)) // except_block @@ -42740,11 +38567,7 @@ _loop1_211_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_208[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_211[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_213[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); } if (_n == 0 || p->error_indicator) { @@ -42766,15 +38589,9 @@ _loop1_211_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_209: 'as' NAME +// _tmp_214: 'as' NAME static void * -_tmp_209_rule(Parser *p) -======= -// _tmp_212: 'as' NAME -static void * -_tmp_212_rule(Parser *p) ->>>>>>> upstream/main +_tmp_214_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42791,37 +38608,21 @@ _tmp_212_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_209[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty name_var; - if ( - (_keyword = _PyPegen_expect_token(p, 639)) // token='as' -======= - D(fprintf(stderr, "%*c> _tmp_212[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_214[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( (_keyword = _PyPegen_expect_token(p, 640)) // token='as' ->>>>>>> upstream/main && (name_var = _PyPegen_name_token(p)) // NAME ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_209[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); -======= - D(fprintf(stderr, "%*c+ _tmp_212[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_214[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_209[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_212[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_214[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -42830,15 +38631,9 @@ _tmp_212_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_210: block -static asdl_seq * -_loop0_210_rule(Parser *p) -======= -// _loop0_213: block +// _loop0_215: block static asdl_seq * -_loop0_213_rule(Parser *p) ->>>>>>> upstream/main +_loop0_215_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42864,11 +38659,7 @@ _loop0_213_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_210[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); -======= - D(fprintf(stderr, "%*c> _loop0_213[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "block")); asdl_stmt_seq* block_var; while ( (block_var = block_rule(p)) // block @@ -42891,11 +38682,7 @@ _loop0_213_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_210[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_213[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_215[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "block")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -42912,15 +38699,9 @@ _loop0_213_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _loop1_211: except_star_block -static asdl_seq * -_loop1_211_rule(Parser *p) -======= -// _loop1_214: except_star_block +// _loop1_216: except_star_block static asdl_seq * -_loop1_214_rule(Parser *p) ->>>>>>> upstream/main +_loop1_216_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -42946,11 +38727,7 @@ _loop1_214_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop1_211[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); -======= - D(fprintf(stderr, "%*c> _loop1_214[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop1_216[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_star_block")); excepthandler_ty except_star_block_var; while ( (except_star_block_var = except_star_block_rule(p)) // except_star_block @@ -42973,11 +38750,7 @@ _loop1_214_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop1_211[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop1_214[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop1_216[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_star_block")); } if (_n == 0 || p->error_indicator) { @@ -42999,56 +38772,9 @@ _loop1_214_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _tmp_212: expression ['as' NAME] -static void * -_tmp_212_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // expression ['as' NAME] - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_212[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_248_rule(p), !p->error_indicator) // ['as' NAME] - ) - { - D(fprintf(stderr, "%*c+ _tmp_212[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); - _res = _PyPegen_dummy_name(p, expression_var, _opt_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_212[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' NAME]")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_213: 'as' NAME -======= -// _tmp_215: expression ['as' NAME] ->>>>>>> upstream/main +// _tmp_217: expression ['as' NAME] static void * -_tmp_215_rule(Parser *p) +_tmp_217_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43065,107 +38791,23 @@ _tmp_215_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); + D(fprintf(stderr, "%*c> _tmp_217[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_267_rule(p), !p->error_indicator) // ['as' NAME] + (_opt_var = _tmp_269_rule(p), !p->error_indicator) // ['as' NAME] ) { - D(fprintf(stderr, "%*c+ _tmp_215[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); + D(fprintf(stderr, "%*c+ _tmp_217[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' NAME]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_215[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' NAME]")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_216: 'as' NAME -static void * -_tmp_216_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' NAME - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_216[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty name_var; - if ( - (_keyword = _PyPegen_expect_token(p, 640)) // token='as' - && - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ _tmp_216[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = _PyPegen_dummy_name(p, _keyword, name_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_216[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_217: 'as' NAME -static void * -_tmp_217_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' NAME - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_217[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - Token * _keyword; - expr_ty name_var; - if ( - (_keyword = _PyPegen_expect_token(p, 640)) // token='as' - && - (name_var = _PyPegen_name_token(p)) // NAME - ) - { - D(fprintf(stderr, "%*c+ _tmp_217[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); - _res = _PyPegen_dummy_name(p, _keyword, name_var); - goto done; - } - p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_217[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' NAME]")); } _res = NULL; done: @@ -43173,7 +38815,7 @@ _tmp_217_rule(Parser *p) return _res; } -// _tmp_218: NEWLINE | ':' +// _tmp_218: 'as' NAME static void * _tmp_218_rule(Parser *p) { @@ -43192,56 +38834,22 @@ _tmp_218_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_213[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_218[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; -======= - D(fprintf(stderr, "%*c> _tmp_218[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - Token * newline_var; ->>>>>>> upstream/main if ( - (_keyword = _PyPegen_expect_token(p, 639)) // token='as' + (_keyword = _PyPegen_expect_token(p, 640)) // token='as' && (name_var = _PyPegen_name_token(p)) // NAME ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_213[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_218[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_213[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); -======= - D(fprintf(stderr, "%*c+ _tmp_218[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); - _res = newline_var; - goto done; - } - p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_218[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); - } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_218[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_218[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_218[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); ->>>>>>> upstream/main + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; done: @@ -43291,11 +38899,7 @@ _tmp_219_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_215: NEWLINE | ':' -======= -// _tmp_220: 'as' NAME ->>>>>>> upstream/main +// _tmp_220: NEWLINE | ':' static void * _tmp_220_rule(Parser *p) { @@ -43314,18 +38918,18 @@ _tmp_220_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_220[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); Token * newline_var; if ( (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_215[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_220[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); _res = newline_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_215[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_220[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); } { // ':' @@ -43333,18 +38937,18 @@ _tmp_220_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_215[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_220[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_215[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_220[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_215[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_220[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } _res = NULL; @@ -43353,9 +38957,9 @@ _tmp_220_rule(Parser *p) return _res; } -// _tmp_216: 'as' NAME +// _tmp_221: 'as' NAME static void * -_tmp_216_rule(Parser *p) +_tmp_221_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43372,11 +38976,7 @@ _tmp_216_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_216[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); -======= - D(fprintf(stderr, "%*c> _tmp_220[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_221[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -43385,20 +38985,12 @@ _tmp_216_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_216[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); -======= - D(fprintf(stderr, "%*c+ _tmp_220[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_221[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_216[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_220[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_221[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -43407,10 +38999,9 @@ _tmp_216_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_217: 'as' NAME +// _tmp_222: 'as' NAME static void * -_tmp_217_rule(Parser *p) +_tmp_222_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43427,21 +39018,21 @@ _tmp_217_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_217[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c> _tmp_222[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( - (_keyword = _PyPegen_expect_token(p, 639)) // token='as' + (_keyword = _PyPegen_expect_token(p, 640)) // token='as' && (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_217[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); + D(fprintf(stderr, "%*c+ _tmp_222[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_217[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_222[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -43450,14 +39041,9 @@ _tmp_217_rule(Parser *p) return _res; } -// _tmp_218: positional_patterns ',' -static void * -_tmp_218_rule(Parser *p) -======= -// _tmp_221: positional_patterns ',' +// _tmp_223: positional_patterns ',' static void * -_tmp_221_rule(Parser *p) ->>>>>>> upstream/main +_tmp_223_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43474,11 +39060,7 @@ _tmp_221_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_218[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); -======= - D(fprintf(stderr, "%*c> _tmp_221[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_223[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); Token * _literal; asdl_pattern_seq* positional_patterns_var; if ( @@ -43487,20 +39069,12 @@ _tmp_221_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_218[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); -======= - D(fprintf(stderr, "%*c+ _tmp_221[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_223[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "positional_patterns ','")); _res = _PyPegen_dummy_name(p, positional_patterns_var, _literal); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_218[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_221[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_223[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "positional_patterns ','")); } _res = NULL; @@ -43509,15 +39083,9 @@ _tmp_221_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_219: '->' expression +// _tmp_224: '->' expression static void * -_tmp_219_rule(Parser *p) -======= -// _tmp_222: '->' expression -static void * -_tmp_222_rule(Parser *p) ->>>>>>> upstream/main +_tmp_224_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43534,11 +39102,7 @@ _tmp_222_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_219[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); -======= - D(fprintf(stderr, "%*c> _tmp_222[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); Token * _literal; expr_ty expression_var; if ( @@ -43547,20 +39111,12 @@ _tmp_222_rule(Parser *p) (expression_var = expression_rule(p)) // expression ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_219[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); -======= - D(fprintf(stderr, "%*c+ _tmp_222[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); _res = _PyPegen_dummy_name(p, _literal, expression_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_219[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_222[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); } _res = NULL; @@ -43569,15 +39125,9 @@ _tmp_222_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_220: '(' arguments? ')' -static void * -_tmp_220_rule(Parser *p) -======= -// _tmp_223: '(' arguments? ')' +// _tmp_225: '(' arguments? ')' static void * -_tmp_223_rule(Parser *p) ->>>>>>> upstream/main +_tmp_225_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43594,11 +39144,7 @@ _tmp_223_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_220[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); -======= - D(fprintf(stderr, "%*c> _tmp_223[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -43611,20 +39157,12 @@ _tmp_223_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_220[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); -======= - D(fprintf(stderr, "%*c+ _tmp_223[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = _PyPegen_dummy_name(p, _literal, _opt_var, _literal_1); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_220[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_223[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -43633,15 +39171,9 @@ _tmp_223_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_221: '(' arguments? ')' -static void * -_tmp_221_rule(Parser *p) -======= -// _tmp_224: '(' arguments? ')' +// _tmp_226: '(' arguments? ')' static void * -_tmp_224_rule(Parser *p) ->>>>>>> upstream/main +_tmp_226_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43658,11 +39190,7 @@ _tmp_224_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_221[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); -======= - D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_226[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); Token * _literal; Token * _literal_1; void *_opt_var; @@ -43675,20 +39203,12 @@ _tmp_224_rule(Parser *p) (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_221[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); -======= - D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_226[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); _res = _PyPegen_dummy_name(p, _literal, _opt_var, _literal_1); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_221[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_226[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); } _res = NULL; @@ -43697,15 +39217,9 @@ _tmp_224_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _loop0_223: ',' double_starred_kvpair +// _loop0_228: ',' double_starred_kvpair static asdl_seq * -_loop0_223_rule(Parser *p) -======= -// _loop0_226: ',' double_starred_kvpair -static asdl_seq * -_loop0_226_rule(Parser *p) ->>>>>>> upstream/main +_loop0_228_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43731,11 +39245,7 @@ _loop0_226_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _loop0_223[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); -======= - D(fprintf(stderr, "%*c> _loop0_226[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _loop0_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); Token * _literal; KeyValuePair* elem; while ( @@ -43767,11 +39277,7 @@ _loop0_226_rule(Parser *p) _mark = p->mark; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _loop0_223[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _loop0_226[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _loop0_228[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -43788,15 +39294,9 @@ _loop0_226_rule(Parser *p) return _seq; } -<<<<<<< HEAD -// _gather_222: double_starred_kvpair _loop0_223 -static asdl_seq * -_gather_222_rule(Parser *p) -======= -// _gather_225: double_starred_kvpair _loop0_226 +// _gather_227: double_starred_kvpair _loop0_228 static asdl_seq * -_gather_225_rule(Parser *p) ->>>>>>> upstream/main +_gather_227_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -43808,211 +39308,27 @@ _gather_225_rule(Parser *p) } asdl_seq * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // double_starred_kvpair _loop0_223 -======= - { // double_starred_kvpair _loop0_226 ->>>>>>> upstream/main + { // double_starred_kvpair _loop0_228 if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _gather_222[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_223")); -======= - D(fprintf(stderr, "%*c> _gather_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_226")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _gather_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_228")); KeyValuePair* elem; asdl_seq * seq; if ( (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair && -<<<<<<< HEAD - (seq = _loop0_223_rule(p)) // _loop0_223 + (seq = _loop0_228_rule(p)) // _loop0_228 ) { - D(fprintf(stderr, "%*c+ _gather_222[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_223")); -======= - (seq = _loop0_226_rule(p)) // _loop0_226 - ) - { - D(fprintf(stderr, "%*c+ _gather_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_226")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _gather_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_228")); _res = _PyPegen_seq_insert_in_front(p, elem, seq); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _gather_222[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_223")); -======= - D(fprintf(stderr, "%*c%s _gather_225[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_226")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _tmp_224: '}' | ',' -static void * -_tmp_224_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); - } - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_224[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_224[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_224[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_225: '}' | ',' -static void * -_tmp_225_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); - } - { // ',' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_225[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - ) - { - D(fprintf(stderr, "%*c+ _tmp_225[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_225[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_226: star_targets '=' -static void * -_tmp_226_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // star_targets '=' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_226[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - Token * _literal; - expr_ty z; - if ( - (z = star_targets_rule(p)) // star_targets - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_226[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_226[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c%s _gather_227[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_228")); } _res = NULL; done: @@ -44020,127 +39336,7 @@ _tmp_226_rule(Parser *p) return _res; } -// _tmp_227: '.' | '...' -======= -// _tmp_227: '}' | ',' ->>>>>>> upstream/main -static void * -_tmp_227_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; -<<<<<<< HEAD - { // '.' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - ) - { - D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); - } - { // '...' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 52)) // token='...' - ) - { - D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_228: '.' | '...' -static void * -_tmp_228_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // '.' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 23)) // token='.' - ) - { - D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); - } - { // '...' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 52)) // token='...' - ) - { - D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_229: '@' named_expression NEWLINE +// _tmp_229: '}' | ',' static void * _tmp_229_rule(Parser *p) { @@ -44154,44 +39350,23 @@ _tmp_229_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // '@' named_expression NEWLINE -======= { // '}' ->>>>>>> upstream/main if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); -======= - D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); - _res = f; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); -======= - D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); } { // ',' @@ -44199,20 +39374,19 @@ _tmp_229_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_227[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_227[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_227[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); ->>>>>>> upstream/main } _res = NULL; done: @@ -44220,11 +39394,7 @@ _tmp_229_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_230: ',' expression -======= -// _tmp_228: '}' | ',' ->>>>>>> upstream/main +// _tmp_230: '}' | ',' static void * _tmp_230_rule(Parser *p) { @@ -44243,36 +39413,18 @@ _tmp_230_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); -======= - D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); -======= - D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); } { // ',' @@ -44280,20 +39432,19 @@ _tmp_230_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_228[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 12)) // token=',' ) { - D(fprintf(stderr, "%*c+ _tmp_228[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); + D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_228[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); ->>>>>>> upstream/main } _res = NULL; done: @@ -44301,11 +39452,7 @@ _tmp_230_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_231: ',' star_expression -======= -// _tmp_229: yield_expr | star_expressions ->>>>>>> upstream/main +// _tmp_231: yield_expr | star_expressions static void * _tmp_231_rule(Parser *p) { @@ -44324,38 +39471,18 @@ _tmp_231_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); - Token * _literal; - expr_ty c; -======= - D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; ->>>>>>> upstream/main if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); -======= - D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -44363,20 +39490,19 @@ _tmp_231_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_229[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_229[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_229[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); ->>>>>>> upstream/main } _res = NULL; done: @@ -44384,11 +39510,7 @@ _tmp_231_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_232: 'or' conjunction -======= -// _tmp_230: yield_expr | star_expressions ->>>>>>> upstream/main +// _tmp_232: yield_expr | star_expressions static void * _tmp_232_rule(Parser *p) { @@ -44407,38 +39529,18 @@ _tmp_232_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); - Token * _keyword; - expr_ty c; -======= - D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; ->>>>>>> upstream/main if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); -======= - D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -44446,20 +39548,19 @@ _tmp_232_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_230[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_230[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_230[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); ->>>>>>> upstream/main } _res = NULL; done: @@ -44467,11 +39568,7 @@ _tmp_232_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_233: 'and' inversion -======= -// _tmp_231: '=' | '!' | ':' | '}' ->>>>>>> upstream/main +// _tmp_233: '=' | '!' | ':' | '}' static void * _tmp_233_rule(Parser *p) { @@ -44490,213 +39587,20 @@ _tmp_233_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_233[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); - Token * _keyword; - expr_ty c; -======= - D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c> _tmp_233[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); Token * _literal; ->>>>>>> upstream/main if ( (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_233[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_233[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); -======= - D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); + D(fprintf(stderr, "%*c+ _tmp_233[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_233[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); } - { // '!' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' - ) - { - D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!'")); - } - { // ':' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 11)) // token=':' - ) - { - D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); - } - { // '}' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_231[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 26)) // token='}' - ) - { - D(fprintf(stderr, "%*c+ _tmp_231[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_231[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _tmp_234: slice | starred_expression -======= -// _tmp_232: yield_expr | star_expressions ->>>>>>> upstream/main -static void * -_tmp_234_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // yield_expr - if (p->error_indicator) { - p->level--; - return NULL; - } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_234[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); - expr_ty slice_var; -======= - D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; ->>>>>>> upstream/main - if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr - ) - { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_234[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); - _res = slice_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_234[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice")); -======= - D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); ->>>>>>> upstream/main - } - { // star_expressions - if (p->error_indicator) { - p->level--; - return NULL; - } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_234[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); - expr_ty starred_expression_var; -======= - D(fprintf(stderr, "%*c> _tmp_232[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; ->>>>>>> upstream/main - if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions - ) - { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_234[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); - _res = starred_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_234[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); -======= - D(fprintf(stderr, "%*c+ _tmp_232[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_232[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _tmp_235: 'if' disjunction -======= -// _tmp_233: '!' | ':' | '}' -static void * -_tmp_233_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; { // '!' if (p->error_indicator) { p->level--; @@ -44818,8 +39722,7 @@ _tmp_234_rule(Parser *p) return _res; } -// _tmp_235: yield_expr | star_expressions ->>>>>>> upstream/main +// _tmp_235: '!' | ':' | '}' static void * _tmp_235_rule(Parser *p) { @@ -44833,143 +39736,62 @@ _tmp_235_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // 'if' disjunction -======= - { // yield_expr ->>>>>>> upstream/main + { // '!' if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 641)) // token='if' - && - (z = disjunction_rule(p)) // disjunction - ) - { - D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } -======= - D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); - expr_ty yield_expr_var; + D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!'")); + Token * _literal; if ( - (yield_expr_var = yield_expr_rule(p)) // yield_expr + (_literal = _PyPegen_expect_token(p, 54)) // token='!' ) { - D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); - _res = yield_expr_var; + D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!'")); + _res = _literal; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_235[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!'")); } - { // star_expressions + { // ':' if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); - expr_ty star_expressions_var; + D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + Token * _literal; if ( - (star_expressions_var = star_expressions_rule(p)) // star_expressions + (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); - _res = star_expressions_var; ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + _res = _literal; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_235[%d-%d]: %s failed!\n", p->level, ' ', -<<<<<<< HEAD - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); -======= - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); ->>>>>>> upstream/main - } - _res = NULL; - done: - p->level--; - return _res; -} - -<<<<<<< HEAD -// _tmp_236: 'if' disjunction -======= -// _tmp_236: '!' NAME ->>>>>>> upstream/main -static void * -_tmp_236_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } - void * _res = NULL; - int _mark = p->mark; -<<<<<<< HEAD - { // 'if' disjunction -======= - { // '!' NAME ->>>>>>> upstream/main + { // '}' if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_236[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); - Token * _keyword; - expr_ty z; - if ( - (_keyword = _PyPegen_expect_token(p, 641)) // token='if' - && - (z = disjunction_rule(p)) // disjunction - ) - { - D(fprintf(stderr, "%*c+ _tmp_236[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); - _res = z; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } -======= - D(fprintf(stderr, "%*c> _tmp_236[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c> _tmp_235[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; - expr_ty name_var; if ( - (_literal = _PyPegen_expect_token(p, 54)) // token='!' - && - (name_var = _PyPegen_name_token(p)) // NAME + (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ _tmp_236[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); - _res = _PyPegen_dummy_name(p, _literal, name_var); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_235[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_236[%d-%d]: %s failed!\n", p->level, ' ', -<<<<<<< HEAD - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); -======= - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' NAME")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_235[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); } _res = NULL; done: @@ -44977,13 +39799,9 @@ _tmp_236_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_237: starred_expression | (assignment_expression | expression !':=') !'=' -======= -// _tmp_237: ':' | '}' ->>>>>>> upstream/main +// _tmp_236: yield_expr | star_expressions static void * -_tmp_237_rule(Parser *p) +_tmp_236_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -44995,93 +39813,43 @@ _tmp_237_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; -<<<<<<< HEAD - { // starred_expression - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); - expr_ty starred_expression_var; - if ( - (starred_expression_var = starred_expression_rule(p)) // starred_expression - ) - { - D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); - _res = starred_expression_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); - } - { // (assignment_expression | expression !':=') !'=' + { // yield_expr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - void *_tmp_249_var; + D(fprintf(stderr, "%*c> _tmp_236[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; if ( - (_tmp_249_var = _tmp_249_rule(p)) // assignment_expression | expression !':=' - && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' + (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - _res = _tmp_249_var; + D(fprintf(stderr, "%*c+ _tmp_236[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_238: ',' star_target -static void * -_tmp_238_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_236[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - void * _res = NULL; - int _mark = p->mark; - { // ',' star_target + { // star_expressions if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_238[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); - Token * _literal; - expr_ty c; + D(fprintf(stderr, "%*c> _tmp_236[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (c = star_target_rule(p)) // star_target + (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_238[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_236[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_238[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c%s _tmp_236[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; done: @@ -45089,9 +39857,9 @@ _tmp_238_rule(Parser *p) return _res; } -// _tmp_239: ',' star_target +// _tmp_237: yield_expr | star_expressions static void * -_tmp_239_rule(Parser *p) +_tmp_237_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45103,74 +39871,43 @@ _tmp_239_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // ',' star_target + { // yield_expr if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_239[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); - Token * _literal; - expr_ty c; + D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + expr_ty yield_expr_var; if ( - (_literal = _PyPegen_expect_token(p, 12)) // token=',' - && - (c = star_target_rule(p)) // star_target + (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_239[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); - _res = c; - if (_res == NULL && PyErr_Occurred()) { - p->error_indicator = 1; - p->level--; - return NULL; - } + D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_239[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_240: star_targets '=' -static void * -_tmp_240_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; + D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } - void * _res = NULL; - int _mark = p->mark; - { // star_targets '=' + { // star_expressions if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - Token * _literal; - expr_ty star_targets_var; + D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + expr_ty star_expressions_var; if ( - (star_targets_var = star_targets_rule(p)) // star_targets - && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' + (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_240[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - _res = _PyPegen_dummy_name(p, star_targets_var, _literal); + D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_240[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; done: @@ -45178,9 +39915,9 @@ _tmp_240_rule(Parser *p) return _res; } -// _tmp_241: star_targets '=' +// _tmp_238: '!' NAME static void * -_tmp_241_rule(Parser *p) +_tmp_238_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45192,85 +39929,27 @@ _tmp_241_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; - { // star_targets '=' + { // '!' NAME if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_238[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); Token * _literal; - expr_ty star_targets_var; + expr_ty name_var; if ( - (star_targets_var = star_targets_rule(p)) // star_targets + (_literal = _PyPegen_expect_token(p, 54)) // token='!' && - (_literal = _PyPegen_expect_token(p, 22)) // token='=' - ) - { - D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); - _res = _PyPegen_dummy_name(p, star_targets_var, _literal); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_242: ')' | '**' -static void * -_tmp_242_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // ')' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 8)) // token=')' - ) - { - D(fprintf(stderr, "%*c+ _tmp_242[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); - _res = _literal; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_242[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); - } - { // '**' - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); - Token * _literal; - if ( - (_literal = _PyPegen_expect_token(p, 35)) // token='**' + (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_242[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); - _res = _literal; + D(fprintf(stderr, "%*c+ _tmp_238[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + _res = _PyPegen_dummy_name(p, _literal, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_242[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c%s _tmp_238[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' NAME")); } _res = NULL; done: @@ -45278,9 +39957,9 @@ _tmp_242_rule(Parser *p) return _res; } -// _tmp_243: ':' | '**' +// _tmp_239: ':' | '}' static void * -_tmp_243_rule(Parser *p) +_tmp_239_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45292,37 +39971,23 @@ _tmp_243_rule(Parser *p) } void * _res = NULL; int _mark = p->mark; -======= ->>>>>>> upstream/main { // ':' if (p->error_indicator) { p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); -======= - D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_239[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); -======= - D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_239[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_239[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '}' @@ -45330,30 +39995,18 @@ _tmp_243_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); -======= - D(fprintf(stderr, "%*c> _tmp_237[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_239[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); -======= - D(fprintf(stderr, "%*c+ _tmp_237[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_239[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); _res = _literal; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); -======= - D(fprintf(stderr, "%*c%s _tmp_237[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_239[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); } _res = NULL; @@ -45362,9 +40015,9 @@ _tmp_243_rule(Parser *p) return _res; } -// _tmp_238: yield_expr | star_expressions +// _tmp_240: yield_expr | star_expressions static void * -_tmp_238_rule(Parser *p) +_tmp_240_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45381,18 +40034,18 @@ _tmp_238_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_238[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_238[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_240[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_238[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_240[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -45400,18 +40053,18 @@ _tmp_238_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_238[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_238[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_240[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_238[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_240[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -45420,9 +40073,9 @@ _tmp_238_rule(Parser *p) return _res; } -// _tmp_239: '!' NAME +// _tmp_241: '!' NAME static void * -_tmp_239_rule(Parser *p) +_tmp_241_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45439,7 +40092,7 @@ _tmp_239_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_239[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); Token * _literal; expr_ty name_var; if ( @@ -45448,12 +40101,12 @@ _tmp_239_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_239[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); _res = _PyPegen_dummy_name(p, _literal, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_239[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' NAME")); } _res = NULL; @@ -45462,9 +40115,9 @@ _tmp_239_rule(Parser *p) return _res; } -// _loop0_240: fstring_format_spec +// _loop0_242: fstring_format_spec static asdl_seq * -_loop0_240_rule(Parser *p) +_loop0_242_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45490,7 +40143,7 @@ _loop0_240_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _loop0_240[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); + D(fprintf(stderr, "%*c> _loop0_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring_format_spec")); expr_ty fstring_format_spec_var; while ( (fstring_format_spec_var = fstring_format_spec_rule(p)) // fstring_format_spec @@ -45513,7 +40166,7 @@ _loop0_240_rule(Parser *p) _mark = p->mark; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _loop0_240[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _loop0_242[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring_format_spec")); } asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); @@ -45530,9 +40183,9 @@ _loop0_240_rule(Parser *p) return _seq; } -// _tmp_241: yield_expr | star_expressions +// _tmp_243: yield_expr | star_expressions static void * -_tmp_241_rule(Parser *p) +_tmp_243_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45549,18 +40202,18 @@ _tmp_241_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); expr_ty yield_expr_var; if ( (yield_expr_var = yield_expr_rule(p)) // yield_expr ) { - D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); + D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); _res = yield_expr_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); } { // star_expressions @@ -45568,18 +40221,18 @@ _tmp_241_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_241[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); expr_ty star_expressions_var; if ( (star_expressions_var = star_expressions_rule(p)) // star_expressions ) { - D(fprintf(stderr, "%*c+ _tmp_241[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); + D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); _res = star_expressions_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_241[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); } _res = NULL; @@ -45588,9 +40241,9 @@ _tmp_241_rule(Parser *p) return _res; } -// _tmp_242: '!' NAME +// _tmp_244: '!' NAME static void * -_tmp_242_rule(Parser *p) +_tmp_244_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45607,7 +40260,7 @@ _tmp_242_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_242[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c> _tmp_244[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!' NAME")); Token * _literal; expr_ty name_var; if ( @@ -45616,12 +40269,12 @@ _tmp_242_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { - D(fprintf(stderr, "%*c+ _tmp_242[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); + D(fprintf(stderr, "%*c+ _tmp_244[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!' NAME")); _res = _PyPegen_dummy_name(p, _literal, name_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_242[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_244[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!' NAME")); } _res = NULL; @@ -45630,9 +40283,9 @@ _tmp_242_rule(Parser *p) return _res; } -// _tmp_243: ':' | '}' +// _tmp_245: ':' | '}' static void * -_tmp_243_rule(Parser *p) +_tmp_245_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45649,18 +40302,18 @@ _tmp_243_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_245[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_245[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_245[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '}' @@ -45668,20 +40321,19 @@ _tmp_243_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_243[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c> _tmp_245[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'}'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 26)) // token='}' ) { - D(fprintf(stderr, "%*c+ _tmp_243[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); + D(fprintf(stderr, "%*c+ _tmp_245[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'}'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_243[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_245[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'}'")); ->>>>>>> upstream/main } _res = NULL; done: @@ -45689,9 +40341,9 @@ _tmp_243_rule(Parser *p) return _res; } -// _tmp_244: star_targets '=' +// _tmp_246: star_targets '=' static void * -_tmp_244_rule(Parser *p) +_tmp_246_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45708,7 +40360,7 @@ _tmp_244_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_244[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_246[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty z; if ( @@ -45717,7 +40369,7 @@ _tmp_244_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_244[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_246[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -45727,7 +40379,7 @@ _tmp_244_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_244[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_246[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -45736,9 +40388,9 @@ _tmp_244_rule(Parser *p) return _res; } -// _tmp_245: '.' | '...' +// _tmp_247: '.' | '...' static void * -_tmp_245_rule(Parser *p) +_tmp_247_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45755,18 +40407,18 @@ _tmp_245_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_245[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_245[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_245[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -45774,18 +40426,18 @@ _tmp_245_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_245[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_245[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_245[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -45794,9 +40446,9 @@ _tmp_245_rule(Parser *p) return _res; } -// _tmp_246: '.' | '...' +// _tmp_248: '.' | '...' static void * -_tmp_246_rule(Parser *p) +_tmp_248_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45813,18 +40465,18 @@ _tmp_246_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_246[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c> _tmp_248[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 23)) // token='.' ) { - D(fprintf(stderr, "%*c+ _tmp_246[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); + D(fprintf(stderr, "%*c+ _tmp_248[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_246[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_248[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); } { // '...' @@ -45832,18 +40484,18 @@ _tmp_246_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_246[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c> _tmp_248[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 52)) // token='...' ) { - D(fprintf(stderr, "%*c+ _tmp_246[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); + D(fprintf(stderr, "%*c+ _tmp_248[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_246[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_248[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); } _res = NULL; @@ -45852,9 +40504,9 @@ _tmp_246_rule(Parser *p) return _res; } -// _tmp_247: '@' named_expression NEWLINE +// _tmp_249: '@' named_expression NEWLINE static void * -_tmp_247_rule(Parser *p) +_tmp_249_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45871,7 +40523,7 @@ _tmp_247_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); Token * _literal; expr_ty f; Token * newline_var; @@ -45883,7 +40535,7 @@ _tmp_247_rule(Parser *p) (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) { - D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); + D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); _res = f; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -45893,7 +40545,7 @@ _tmp_247_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); } _res = NULL; @@ -45902,9 +40554,9 @@ _tmp_247_rule(Parser *p) return _res; } -// _tmp_248: ',' expression +// _tmp_250: ',' expression static void * -_tmp_248_rule(Parser *p) +_tmp_250_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45921,7 +40573,7 @@ _tmp_248_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_248[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c> _tmp_250[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); Token * _literal; expr_ty c; if ( @@ -45930,7 +40582,7 @@ _tmp_248_rule(Parser *p) (c = expression_rule(p)) // expression ) { - D(fprintf(stderr, "%*c+ _tmp_248[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); + D(fprintf(stderr, "%*c+ _tmp_250[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -45940,7 +40592,7 @@ _tmp_248_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_248[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_250[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); } _res = NULL; @@ -45949,9 +40601,9 @@ _tmp_248_rule(Parser *p) return _res; } -// _tmp_249: ',' star_expression +// _tmp_251: ',' star_expression static void * -_tmp_249_rule(Parser *p) +_tmp_251_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -45968,7 +40620,7 @@ _tmp_249_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c> _tmp_251[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); Token * _literal; expr_ty c; if ( @@ -45977,7 +40629,7 @@ _tmp_249_rule(Parser *p) (c = star_expression_rule(p)) // star_expression ) { - D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); + D(fprintf(stderr, "%*c+ _tmp_251[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -45987,7 +40639,7 @@ _tmp_249_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_251[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); } _res = NULL; @@ -45996,9 +40648,9 @@ _tmp_249_rule(Parser *p) return _res; } -// _tmp_250: 'or' conjunction +// _tmp_252: 'or' conjunction static void * -_tmp_250_rule(Parser *p) +_tmp_252_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46015,7 +40667,7 @@ _tmp_250_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_250[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c> _tmp_252[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); Token * _keyword; expr_ty c; if ( @@ -46024,7 +40676,7 @@ _tmp_250_rule(Parser *p) (c = conjunction_rule(p)) // conjunction ) { - D(fprintf(stderr, "%*c+ _tmp_250[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); + D(fprintf(stderr, "%*c+ _tmp_252[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -46034,7 +40686,7 @@ _tmp_250_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_250[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_252[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); } _res = NULL; @@ -46043,9 +40695,9 @@ _tmp_250_rule(Parser *p) return _res; } -// _tmp_251: 'and' inversion +// _tmp_253: 'and' inversion static void * -_tmp_251_rule(Parser *p) +_tmp_253_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46062,7 +40714,7 @@ _tmp_251_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_251[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c> _tmp_253[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); Token * _keyword; expr_ty c; if ( @@ -46071,7 +40723,7 @@ _tmp_251_rule(Parser *p) (c = inversion_rule(p)) // inversion ) { - D(fprintf(stderr, "%*c+ _tmp_251[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); + D(fprintf(stderr, "%*c+ _tmp_253[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -46081,7 +40733,7 @@ _tmp_251_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_251[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_253[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); } _res = NULL; @@ -46090,9 +40742,9 @@ _tmp_251_rule(Parser *p) return _res; } -// _tmp_252: slice | starred_expression +// _tmp_254: slice | starred_expression static void * -_tmp_252_rule(Parser *p) +_tmp_254_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46109,18 +40761,18 @@ _tmp_252_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_252[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); + D(fprintf(stderr, "%*c> _tmp_254[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice")); expr_ty slice_var; if ( (slice_var = slice_rule(p)) // slice ) { - D(fprintf(stderr, "%*c+ _tmp_252[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); + D(fprintf(stderr, "%*c+ _tmp_254[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice")); _res = slice_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_252[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_254[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice")); } { // starred_expression @@ -46128,18 +40780,18 @@ _tmp_252_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_252[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_254[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); expr_ty starred_expression_var; if ( (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_252[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_254[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_252[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_254[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } _res = NULL; @@ -46148,9 +40800,9 @@ _tmp_252_rule(Parser *p) return _res; } -// _tmp_253: fstring | string +// _tmp_255: fstring | string static void * -_tmp_253_rule(Parser *p) +_tmp_255_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46167,18 +40819,18 @@ _tmp_253_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_253[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring")); + D(fprintf(stderr, "%*c> _tmp_255[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "fstring")); expr_ty fstring_var; if ( (fstring_var = fstring_rule(p)) // fstring ) { - D(fprintf(stderr, "%*c+ _tmp_253[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring")); + D(fprintf(stderr, "%*c+ _tmp_255[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "fstring")); _res = fstring_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_253[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_255[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "fstring")); } { // string @@ -46186,18 +40838,18 @@ _tmp_253_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_253[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "string")); + D(fprintf(stderr, "%*c> _tmp_255[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "string")); expr_ty string_var; if ( (string_var = string_rule(p)) // string ) { - D(fprintf(stderr, "%*c+ _tmp_253[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "string")); + D(fprintf(stderr, "%*c+ _tmp_255[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "string")); _res = string_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_253[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_255[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "string")); } _res = NULL; @@ -46206,9 +40858,9 @@ _tmp_253_rule(Parser *p) return _res; } -// _tmp_254: 'if' disjunction +// _tmp_256: 'if' disjunction static void * -_tmp_254_rule(Parser *p) +_tmp_256_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46225,7 +40877,7 @@ _tmp_254_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_254[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_256[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -46234,7 +40886,7 @@ _tmp_254_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_254[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_256[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -46244,7 +40896,7 @@ _tmp_254_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_254[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_256[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -46253,9 +40905,9 @@ _tmp_254_rule(Parser *p) return _res; } -// _tmp_255: 'if' disjunction +// _tmp_257: 'if' disjunction static void * -_tmp_255_rule(Parser *p) +_tmp_257_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46272,7 +40924,7 @@ _tmp_255_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_255[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c> _tmp_257[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); Token * _keyword; expr_ty z; if ( @@ -46281,7 +40933,7 @@ _tmp_255_rule(Parser *p) (z = disjunction_rule(p)) // disjunction ) { - D(fprintf(stderr, "%*c+ _tmp_255[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); + D(fprintf(stderr, "%*c+ _tmp_257[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); _res = z; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -46291,7 +40943,7 @@ _tmp_255_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_255[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_257[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); } _res = NULL; @@ -46300,9 +40952,9 @@ _tmp_255_rule(Parser *p) return _res; } -// _tmp_256: starred_expression | (assignment_expression | expression !':=') !'=' +// _tmp_258: starred_expression | (assignment_expression | expression !':=') !'=' static void * -_tmp_256_rule(Parser *p) +_tmp_258_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46319,18 +40971,18 @@ _tmp_256_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_256[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c> _tmp_258[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); expr_ty starred_expression_var; if ( (starred_expression_var = starred_expression_rule(p)) // starred_expression ) { - D(fprintf(stderr, "%*c+ _tmp_256[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); + D(fprintf(stderr, "%*c+ _tmp_258[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); _res = starred_expression_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_256[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_258[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); } { // (assignment_expression | expression !':=') !'=' @@ -46338,20 +40990,20 @@ _tmp_256_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_256[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - void *_tmp_268_var; + D(fprintf(stderr, "%*c> _tmp_258[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + void *_tmp_270_var; if ( - (_tmp_268_var = _tmp_268_rule(p)) // assignment_expression | expression !':=' + (_tmp_270_var = _tmp_270_rule(p)) // assignment_expression | expression !':=' && _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_256[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); - _res = _tmp_268_var; + D(fprintf(stderr, "%*c+ _tmp_258[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(assignment_expression | expression !':=') !'='")); + _res = _tmp_270_var; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_256[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_258[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(assignment_expression | expression !':=') !'='")); } _res = NULL; @@ -46360,9 +41012,9 @@ _tmp_256_rule(Parser *p) return _res; } -// _tmp_257: ',' star_target +// _tmp_259: ',' star_target static void * -_tmp_257_rule(Parser *p) +_tmp_259_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46379,7 +41031,7 @@ _tmp_257_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_257[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_259[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -46388,7 +41040,7 @@ _tmp_257_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_257[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_259[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -46398,7 +41050,7 @@ _tmp_257_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_257[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_259[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -46407,9 +41059,9 @@ _tmp_257_rule(Parser *p) return _res; } -// _tmp_258: ',' star_target +// _tmp_260: ',' star_target static void * -_tmp_258_rule(Parser *p) +_tmp_260_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46426,7 +41078,7 @@ _tmp_258_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_258[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c> _tmp_260[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); Token * _literal; expr_ty c; if ( @@ -46435,7 +41087,7 @@ _tmp_258_rule(Parser *p) (c = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_258[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); + D(fprintf(stderr, "%*c+ _tmp_260[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); _res = c; if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; @@ -46445,7 +41097,7 @@ _tmp_258_rule(Parser *p) goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_258[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_260[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); } _res = NULL; @@ -46454,9 +41106,9 @@ _tmp_258_rule(Parser *p) return _res; } -// _tmp_259: star_targets '=' +// _tmp_261: star_targets '=' static void * -_tmp_259_rule(Parser *p) +_tmp_261_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46473,7 +41125,7 @@ _tmp_259_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_259[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_261[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -46482,12 +41134,12 @@ _tmp_259_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_259[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_261[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = _PyPegen_dummy_name(p, star_targets_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_259[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_261[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -46496,9 +41148,9 @@ _tmp_259_rule(Parser *p) return _res; } -// _tmp_260: star_targets '=' +// _tmp_262: star_targets '=' static void * -_tmp_260_rule(Parser *p) +_tmp_262_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46515,7 +41167,7 @@ _tmp_260_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_260[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c> _tmp_262[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); Token * _literal; expr_ty star_targets_var; if ( @@ -46524,12 +41176,12 @@ _tmp_260_rule(Parser *p) (_literal = _PyPegen_expect_token(p, 22)) // token='=' ) { - D(fprintf(stderr, "%*c+ _tmp_260[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); + D(fprintf(stderr, "%*c+ _tmp_262[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); _res = _PyPegen_dummy_name(p, star_targets_var, _literal); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_260[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_262[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); } _res = NULL; @@ -46538,9 +41190,9 @@ _tmp_260_rule(Parser *p) return _res; } -// _tmp_261: ')' | '**' +// _tmp_263: ')' | '**' static void * -_tmp_261_rule(Parser *p) +_tmp_263_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46557,18 +41209,18 @@ _tmp_261_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_261[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c> _tmp_263[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 8)) // token=')' ) { - D(fprintf(stderr, "%*c+ _tmp_261[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); + D(fprintf(stderr, "%*c+ _tmp_263[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_261[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_263[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); } { // '**' @@ -46576,18 +41228,18 @@ _tmp_261_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_261[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_263[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_261[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_263[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_261[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_263[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; @@ -46596,9 +41248,9 @@ _tmp_261_rule(Parser *p) return _res; } -// _tmp_262: ':' | '**' +// _tmp_264: ':' | '**' static void * -_tmp_262_rule(Parser *p) +_tmp_264_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46615,18 +41267,18 @@ _tmp_262_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_262[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c> _tmp_264[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 11)) // token=':' ) { - D(fprintf(stderr, "%*c+ _tmp_262[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); + D(fprintf(stderr, "%*c+ _tmp_264[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_262[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_264[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); } { // '**' @@ -46634,105 +41286,19 @@ _tmp_262_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_262[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c> _tmp_264[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); Token * _literal; if ( (_literal = _PyPegen_expect_token(p, 35)) // token='**' ) { - D(fprintf(stderr, "%*c+ _tmp_262[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); + D(fprintf(stderr, "%*c+ _tmp_264[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); _res = _literal; goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_262[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_263: expression ['as' star_target] -static void * -_tmp_263_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // expression ['as' star_target] - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_263[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty expression_var; - if ( - (expression_var = expression_rule(p)) // expression - && - (_opt_var = _tmp_269_rule(p), !p->error_indicator) // ['as' star_target] - ) - { - D(fprintf(stderr, "%*c+ _tmp_263[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); - _res = _PyPegen_dummy_name(p, expression_var, _opt_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_263[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_264: expressions ['as' star_target] -static void * -_tmp_264_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // expressions ['as' star_target] - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_264[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); - void *_opt_var; - UNUSED(_opt_var); // Silence compiler warnings - expr_ty expressions_var; - if ( - (expressions_var = expressions_rule(p)) // expressions - && - (_opt_var = _tmp_270_rule(p), !p->error_indicator) // ['as' star_target] - ) - { - D(fprintf(stderr, "%*c+ _tmp_264[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); - _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); - goto done; - } - p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_264[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); } _res = NULL; done: @@ -46740,11 +41306,7 @@ _tmp_264_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_246: expression ['as' star_target] -======= // _tmp_265: expression ['as' star_target] ->>>>>>> upstream/main static void * _tmp_265_rule(Parser *p) { @@ -46830,7 +41392,7 @@ _tmp_266_rule(Parser *p) return _res; } -// _tmp_267: 'as' NAME +// _tmp_267: expression ['as' star_target] static void * _tmp_267_rule(Parser *p) { @@ -46849,22 +41411,22 @@ _tmp_267_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_246[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_267[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression && - (_opt_var = _tmp_252_rule(p), !p->error_indicator) // ['as' star_target] + (_opt_var = _tmp_273_rule(p), !p->error_indicator) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_246[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_267[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); _res = _PyPegen_dummy_name(p, expression_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_246[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_267[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); } _res = NULL; @@ -46873,9 +41435,9 @@ _tmp_267_rule(Parser *p) return _res; } -// _tmp_247: expressions ['as' star_target] +// _tmp_268: expressions ['as' star_target] static void * -_tmp_247_rule(Parser *p) +_tmp_268_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46892,22 +41454,22 @@ _tmp_247_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_247[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c> _tmp_268[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); void *_opt_var; UNUSED(_opt_var); // Silence compiler warnings expr_ty expressions_var; if ( (expressions_var = expressions_rule(p)) // expressions && - (_opt_var = _tmp_253_rule(p), !p->error_indicator) // ['as' star_target] + (_opt_var = _tmp_274_rule(p), !p->error_indicator) // ['as' star_target] ) { - D(fprintf(stderr, "%*c+ _tmp_247[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); + D(fprintf(stderr, "%*c+ _tmp_268[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_247[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_268[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); } _res = NULL; @@ -46916,9 +41478,9 @@ _tmp_247_rule(Parser *p) return _res; } -// _tmp_248: 'as' NAME +// _tmp_269: 'as' NAME static void * -_tmp_248_rule(Parser *p) +_tmp_269_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46935,11 +41497,7 @@ _tmp_248_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_248[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); -======= - D(fprintf(stderr, "%*c> _tmp_267[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_269[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); Token * _keyword; expr_ty name_var; if ( @@ -46948,20 +41506,12 @@ _tmp_248_rule(Parser *p) (name_var = _PyPegen_name_token(p)) // NAME ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_248[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); -======= - D(fprintf(stderr, "%*c+ _tmp_267[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_269[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); _res = _PyPegen_dummy_name(p, _keyword, name_var); goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_248[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_267[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_269[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); } _res = NULL; @@ -46970,15 +41520,9 @@ _tmp_248_rule(Parser *p) return _res; } -<<<<<<< HEAD -// _tmp_249: assignment_expression | expression !':=' -static void * -_tmp_249_rule(Parser *p) -======= -// _tmp_268: assignment_expression | expression !':=' +// _tmp_270: assignment_expression | expression !':=' static void * -_tmp_268_rule(Parser *p) ->>>>>>> upstream/main +_tmp_270_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -46995,30 +41539,18 @@ _tmp_268_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); -======= - D(fprintf(stderr, "%*c> _tmp_268[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_270[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment_expression")); expr_ty assignment_expression_var; if ( (assignment_expression_var = assignment_expression_rule(p)) // assignment_expression ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); -======= - D(fprintf(stderr, "%*c+ _tmp_268[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_270[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment_expression")); _res = assignment_expression_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', -======= - D(fprintf(stderr, "%*c%s _tmp_268[%d-%d]: %s failed!\n", p->level, ' ', ->>>>>>> upstream/main + D(fprintf(stderr, "%*c%s _tmp_270[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment_expression")); } { // expression !':=' @@ -47026,11 +41558,7 @@ _tmp_268_rule(Parser *p) p->level--; return NULL; } -<<<<<<< HEAD - D(fprintf(stderr, "%*c> _tmp_249[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); -======= - D(fprintf(stderr, "%*c> _tmp_268[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c> _tmp_270[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); expr_ty expression_var; if ( (expression_var = expression_rule(p)) // expression @@ -47038,106 +41566,13 @@ _tmp_268_rule(Parser *p) _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' ) { -<<<<<<< HEAD - D(fprintf(stderr, "%*c+ _tmp_249[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); -======= - D(fprintf(stderr, "%*c+ _tmp_268[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); ->>>>>>> upstream/main + D(fprintf(stderr, "%*c+ _tmp_270[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); _res = expression_var; goto done; } p->mark = _mark; -<<<<<<< HEAD - D(fprintf(stderr, "%*c%s _tmp_249[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); -======= - D(fprintf(stderr, "%*c%s _tmp_268[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_269: 'as' star_target -static void * -_tmp_269_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' star_target - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_269[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); - Token * _keyword; - expr_ty star_target_var; - if ( - (_keyword = _PyPegen_expect_token(p, 640)) // token='as' - && - (star_target_var = star_target_rule(p)) // star_target - ) - { - D(fprintf(stderr, "%*c+ _tmp_269[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); - _res = _PyPegen_dummy_name(p, _keyword, star_target_var); - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_269[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); - } - _res = NULL; - done: - p->level--; - return _res; -} - -// _tmp_270: 'as' star_target -static void * -_tmp_270_rule(Parser *p) -{ - if (p->level++ == MAXSTACK) { - p->error_indicator = 1; - PyErr_NoMemory(); - } - if (p->error_indicator) { - p->level--; - return NULL; - } - void * _res = NULL; - int _mark = p->mark; - { // 'as' star_target - if (p->error_indicator) { - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> _tmp_270[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); - Token * _keyword; - expr_ty star_target_var; - if ( - (_keyword = _PyPegen_expect_token(p, 640)) // token='as' - && - (star_target_var = star_target_rule(p)) // star_target - ) - { - D(fprintf(stderr, "%*c+ _tmp_270[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); - _res = _PyPegen_dummy_name(p, _keyword, star_target_var); - goto done; - } - p->mark = _mark; D(fprintf(stderr, "%*c%s _tmp_270[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); ->>>>>>> upstream/main + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); } _res = NULL; done: @@ -47229,9 +41664,9 @@ _tmp_272_rule(Parser *p) return _res; } -// _tmp_252: 'as' star_target +// _tmp_273: 'as' star_target static void * -_tmp_252_rule(Parser *p) +_tmp_273_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -47248,21 +41683,21 @@ _tmp_252_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_252[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_273[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( - (_keyword = _PyPegen_expect_token(p, 639)) // token='as' + (_keyword = _PyPegen_expect_token(p, 640)) // token='as' && (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_252[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_273[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_252[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_273[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; @@ -47271,9 +41706,9 @@ _tmp_252_rule(Parser *p) return _res; } -// _tmp_253: 'as' star_target +// _tmp_274: 'as' star_target static void * -_tmp_253_rule(Parser *p) +_tmp_274_rule(Parser *p) { if (p->level++ == MAXSTACK) { p->error_indicator = 1; @@ -47290,21 +41725,21 @@ _tmp_253_rule(Parser *p) p->level--; return NULL; } - D(fprintf(stderr, "%*c> _tmp_253[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c> _tmp_274[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); Token * _keyword; expr_ty star_target_var; if ( - (_keyword = _PyPegen_expect_token(p, 639)) // token='as' + (_keyword = _PyPegen_expect_token(p, 640)) // token='as' && (star_target_var = star_target_rule(p)) // star_target ) { - D(fprintf(stderr, "%*c+ _tmp_253[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); + D(fprintf(stderr, "%*c+ _tmp_274[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); _res = _PyPegen_dummy_name(p, _keyword, star_target_var); goto done; } p->mark = _mark; - D(fprintf(stderr, "%*c%s _tmp_253[%d-%d]: %s failed!\n", p->level, ' ', + D(fprintf(stderr, "%*c%s _tmp_274[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); } _res = NULL; diff --git a/Python/compile.c b/Python/compile.c index 1cc38a2cf85be0..cbd45aa8f675e7 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -709,7 +709,7 @@ compiler_set_qualname(struct compiler *c) if (stack_size == 2) { // If we're immediately within the module, we can skip // the rest and just set the qualname to be the same as name. - u->u_qualname = Py_NewRef(u->u_name); + u->u_metadata.u_qualname = Py_NewRef(u->u_metadata.u_name); return SUCCESS; } capsule = PyList_GET_ITEM(c->c_stack, stack_size - 2); @@ -2243,15 +2243,15 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) Py_DECREF(co); if (typeparams) { if (is_typeparams_in_class) { - c->u->u_argcount += 1; + c->u->u_metadata.u_argcount += 1; } if (funcflags & 0x02) { - c->u->u_argcount += 1; + c->u->u_metadata.u_argcount += 1; } if (funcflags & 0x01) { - c->u->u_argcount += 1; + c->u->u_metadata.u_argcount += 1; } - PyCodeObject *co = assemble(c, 0); + PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { return ERROR; @@ -2416,8 +2416,8 @@ compiler_class(struct compiler *c, stmt_ty s) &_Py_STR(type_params))); int is_in_class = c->u->u_ste->ste_type_params_in_class; - c->u->u_argcount = is_in_class; - PyCodeObject *co = assemble(c, 0); + c->u->u_metadata.u_argcount = is_in_class; + PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { return ERROR; @@ -2479,7 +2479,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) RETURN_IF_ERROR(compiler_add_const(c->c_const_cache, c->u, Py_None)); VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); - PyCodeObject *co = assemble(c, 1); + PyCodeObject *co = optimize_and_assemble(c, 1); compiler_exit_scope(c); if (co == NULL) { return ERROR; @@ -2493,8 +2493,8 @@ compiler_typealias(struct compiler *c, stmt_ty s) ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); if (typeparams) { int is_in_class = c->u->u_ste->ste_type_params_in_class; - c->u->u_argcount = is_in_class; - PyCodeObject *co = assemble(c, 0); + c->u->u_metadata.u_argcount = is_in_class; + PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { return ERROR; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 3c4572c529fa7f..6dba04ae145139 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -8,6 +8,7 @@ } TARGET(RESUME) { + #line 137 "Python/bytecodes.c" assert(tstate->cframe == &cframe); assert(frame == cframe.current_frame); /* Possibly combine this with eval breaker */ @@ -19,10 +20,12 @@ else if (_Py_atomic_load_relaxed_int32(eval_breaker) && oparg < 2) { goto handle_eval_breaker; } + #line 24 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_RESUME) { + #line 151 "Python/bytecodes.c" /* Possible performance enhancement: * We need to check the eval breaker anyway, can we * combine the instrument verison check and the eval breaker test? @@ -48,15 +51,18 @@ goto handle_eval_breaker; } } + #line 55 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLOSURE) { PyObject *value; + #line 179 "Python/bytecodes.c" /* We keep LOAD_CLOSURE so that the bytecode stays more readable. */ value = GETLOCAL(oparg); if (value == NULL) goto unbound_local_error; Py_INCREF(value); + #line 66 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -64,9 +70,11 @@ TARGET(LOAD_FAST_CHECK) { PyObject *value; + #line 186 "Python/bytecodes.c" value = GETLOCAL(oparg); if (value == NULL) goto unbound_local_error; Py_INCREF(value); + #line 78 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -74,9 +82,11 @@ TARGET(LOAD_FAST) { PyObject *value; + #line 192 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); + #line 90 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -85,8 +95,10 @@ TARGET(LOAD_CONST) { PREDICTED(LOAD_CONST); PyObject *value; + #line 198 "Python/bytecodes.c" value = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(value); + #line 102 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -94,7 +106,9 @@ TARGET(STORE_FAST) { PyObject *value = stack_pointer[-1]; + #line 203 "Python/bytecodes.c" SETLOCAL(oparg, value); + #line 112 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -104,17 +118,21 @@ PyObject *_tmp_2; { PyObject *value; + #line 192 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); + #line 126 "Python/generated_cases.c.h" _tmp_2 = value; } oparg = (next_instr++)->op.arg; { PyObject *value; + #line 192 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); + #line 136 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(2); @@ -128,16 +146,20 @@ PyObject *_tmp_2; { PyObject *value; + #line 192 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); + #line 154 "Python/generated_cases.c.h" _tmp_2 = value; } oparg = (next_instr++)->op.arg; { PyObject *value; + #line 198 "Python/bytecodes.c" value = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(value); + #line 163 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(2); @@ -150,14 +172,18 @@ PyObject *_tmp_1 = stack_pointer[-1]; { PyObject *value = _tmp_1; + #line 203 "Python/bytecodes.c" SETLOCAL(oparg, value); + #line 178 "Python/generated_cases.c.h" } oparg = (next_instr++)->op.arg; { PyObject *value; + #line 192 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); + #line 187 "Python/generated_cases.c.h" _tmp_1 = value; } stack_pointer[-1] = _tmp_1; @@ -169,12 +195,16 @@ PyObject *_tmp_2 = stack_pointer[-2]; { PyObject *value = _tmp_1; + #line 203 "Python/bytecodes.c" SETLOCAL(oparg, value); + #line 201 "Python/generated_cases.c.h" } oparg = (next_instr++)->op.arg; { PyObject *value = _tmp_2; + #line 203 "Python/bytecodes.c" SETLOCAL(oparg, value); + #line 208 "Python/generated_cases.c.h" } STACK_SHRINK(2); DISPATCH(); @@ -185,16 +215,20 @@ PyObject *_tmp_2; { PyObject *value; + #line 198 "Python/bytecodes.c" value = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(value); + #line 222 "Python/generated_cases.c.h" _tmp_2 = value; } oparg = (next_instr++)->op.arg; { PyObject *value; + #line 192 "Python/bytecodes.c" value = GETLOCAL(oparg); assert(value != NULL); Py_INCREF(value); + #line 232 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(2); @@ -205,6 +239,8 @@ TARGET(POP_TOP) { PyObject *value = stack_pointer[-1]; + #line 213 "Python/bytecodes.c" + #line 244 "Python/generated_cases.c.h" Py_DECREF(value); STACK_SHRINK(1); DISPATCH(); @@ -212,7 +248,9 @@ TARGET(PUSH_NULL) { PyObject *res; + #line 217 "Python/bytecodes.c" res = NULL; + #line 254 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -220,7 +258,9 @@ TARGET(POP_NULL) { PyObject *value = stack_pointer[-1]; + #line 221 "Python/bytecodes.c" assert(value == NULL); + #line 264 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -230,10 +270,14 @@ PyObject *_tmp_2 = stack_pointer[-2]; { PyObject *value = _tmp_1; + #line 213 "Python/bytecodes.c" + #line 275 "Python/generated_cases.c.h" Py_DECREF(value); } { PyObject *value = _tmp_2; + #line 213 "Python/bytecodes.c" + #line 281 "Python/generated_cases.c.h" Py_DECREF(value); } STACK_SHRINK(2); @@ -243,6 +287,7 @@ TARGET(INSTRUMENTED_END_FOR) { PyObject *value = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; + #line 227 "Python/bytecodes.c" /* Need to create a fake StopIteration error here, * to conform to PEP 380 */ if (PyGen_Check(receiver)) { @@ -252,6 +297,7 @@ } PyErr_SetRaisedException(NULL); } + #line 301 "Python/generated_cases.c.h" Py_DECREF(receiver); Py_DECREF(value); STACK_SHRINK(2); @@ -261,7 +307,9 @@ TARGET(END_SEND) { PyObject *value = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; + #line 240 "Python/bytecodes.c" Py_DECREF(receiver); + #line 313 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; DISPATCH(); @@ -270,6 +318,7 @@ TARGET(INSTRUMENTED_END_SEND) { PyObject *value = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; + #line 244 "Python/bytecodes.c" if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) { PyErr_SetObject(PyExc_StopIteration, value); if (monitor_stop_iteration(tstate, frame, next_instr-1)) { @@ -278,6 +327,7 @@ PyErr_SetRaisedException(NULL); } Py_DECREF(receiver); + #line 331 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; DISPATCH(); @@ -286,9 +336,13 @@ TARGET(UNARY_NEGATIVE) { PyObject *value = stack_pointer[-1]; PyObject *res; + #line 255 "Python/bytecodes.c" res = PyNumber_Negative(value); + #line 342 "Python/generated_cases.c.h" Py_DECREF(value); + #line 257 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; + #line 346 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -296,8 +350,11 @@ TARGET(UNARY_NOT) { PyObject *value = stack_pointer[-1]; PyObject *res; + #line 261 "Python/bytecodes.c" int err = PyObject_IsTrue(value); + #line 356 "Python/generated_cases.c.h" Py_DECREF(value); + #line 263 "Python/bytecodes.c" if (err < 0) goto pop_1_error; if (err == 0) { res = Py_True; @@ -306,6 +363,7 @@ res = Py_False; } Py_INCREF(res); + #line 367 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -313,9 +371,13 @@ TARGET(UNARY_INVERT) { PyObject *value = stack_pointer[-1]; PyObject *res; + #line 274 "Python/bytecodes.c" res = PyNumber_Invert(value); + #line 377 "Python/generated_cases.c.h" Py_DECREF(value); + #line 276 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; + #line 381 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -324,6 +386,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; + #line 293 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -331,6 +394,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (prod == NULL) goto pop_2_error; + #line 398 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = prod; next_instr += 1; @@ -341,12 +405,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; + #line 303 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); double dprod = ((PyFloatObject *)left)->ob_fval * ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dprod, prod); + #line 416 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = prod; next_instr += 1; @@ -357,6 +423,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; + #line 312 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -364,6 +431,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (sub == NULL) goto pop_2_error; + #line 435 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sub; next_instr += 1; @@ -374,11 +442,13 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; + #line 322 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); double dsub = ((PyFloatObject *)left)->ob_fval - ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsub, sub); + #line 452 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sub; next_instr += 1; @@ -389,6 +459,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; + #line 330 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -396,6 +467,7 @@ _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc); _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc); if (res == NULL) goto pop_2_error; + #line 471 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -405,6 +477,7 @@ TARGET(BINARY_OP_INPLACE_ADD_UNICODE) { PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; + #line 346 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP]; @@ -431,6 +504,7 @@ if (*target_local == NULL) goto pop_2_error; // The STORE_FAST is already done. JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1); + #line 508 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -439,12 +513,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; + #line 375 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); STAT_INC(BINARY_OP, hit); double dsum = ((PyFloatObject *)left)->ob_fval + ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsum, sum); + #line 524 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sum; next_instr += 1; @@ -455,6 +531,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; + #line 384 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -462,6 +539,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (sum == NULL) goto pop_2_error; + #line 543 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sum; next_instr += 1; @@ -474,6 +552,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; PyObject *res; + #line 402 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -485,9 +564,12 @@ DECREMENT_ADAPTIVE_COUNTER(cache->counter); #endif /* ENABLE_SPECIALIZATION */ res = PyObject_GetItem(container, sub); + #line 568 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); + #line 414 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; + #line 573 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -499,6 +581,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *res; + #line 418 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); // Can't use ERROR_IF() here, because we haven't // DECREF'ed container yet, and we still own slice. @@ -511,6 +594,7 @@ } Py_DECREF(container); if (res == NULL) goto pop_3_error; + #line 598 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = res; DISPATCH(); @@ -521,6 +605,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *v = stack_pointer[-4]; + #line 433 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); int err; if (slice == NULL) { @@ -533,6 +618,7 @@ Py_DECREF(v); Py_DECREF(container); if (err) goto pop_4_error; + #line 622 "Python/generated_cases.c.h" STACK_SHRINK(4); DISPATCH(); } @@ -541,6 +627,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *res; + #line 448 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR); @@ -554,6 +641,7 @@ Py_INCREF(res); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(list); + #line 645 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -564,6 +652,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *tuple = stack_pointer[-2]; PyObject *res; + #line 464 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR); @@ -577,6 +666,7 @@ Py_INCREF(res); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(tuple); + #line 670 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -587,6 +677,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *res; + #line 480 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR); STAT_INC(BINARY_SUBSCR, hit); res = PyDict_GetItemWithError(dict, sub); @@ -594,11 +685,14 @@ if (!_PyErr_Occurred(tstate)) { _PyErr_SetKeyError(sub); } + #line 689 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); + #line 488 "Python/bytecodes.c" if (true) goto pop_2_error; } Py_INCREF(res); // Do this before DECREF'ing dict, sub + #line 696 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); STACK_SHRINK(1); @@ -610,6 +704,7 @@ TARGET(BINARY_SUBSCR_GETITEM) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; + #line 495 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(container); DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR); PyHeapTypeObject *ht = (PyHeapTypeObject *)tp; @@ -631,12 +726,15 @@ JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); + #line 730 "Python/generated_cases.c.h" } TARGET(LIST_APPEND) { PyObject *v = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; + #line 519 "Python/bytecodes.c" if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error; + #line 738 "Python/generated_cases.c.h" STACK_SHRINK(1); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -645,9 +743,13 @@ TARGET(SET_ADD) { PyObject *v = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; + #line 524 "Python/bytecodes.c" int err = PySet_Add(set, v); + #line 749 "Python/generated_cases.c.h" Py_DECREF(v); + #line 526 "Python/bytecodes.c" if (err) goto pop_1_error; + #line 753 "Python/generated_cases.c.h" STACK_SHRINK(1); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -660,6 +762,7 @@ PyObject *container = stack_pointer[-2]; PyObject *v = stack_pointer[-3]; uint16_t counter = read_u16(&next_instr[0].cache); + #line 537 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { next_instr--; @@ -674,10 +777,13 @@ #endif /* ENABLE_SPECIALIZATION */ /* container[sub] = v */ int err = PyObject_SetItem(container, sub, v); + #line 781 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(container); Py_DECREF(sub); + #line 552 "Python/bytecodes.c" if (err) goto pop_3_error; + #line 787 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -687,6 +793,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; + #line 556 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR); @@ -703,6 +810,7 @@ Py_DECREF(old_value); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(list); + #line 814 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -712,11 +820,13 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; + #line 575 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR); STAT_INC(STORE_SUBSCR, hit); int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value); Py_DECREF(dict); if (err) goto pop_3_error; + #line 830 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -725,11 +835,15 @@ TARGET(DELETE_SUBSCR) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; + #line 583 "Python/bytecodes.c" /* del container[sub] */ int err = PyObject_DelItem(container, sub); + #line 842 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); + #line 586 "Python/bytecodes.c" if (err) goto pop_2_error; + #line 847 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -737,10 +851,14 @@ TARGET(CALL_INTRINSIC_1) { PyObject *value = stack_pointer[-1]; PyObject *res; + #line 590 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_1); res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value); + #line 858 "Python/generated_cases.c.h" Py_DECREF(value); + #line 593 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; + #line 862 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -749,11 +867,15 @@ PyObject *value1 = stack_pointer[-1]; PyObject *value2 = stack_pointer[-2]; PyObject *res; + #line 597 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_2); res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1); + #line 874 "Python/generated_cases.c.h" Py_DECREF(value2); Py_DECREF(value1); + #line 600 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; + #line 879 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -761,6 +883,7 @@ TARGET(RAISE_VARARGS) { PyObject **args = (stack_pointer - oparg); + #line 604 "Python/bytecodes.c" PyObject *cause = NULL, *exc = NULL; switch (oparg) { case 2: @@ -778,10 +901,12 @@ break; } if (true) { STACK_SHRINK(oparg); goto error; } + #line 905 "Python/generated_cases.c.h" } TARGET(INTERPRETER_EXIT) { PyObject *retval = stack_pointer[-1]; + #line 624 "Python/bytecodes.c" assert(frame == &entry_frame); assert(_PyFrame_IsIncomplete(frame)); STACK_SHRINK(1); // Since we're not going to DISPATCH() @@ -792,10 +917,12 @@ assert(!_PyErr_Occurred(tstate)); _Py_LeaveRecursiveCallTstate(tstate); return retval; + #line 921 "Python/generated_cases.c.h" } TARGET(RETURN_VALUE) { PyObject *retval = stack_pointer[-1]; + #line 637 "Python/bytecodes.c" STACK_SHRINK(1); assert(EMPTY()); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -808,10 +935,12 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; + #line 939 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_RETURN_VALUE) { PyObject *retval = stack_pointer[-1]; + #line 652 "Python/bytecodes.c" int err = _Py_call_instrumentation_arg( tstate, PY_MONITORING_EVENT_PY_RETURN, frame, next_instr-1, retval); @@ -828,9 +957,11 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; + #line 961 "Python/generated_cases.c.h" } TARGET(RETURN_CONST) { + #line 671 "Python/bytecodes.c" PyObject *retval = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(retval); assert(EMPTY()); @@ -844,9 +975,11 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; + #line 979 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_RETURN_CONST) { + #line 687 "Python/bytecodes.c" PyObject *retval = GETITEM(frame->f_code->co_consts, oparg); int err = _Py_call_instrumentation_arg( tstate, PY_MONITORING_EVENT_PY_RETURN, @@ -864,11 +997,13 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; + #line 1001 "Python/generated_cases.c.h" } TARGET(GET_AITER) { PyObject *obj = stack_pointer[-1]; PyObject *iter; + #line 707 "Python/bytecodes.c" unaryfunc getter = NULL; PyTypeObject *type = Py_TYPE(obj); @@ -881,12 +1016,16 @@ "'async for' requires an object with " "__aiter__ method, got %.100s", type->tp_name); + #line 1020 "Python/generated_cases.c.h" Py_DECREF(obj); + #line 720 "Python/bytecodes.c" if (true) goto pop_1_error; } iter = (*getter)(obj); + #line 1027 "Python/generated_cases.c.h" Py_DECREF(obj); + #line 725 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; if (Py_TYPE(iter)->tp_as_async == NULL || @@ -899,6 +1038,7 @@ Py_DECREF(iter); if (true) goto pop_1_error; } + #line 1042 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -906,6 +1046,7 @@ TARGET(GET_ANEXT) { PyObject *aiter = stack_pointer[-1]; PyObject *awaitable; + #line 740 "Python/bytecodes.c" unaryfunc getter = NULL; PyObject *next_iter = NULL; PyTypeObject *type = Py_TYPE(aiter); @@ -949,6 +1090,7 @@ } } + #line 1094 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = awaitable; PREDICT(LOAD_CONST); @@ -959,13 +1101,16 @@ PREDICTED(GET_AWAITABLE); PyObject *iterable = stack_pointer[-1]; PyObject *iter; + #line 787 "Python/bytecodes.c" iter = _PyCoro_GetAwaitableIter(iterable); if (iter == NULL) { format_awaitable_error(tstate, Py_TYPE(iterable), oparg); } + #line 1112 "Python/generated_cases.c.h" Py_DECREF(iterable); + #line 794 "Python/bytecodes.c" if (iter != NULL && PyCoro_CheckExact(iter)) { PyObject *yf = _PyGen_yf((PyGenObject*)iter); @@ -983,6 +1128,7 @@ if (iter == NULL) goto pop_1_error; + #line 1132 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -993,6 +1139,7 @@ PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; PyObject *retval; + #line 820 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PySendCache *cache = (_PySendCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1038,6 +1185,7 @@ } } Py_DECREF(v); + #line 1189 "Python/generated_cases.c.h" stack_pointer[-1] = retval; next_instr += 1; DISPATCH(); @@ -1046,6 +1194,7 @@ TARGET(SEND_GEN) { PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; + #line 868 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)receiver; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type && Py_TYPE(gen) != &PyCoro_Type, SEND); @@ -1060,10 +1209,12 @@ tstate->exc_info = &gen->gi_exc_state; JUMPBY(INLINE_CACHE_ENTRIES_SEND); DISPATCH_INLINED(gen_frame); + #line 1213 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_YIELD_VALUE) { PyObject *retval = stack_pointer[-1]; + #line 885 "Python/bytecodes.c" assert(frame != &entry_frame); PyGenObject *gen = _PyFrame_GetGenerator(frame); gen->gi_frame_state = FRAME_SUSPENDED; @@ -1080,10 +1231,12 @@ gen_frame->previous = NULL; _PyFrame_StackPush(frame, retval); goto resume_frame; + #line 1235 "Python/generated_cases.c.h" } TARGET(YIELD_VALUE) { PyObject *retval = stack_pointer[-1]; + #line 904 "Python/bytecodes.c" // NOTE: It's important that YIELD_VALUE never raises an exception! // The compiler treats any exception raised here as a failed close() // or throw() call. @@ -1099,12 +1252,15 @@ gen_frame->previous = NULL; _PyFrame_StackPush(frame, retval); goto resume_frame; + #line 1256 "Python/generated_cases.c.h" } TARGET(POP_EXCEPT) { PyObject *exc_value = stack_pointer[-1]; + #line 922 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; Py_XSETREF(exc_info->exc_value, exc_value); + #line 1264 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -1112,6 +1268,7 @@ TARGET(RERAISE) { PyObject *exc = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); + #line 927 "Python/bytecodes.c" assert(oparg >= 0 && oparg <= 2); if (oparg) { PyObject *lasti = values[0]; @@ -1129,21 +1286,26 @@ Py_INCREF(exc); _PyErr_SetRaisedException(tstate, exc); goto exception_unwind; + #line 1290 "Python/generated_cases.c.h" } TARGET(END_ASYNC_FOR) { PyObject *exc = stack_pointer[-1]; PyObject *awaitable = stack_pointer[-2]; + #line 947 "Python/bytecodes.c" assert(exc && PyExceptionInstance_Check(exc)); if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) { + #line 1299 "Python/generated_cases.c.h" Py_DECREF(awaitable); Py_DECREF(exc); + #line 950 "Python/bytecodes.c" } else { Py_INCREF(exc); _PyErr_SetRaisedException(tstate, exc); goto exception_unwind; } + #line 1309 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -1154,19 +1316,23 @@ PyObject *sub_iter = stack_pointer[-3]; PyObject *none; PyObject *value; + #line 959 "Python/bytecodes.c" assert(throwflag); assert(exc_value && PyExceptionInstance_Check(exc_value)); if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) { value = Py_NewRef(((PyStopIterationObject *)exc_value)->value); + #line 1325 "Python/generated_cases.c.h" Py_DECREF(sub_iter); Py_DECREF(last_sent_val); Py_DECREF(exc_value); + #line 964 "Python/bytecodes.c" none = Py_NewRef(Py_None); } else { _PyErr_SetRaisedException(tstate, Py_NewRef(exc_value)); goto exception_unwind; } + #line 1336 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; stack_pointer[-2] = none; @@ -1175,7 +1341,9 @@ TARGET(LOAD_ASSERTION_ERROR) { PyObject *value; + #line 973 "Python/bytecodes.c" value = Py_NewRef(PyExc_AssertionError); + #line 1347 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1183,6 +1351,7 @@ TARGET(LOAD_BUILD_CLASS) { PyObject *bc; + #line 977 "Python/bytecodes.c" if (PyDict_CheckExact(BUILTINS())) { bc = _PyDict_GetItemWithError(BUILTINS(), &_Py_ID(__build_class__)); @@ -1204,6 +1373,7 @@ if (true) goto error; } } + #line 1377 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = bc; DISPATCH(); @@ -1211,6 +1381,7 @@ TARGET(LOAD_LOCALS) { PyObject *locals; + #line 1001 "Python/bytecodes.c" locals = LOCALS(); if (locals == NULL) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -1218,6 +1389,7 @@ if (true) goto error; } Py_INCREF(locals); + #line 1393 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = locals; DISPATCH(); @@ -1225,26 +1397,33 @@ TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; + #line 1011 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); + #line 1408 "Python/generated_cases.c.h" Py_DECREF(v); + #line 1018 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); + #line 1417 "Python/generated_cases.c.h" Py_DECREF(v); + #line 1025 "Python/bytecodes.c" if (err) goto pop_1_error; + #line 1421 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { + #line 1029 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1261,6 +1440,7 @@ name); goto error; } + #line 1444 "Python/generated_cases.c.h" DISPATCH(); } @@ -1268,6 +1448,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; + #line 1055 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1280,8 +1461,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); + #line 1465 "Python/generated_cases.c.h" Py_DECREF(seq); + #line 1068 "Python/bytecodes.c" if (res == 0) goto pop_1_error; + #line 1469 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1291,12 +1475,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); + #line 1072 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); + #line 1486 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1307,6 +1493,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); + #line 1082 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1314,6 +1501,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } + #line 1505 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1324,6 +1512,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); + #line 1093 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1331,6 +1520,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } + #line 1524 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1340,11 +1530,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; + #line 1104 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); + #line 1538 "Python/generated_cases.c.h" Py_DECREF(seq); + #line 1108 "Python/bytecodes.c" if (res == 0) goto pop_1_error; + #line 1542 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1355,6 +1549,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); + #line 1119 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1370,9 +1565,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); + #line 1569 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); + #line 1135 "Python/bytecodes.c" if (err) goto pop_2_error; + #line 1574 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1380,25 +1578,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; + #line 1139 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); + #line 1585 "Python/generated_cases.c.h" Py_DECREF(owner); + #line 1142 "Python/bytecodes.c" if (err) goto pop_1_error; + #line 1589 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; + #line 1146 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); + #line 1599 "Python/generated_cases.c.h" Py_DECREF(v); + #line 1149 "Python/bytecodes.c" if (err) goto pop_1_error; + #line 1603 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { + #line 1153 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1410,11 +1617,13 @@ } goto error; } + #line 1621 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASS_OR_GLOBAL) { PyObject *v; + #line 1167 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = GETLOCAL(0); if (locals == NULL) { @@ -1473,6 +1682,7 @@ } } } + #line 1686 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1480,6 +1690,7 @@ TARGET(LOAD_NAME) { PyObject *v; + #line 1228 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = LOCALS(); if (locals == NULL) { @@ -1538,6 +1749,7 @@ } } } + #line 1753 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1548,6 +1760,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; + #line 1295 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1599,6 +1812,7 @@ } } null = NULL; + #line 1816 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1612,6 +1826,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); + #line 1349 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1622,6 +1837,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; + #line 1841 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1636,6 +1852,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); + #line 1362 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1650,6 +1867,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; + #line 1871 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1659,13 +1877,16 @@ } TARGET(DELETE_FAST) { + #line 1379 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); + #line 1885 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { + #line 1385 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1674,10 +1895,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); + #line 1899 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { + #line 1396 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1688,11 +1911,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); + #line 1915 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; + #line 1409 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1724,6 +1949,7 @@ } Py_INCREF(value); } + #line 1953 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1731,6 +1957,7 @@ TARGET(LOAD_DEREF) { PyObject *value; + #line 1443 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1738,6 +1965,7 @@ if (true) goto error; } Py_INCREF(value); + #line 1969 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1745,15 +1973,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; + #line 1453 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); + #line 1982 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { + #line 1460 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1764,17 +1995,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } + #line 1999 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; + #line 1473 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); + #line 2008 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } + #line 1475 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } + #line 2014 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -1784,8 +2020,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; + #line 1479 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } + #line 2027 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -1795,8 +2033,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; + #line 1484 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } + #line 2040 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -1806,6 +2046,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; + #line 1489 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -1816,10 +2057,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } + #line 2061 "Python/generated_cases.c.h" Py_DECREF(iterable); + #line 1500 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); + #line 2067 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -1828,9 +2072,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; + #line 1507 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); + #line 2078 "Python/generated_cases.c.h" Py_DECREF(iterable); + #line 1509 "Python/bytecodes.c" if (err < 0) goto pop_1_error; + #line 2082 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -1838,6 +2086,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; + #line 1513 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -1852,6 +2101,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } + #line 2105 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -1861,6 +2111,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; + #line 1530 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -1868,10 +2119,13 @@ if (map == NULL) goto error; + #line 2123 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } + #line 1538 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } + #line 2129 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -1879,6 +2133,7 @@ } TARGET(SETUP_ANNOTATIONS) { + #line 1542 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -1918,6 +2173,7 @@ Py_DECREF(ann_dict); } } + #line 2177 "Python/generated_cases.c.h" DISPATCH(); } @@ -1925,6 +2181,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; + #line 1584 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -1934,11 +2191,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); + #line 2195 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); + #line 1594 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } + #line 2202 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -1946,6 +2206,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; + #line 1598 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -1953,9 +2214,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } + #line 2218 "Python/generated_cases.c.h" Py_DECREF(update); + #line 1606 "Python/bytecodes.c" if (true) goto pop_1_error; } + #line 2223 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -1963,13 +2227,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; + #line 1612 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); + #line 2236 "Python/generated_cases.c.h" Py_DECREF(update); + #line 1617 "Python/bytecodes.c" if (true) goto pop_1_error; } + #line 2241 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -1979,11 +2247,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; + #line 1624 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; + #line 2257 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -1995,6 +2265,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; + #line 1647 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2028,7 +2299,9 @@ NULL | meth | arg1 | ... | argN */ + #line 2303 "Python/generated_cases.c.h" Py_DECREF(owner); + #line 1681 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2037,9 +2310,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); + #line 2314 "Python/generated_cases.c.h" Py_DECREF(owner); + #line 1690 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } + #line 2319 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2053,6 +2329,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); + #line 1695 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2065,6 +2342,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; + #line 2346 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2079,6 +2357,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); + #line 1711 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2091,6 +2370,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; + #line 2374 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2105,6 +2385,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); + #line 1727 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2131,6 +2412,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; + #line 2416 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2145,6 +2427,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); + #line 1757 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2154,6 +2437,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; + #line 2441 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2168,6 +2452,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); + #line 1770 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2179,6 +2464,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); + #line 2468 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2192,6 +2478,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); + #line 1785 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2215,6 +2502,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); + #line 2506 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2222,6 +2510,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); + #line 1811 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2247,6 +2536,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); + #line 2540 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2254,6 +2544,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); + #line 1839 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2271,6 +2562,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); + #line 2566 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2281,6 +2573,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); + #line 1859 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2319,6 +2612,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); + #line 2616 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2329,6 +2623,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); + #line 1900 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2338,6 +2633,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); + #line 2637 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2349,6 +2645,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; + #line 1919 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2361,9 +2658,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); + #line 2662 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); + #line 1932 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; + #line 2667 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2374,6 +2674,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; + #line 1936 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2385,6 +2686,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); + #line 2690 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2395,6 +2697,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; + #line 1951 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2410,6 +2713,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); + #line 2717 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2420,6 +2724,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; + #line 1970 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2432,6 +2737,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); + #line 2741 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2442,10 +2748,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; + #line 1985 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; + #line 2754 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); + #line 1987 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); + #line 2759 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2455,11 +2765,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; + #line 1991 "Python/bytecodes.c" int res = PySequence_Contains(right, left); + #line 2771 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); + #line 1993 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); + #line 2777 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2470,9 +2784,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; + #line 1998 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { + #line 2790 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); + #line 2000 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2480,8 +2797,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); + #line 2801 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); + #line 2008 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2490,6 +2809,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } + #line 2813 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2499,15 +2819,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; + #line 2019 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { + #line 2826 "Python/generated_cases.c.h" Py_DECREF(right); + #line 2022 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); + #line 2833 "Python/generated_cases.c.h" Py_DECREF(right); + #line 2027 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); + #line 2837 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2516,11 +2842,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; + #line 2031 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); + #line 2849 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); + #line 2034 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; + #line 2854 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2529,23 +2859,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; + #line 2038 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; + #line 2867 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { + #line 2044 "Python/bytecodes.c" JUMPBY(oparg); + #line 2876 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); + #line 2048 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); + #line 2885 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2553,6 +2889,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; + #line 2054 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2562,7 +2899,9 @@ } else { int err = PyObject_IsTrue(cond); + #line 2903 "Python/generated_cases.c.h" Py_DECREF(cond); + #line 2064 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2570,12 +2909,14 @@ if (err < 0) goto pop_1_error; } } + #line 2913 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; + #line 2074 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2585,7 +2926,9 @@ } else { int err = PyObject_IsTrue(cond); + #line 2930 "Python/generated_cases.c.h" Py_DECREF(cond); + #line 2084 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2593,54 +2936,67 @@ if (err < 0) goto pop_1_error; } } + #line 2940 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; + #line 2094 "Python/bytecodes.c" if (!Py_IsNone(value)) { + #line 2949 "Python/generated_cases.c.h" Py_DECREF(value); + #line 2096 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } + #line 2957 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; + #line 2104 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { + #line 2970 "Python/generated_cases.c.h" Py_DECREF(value); + #line 2110 "Python/bytecodes.c" } + #line 2974 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { + #line 2114 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); + #line 2987 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; + #line 2123 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; + #line 3000 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -2651,13 +3007,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; + #line 2131 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); + #line 3016 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); + #line 2136 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -2665,6 +3024,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } + #line 3028 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -2673,8 +3033,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; + #line 2146 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); + #line 3040 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2684,8 +3046,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; + #line 2152 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); + #line 3053 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2696,9 +3060,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; + #line 2158 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; + #line 3068 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -2707,10 +3073,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; + #line 2164 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); + #line 3080 "Python/generated_cases.c.h" Py_DECREF(iterable); + #line 2167 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; + #line 3084 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -2718,6 +3088,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; + #line 2171 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -2740,8 +3111,11 @@ if (iter == NULL) { goto error; } + #line 3115 "Python/generated_cases.c.h" Py_DECREF(iterable); + #line 2194 "Python/bytecodes.c" } + #line 3119 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -2752,6 +3126,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; + #line 2213 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2782,6 +3157,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator + #line 3161 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -2789,6 +3165,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { + #line 2246 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -2814,12 +3191,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); + #line 3195 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; + #line 2274 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -2839,6 +3218,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator + #line 3222 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -2848,6 +3228,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; + #line 2296 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -2867,6 +3248,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator + #line 3252 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -2876,6 +3258,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; + #line 2318 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -2893,6 +3276,7 @@ if (next == NULL) { goto error; } + #line 3280 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -2901,6 +3285,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; + #line 2338 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -2915,12 +3300,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); + #line 3304 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; + #line 2355 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -2943,13 +3330,16 @@ Py_DECREF(enter); goto error; } + #line 3334 "Python/generated_cases.c.h" Py_DECREF(mgr); + #line 2378 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } + #line 3343 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -2961,6 +3351,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; + #line 2388 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -2986,13 +3377,16 @@ Py_DECREF(enter); goto error; } + #line 3381 "Python/generated_cases.c.h" Py_DECREF(mgr); + #line 2414 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } + #line 3390 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3004,6 +3398,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; + #line 2423 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3024,6 +3419,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; + #line 3423 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3032,6 +3428,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; + #line 2446 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3041,6 +3438,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); + #line 3442 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3054,6 +3452,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); + #line 2458 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3070,6 +3469,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); + #line 3473 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3083,6 +3483,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); + #line 2477 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3092,6 +3493,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); + #line 3497 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3105,6 +3507,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); + #line 2489 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3118,6 +3521,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); + #line 3525 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3126,13 +3530,16 @@ } TARGET(KW_NAMES) { + #line 2505 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); + #line 3538 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { + #line 2511 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3145,6 +3552,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); + #line 3556 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3154,6 +3562,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2556 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3235,6 +3644,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 3648 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3246,6 +3656,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; + #line 2644 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3255,6 +3666,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); + #line 3670 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3263,6 +3675,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); + #line 2656 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3288,6 +3701,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); + #line 3705 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3295,6 +3709,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); + #line 2684 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3330,6 +3745,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); + #line 3749 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3337,6 +3753,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2722 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3346,6 +3763,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable + #line 3767 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3358,6 +3776,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2734 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3368,6 +3787,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 3791 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3381,6 +3801,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2748 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3391,6 +3812,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 3816 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3404,6 +3826,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2762 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3425,6 +3848,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 3852 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3438,6 +3862,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2787 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3465,6 +3890,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 3894 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3478,6 +3904,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2818 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3509,6 +3936,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ + #line 3940 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3522,6 +3950,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2853 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -3553,6 +3982,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 3986 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3566,6 +3996,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2888 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -3590,6 +4021,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 4025 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3602,6 +4034,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2915 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -3628,6 +4061,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 4065 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3639,6 +4073,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; + #line 2945 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -3656,12 +4091,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); + #line 4095 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2965 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -3692,6 +4129,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 4133 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3704,6 +4142,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 2999 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3732,6 +4171,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 4175 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3744,6 +4184,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 3031 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -3772,6 +4213,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 4217 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3784,6 +4226,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; + #line 3063 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -3811,6 +4254,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } + #line 4258 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3820,7 +4264,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { + #line 3094 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); + #line 4270 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -3829,6 +4275,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; + #line 3098 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -3871,11 +4318,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } + #line 4322 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); + #line 3141 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } + #line 4329 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -3891,6 +4341,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; + #line 3152 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -3923,12 +4374,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; + #line 4378 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { + #line 3187 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -3949,6 +4402,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; + #line 4406 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -3956,11 +4410,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; + #line 3210 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); + #line 4416 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); + #line 3212 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } + #line 4422 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -3971,6 +4429,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; + #line 3216 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4005,6 +4464,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } + #line 4468 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4013,8 +4473,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; + #line 3253 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); + #line 4480 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4026,6 +4488,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; + #line 3258 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4040,9 +4503,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); + #line 4507 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); + #line 3273 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; + #line 4512 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4052,13 +4518,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; + #line 3278 "Python/bytecodes.c" assert(oparg >= 2); + #line 4524 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { + #line 3282 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4078,9 +4547,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); + #line 4551 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { + #line 3304 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4092,20 +4563,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); + #line 4567 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { + #line 3318 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); + #line 4573 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { + #line 3322 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); + #line 4580 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { + #line 3327 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4114,10 +4591,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); + #line 4595 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { + #line 3338 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4126,10 +4605,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); + #line 4609 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { + #line 3349 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4142,10 +4623,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); + #line 4627 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { + #line 3364 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4158,23 +4641,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); + #line 4645 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { + #line 3379 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); + #line 4656 "Python/generated_cases.c.h" } TARGET(CACHE) { + #line 3387 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); + #line 4663 "Python/generated_cases.c.h" } TARGET(RESERVED) { + #line 3392 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); + #line 4670 "Python/generated_cases.c.h" } From 48e23b00a6ac5b83767d5cac9db7e16b8f18ab83 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 13:15:55 -0600 Subject: [PATCH 065/200] Avoid complicating compile_call_helper --- .../pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + .../internal/pycore_runtime_init_generated.h | 1 + Python/compile.c | 49 +++++++++++-------- Python/symtable.c | 10 ++++ 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index da25b7b468ec47..7d9bf1f447ebd2 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -559,6 +559,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dot_locals)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(empty)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(generic_base)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(json_decoder)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(kwdefaults)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(list_err)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index f1ef1bdb861732..fa6e8281ae41bd 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -44,6 +44,7 @@ struct _Py_global_strings { STRUCT_FOR_STR(dot, ".") STRUCT_FOR_STR(dot_locals, ".") STRUCT_FOR_STR(empty, "") + STRUCT_FOR_STR(generic_base, ".generic_base") STRUCT_FOR_STR(json_decoder, "json.decoder") STRUCT_FOR_STR(kwdefaults, ".kwdefaults") STRUCT_FOR_STR(list_err, "list index out of range") diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index eb7e444f250e01..ba5bcd58a90845 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -550,6 +550,7 @@ extern "C" { INIT_STR(dot, "."), \ INIT_STR(dot_locals, "."), \ INIT_STR(empty, ""), \ + INIT_STR(generic_base, ".generic_base"), \ INIT_STR(json_decoder, "json.decoder"), \ INIT_STR(kwdefaults, ".kwdefaults"), \ INIT_STR(list_err, "list index out of range"), \ diff --git a/Python/compile.c b/Python/compile.c index cbd45aa8f675e7..8c403b96a54b8c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -467,8 +467,7 @@ static int compiler_call_simple_kw_helper(struct compiler *c, Py_ssize_t nkwelts); static int compiler_call_helper(struct compiler *c, location loc, int n, asdl_expr_seq *args, - asdl_keyword_seq *keywords, - PyObject *extra_positional_arg); + asdl_keyword_seq *keywords); static int compiler_try_except(struct compiler *, stmt_ty); static int compiler_try_star_except(struct compiler *, stmt_ty); static int compiler_set_qualname(struct compiler *); @@ -2410,10 +2409,28 @@ compiler_class(struct compiler *c, stmt_ty s) if (typeparams) { _Py_DECLARE_STR(type_params, ".type_params"); + _Py_DECLARE_STR(generic_base, ".generic_base"); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(generic_base), Store)); + + Py_ssize_t original_len = asdl_seq_LEN(s->v.ClassDef.bases); + asdl_expr_seq *bases = _Py_asdl_expr_seq_new( + original_len + 1, c->c_arena); + for (Py_ssize_t i = 0; i < original_len; i++) { + asdl_seq_SET(bases, i, asdl_seq_GET(s->v.ClassDef.bases, i)); + } + expr_ty name_node = _PyAST_Name( + &_Py_STR(generic_base), Load, + loc.lineno, loc.col_offset, loc.end_lineno, loc.end_col_offset, c->c_arena + ); + if (name_node == NULL) { + return ERROR; + } + asdl_seq_SET(bases, original_len, name_node); RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, - s->v.ClassDef.bases, - s->v.ClassDef.keywords, - &_Py_STR(type_params))); + bases, + s->v.ClassDef.keywords)); int is_in_class = c->u->u_ste->ste_type_params_in_class; c->u->u_metadata.u_argcount = is_in_class; @@ -2434,8 +2451,7 @@ compiler_class(struct compiler *c, stmt_ty s) } else { RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, s->v.ClassDef.bases, - s->v.ClassDef.keywords, - NULL)); + s->v.ClassDef.keywords)); } /* 6. apply decorators */ @@ -4607,8 +4623,7 @@ compiler_call(struct compiler *c, expr_ty e) loc = LOC(e); return compiler_call_helper(c, loc, 0, e->v.Call.args, - e->v.Call.keywords, - NULL); + e->v.Call.keywords); } static int @@ -4758,18 +4773,16 @@ static int compiler_call_helper(struct compiler *c, location loc, int n, /* Args already pushed */ asdl_expr_seq *args, - asdl_keyword_seq *keywords, - PyObject *extra_positional_arg) + asdl_keyword_seq *keywords) { - Py_ssize_t i, nseen, nelts, nkwelts, real_nelts; + Py_ssize_t i, nseen, nelts, nkwelts; RETURN_IF_ERROR(validate_keywords(c, keywords)); nelts = asdl_seq_LEN(args); nkwelts = asdl_seq_LEN(keywords); - real_nelts = extra_positional_arg == NULL ? nelts : nelts + 1; - if (real_nelts + nkwelts*2 > STACK_USE_GUIDELINE) { + if (nelts + nkwelts*2 > STACK_USE_GUIDELINE) { goto ex_call; } for (i = 0; i < nelts; i++) { @@ -4791,22 +4804,16 @@ compiler_call_helper(struct compiler *c, location loc, assert(elt->kind != Starred_kind); VISIT(c, expr, elt); } - if (extra_positional_arg != NULL) { - RETURN_IF_ERROR(compiler_nameop(c, loc, extra_positional_arg, Load)); - ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC); - } if (nkwelts) { VISIT_SEQ(c, keyword, keywords); RETURN_IF_ERROR( compiler_call_simple_kw_helper(c, loc, keywords, nkwelts)); } - ADDOP_I(c, loc, CALL, n + real_nelts + nkwelts); + ADDOP_I(c, loc, CALL, n + nelts + nkwelts); return SUCCESS; ex_call: - assert(extra_positional_arg == NULL); // TODO(PEP 695) - /* Do positional arguments. */ if (n ==0 && nelts == 1 && ((expr_ty)asdl_seq_GET(args, 0))->kind == Starred_kind) { VISIT(c, expr, ((expr_ty)asdl_seq_GET(args, 0))->v.Starred.value); diff --git a/Python/symtable.c b/Python/symtable.c index 0ed0423cd9852e..084d6ff6e4d71c 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1156,6 +1156,16 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, lineno, col_offset, end_lineno, end_col_offset)) { return 0; } + // This is used for setting the generic base + _Py_DECLARE_STR(generic_base, ".generic_base"); + if (!symtable_add_def(st, &_Py_STR(generic_base), DEF_LOCAL, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + if (!symtable_add_def(st, &_Py_STR(generic_base), USE, + lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } } if (has_defaults) { _Py_DECLARE_STR(defaults, ".defaults"); From dec31ae26fa81eb2b2749e82f1f398dddbf9f7fb Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 13:24:46 -0600 Subject: [PATCH 066/200] Apparently it is a length-0 list if there are no typeparams, not NULL --- Python/compile.c | 16 ++++++++-------- Python/symtable.c | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 8c403b96a54b8c..4b976bef115d02 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2151,7 +2151,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int is_typeparams_in_class = 0; - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { ADDOP(c, loc, PUSH_NULL); // We'll swap in the callable here later. ADDOP(c, loc, PUSH_NULL); @@ -2173,7 +2173,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int num_typeparam_args = 0; - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { funcflags |= 0x10; PyObject *typeparams_name = PyUnicode_FromFormat("", name); if (!typeparams_name) { @@ -2240,7 +2240,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { if (is_typeparams_in_class) { c->u->u_metadata.u_argcount += 1; } @@ -2294,7 +2294,7 @@ compiler_class(struct compiler *c, stmt_ty s) location loc = LOC(s); asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { ADDOP(c, loc, PUSH_NULL); PyObject *typeparams_name = PyUnicode_FromFormat("", s->v.ClassDef.name); @@ -2348,7 +2348,7 @@ compiler_class(struct compiler *c, stmt_ty s) compiler_exit_scope(c); return ERROR; } - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { if (!compiler_set_type_params_in_class(c, loc)) { compiler_exit_scope(c); return ERROR; @@ -2407,7 +2407,7 @@ compiler_class(struct compiler *c, stmt_ty s) /* 5. generate the rest of the code for the call */ - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { _Py_DECLARE_STR(type_params, ".type_params"); _Py_DECLARE_STR(generic_base, ".generic_base"); RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); @@ -2468,7 +2468,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) location loc = LOC(s); asdl_typeparam_seq *typeparams = s->v.TypeAlias.typeparams; PyObject *name = s->v.TypeAlias.name->v.Name.id; - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { ADDOP(c, loc, PUSH_NULL); PyObject *typeparams_name = PyUnicode_FromFormat("", name); @@ -2507,7 +2507,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) Py_DECREF(co); ADDOP_I(c, loc, BUILD_TUPLE, 3); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); - if (typeparams) { + if (asdl_seq_LEN(typeparams) > 0) { int is_in_class = c->u->u_ste->ste_type_params_in_class; c->u->u_metadata.u_argcount = is_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); diff --git a/Python/symtable.c b/Python/symtable.c index 084d6ff6e4d71c..8af56e5d5f0fbc 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1285,7 +1285,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ_WITH_NULL(st, expr, s->v.FunctionDef.args->kw_defaults); if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); - if (s->v.FunctionDef.typeparams) { + if (asdl_seq_LEN(s->v.AsyncFunctionDef.typeparams) > 0) { if (!symtable_enter_typeparam_block( st, s->v.FunctionDef.name, (void *)s->v.FunctionDef.typeparams, @@ -1309,7 +1309,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ(st, stmt, s->v.FunctionDef.body); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - if (s->v.FunctionDef.typeparams) { + if (asdl_seq_LEN(s->v.FunctionDef.typeparams) > 0) { if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); } @@ -1321,7 +1321,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); if (s->v.ClassDef.decorator_list) VISIT_SEQ(st, expr, s->v.ClassDef.decorator_list); - if (s->v.ClassDef.typeparams) { + if (asdl_seq_LEN(s->v.ClassDef.typeparams) > 0) { if (!symtable_enter_typeparam_block(st, s->v.ClassDef.name, (void *)s->v.ClassDef.typeparams, false, false, true, @@ -1338,7 +1338,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); tmp = st->st_private; st->st_private = s->v.ClassDef.name; - if (s->v.ClassDef.typeparams) { + if (asdl_seq_LEN(s->v.ClassDef.typeparams) > 0) { if (!symtable_add_def(st, &_Py_ID(__type_variables__), DEF_LOCAL, LOCATION(s))) { VISIT_QUIT(st, 0); @@ -1353,7 +1353,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) st->st_private = tmp; if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - if (s->v.ClassDef.typeparams) { + if (asdl_seq_LEN(s->v.ClassDef.typeparams) > 0) { if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); } @@ -1363,7 +1363,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT(st, expr, s->v.TypeAlias.name); assert(s->v.TypeAlias.name->kind == Name_kind); PyObject *name = s->v.TypeAlias.name->v.Name.id; - if (s->v.TypeAlias.typeparams) { + if (asdl_seq_LEN(s->v.TypeAlias.typeparams) > 0) { if (!symtable_enter_typeparam_block( st, name, (void *)s->v.TypeAlias.typeparams, @@ -1379,7 +1379,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT(st, expr, s->v.TypeAlias.value); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - if (s->v.TypeAlias.typeparams) { + if (asdl_seq_LEN(s->v.TypeAlias.typeparams) > 0) { if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); } @@ -1592,7 +1592,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) s->v.AsyncFunctionDef.args->kw_defaults); if (s->v.AsyncFunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.AsyncFunctionDef.decorator_list); - if (s->v.AsyncFunctionDef.typeparams) { + if (asdl_seq_LEN(s->v.AsyncFunctionDef.typeparams) > 0) { if (!symtable_enter_typeparam_block( st, s->v.AsyncFunctionDef.name, (void *)s->v.AsyncFunctionDef.typeparams, @@ -1618,7 +1618,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ(st, stmt, s->v.AsyncFunctionDef.body); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - if (s->v.AsyncFunctionDef.typeparams) { + if (asdl_seq_LEN(s->v.AsyncFunctionDef.typeparams) > 0) { if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); } From 062999c0f2f59f1b5ce413af8b47b54f02753f2d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 14:02:57 -0600 Subject: [PATCH 067/200] Fix GC for TypeAlias --- Objects/typevarobject.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 8fa7bafe5aa4c7..eed55e3a42ba61 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1042,6 +1042,7 @@ PyObject *_Py_make_typevartuple(const char *name) { static void typealias_dealloc(PyObject *self) { + _PyObject_GC_UNTRACK(self); typealiasobject *ta = (typealiasobject *)self; free((void *)ta->name); Py_XDECREF(ta->type_params); @@ -1066,7 +1067,7 @@ static PyMemberDef typealias_members[] = { static typealiasobject * typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) { - typealiasobject *ta = PyObject_GC_New(typealiasobject, &_PyTypeAlias_Type); + typealiasobject *ta = _PyTypeAlias_Type.tp_alloc(&_PyTypeAlias_Type, 0); if (ta == NULL) { return NULL; } @@ -1078,11 +1079,11 @@ typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value ta->type_params = Py_XNewRef(type_params); ta->compute_value = Py_NewRef(compute_value); ta->value = NULL; - PyObject_GC_Track(ta); return ta; } -static int typealias_traverse(typealiasobject *self, visitproc visit, void *arg) +static int +typealias_traverse(typealiasobject *self, visitproc visit, void *arg) { Py_VISIT(self->type_params); Py_VISIT(self->compute_value); @@ -1120,8 +1121,10 @@ PyTypeObject _PyTypeAlias_Type = { .tp_name = "TypeAlias", .tp_basicsize = sizeof(typealiasobject), .tp_dealloc = typealias_dealloc, + .tp_alloc = PyType_GenericAlloc, + .tp_free = PyObject_GC_Del, .tp_repr = typealias_repr, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC, .tp_members = typealias_members, .tp_methods = typealias_methods, .tp_doc = typealias_doc, From 9147a4a7f01ffa6f3cbf1261ed7c20704a63a302 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 14:04:04 -0600 Subject: [PATCH 068/200] fix warnings --- Objects/typevarobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index eed55e3a42ba61..5263e4f73aaa1c 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1067,7 +1067,8 @@ static PyMemberDef typealias_members[] = { static typealiasobject * typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) { - typealiasobject *ta = _PyTypeAlias_Type.tp_alloc(&_PyTypeAlias_Type, 0); + typealiasobject *ta = (typealiasobject *)_PyTypeAlias_Type.tp_alloc( + &_PyTypeAlias_Type, 0); if (ta == NULL) { return NULL; } @@ -1128,7 +1129,7 @@ PyTypeObject _PyTypeAlias_Type = { .tp_members = typealias_members, .tp_methods = typealias_methods, .tp_doc = typealias_doc, - .tp_traverse = typealias_traverse, + .tp_traverse = (traverseproc)typealias_traverse, }; PyObject * From 1b043c8dfc5c678e123d8342e5dff5aa453a75aa Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 14:09:52 -0600 Subject: [PATCH 069/200] Add to globals-to-fix --- Tools/c-analyzer/cpython/globals-to-fix.tsv | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tools/c-analyzer/cpython/globals-to-fix.tsv b/Tools/c-analyzer/cpython/globals-to-fix.tsv index 849fd5d9a1e8d5..fbb4cbdf1610be 100644 --- a/Tools/c-analyzer/cpython/globals-to-fix.tsv +++ b/Tools/c-analyzer/cpython/globals-to-fix.tsv @@ -89,6 +89,12 @@ Objects/tupleobject.c - PyTuple_Type - Objects/typeobject.c - PyBaseObject_Type - Objects/typeobject.c - PySuper_Type - Objects/typeobject.c - PyType_Type - +Objects/typevarobject.c - _PyTypeVar_Type - +Objects/typevarobject.c - _PyParamSpecArgs_Type - +Objects/typevarobject.c - _PyParamSpecKwargs_Type - +Objects/typevarobject.c - _PyParamSpec_Type - +Objects/typevarobject.c - _PyTypeVarTuple_Type - +Objects/typevarobject.c- _PyTypeAlias_Type - Objects/unicodeobject.c - PyUnicodeIter_Type - Objects/unicodeobject.c - PyUnicode_Type - Objects/weakrefobject.c - _PyWeakref_CallableProxyType - From 16cb6a5486189dc51158579557a213b7d2c790aa Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 14:11:31 -0600 Subject: [PATCH 070/200] Add to _freeze_module.vcxproj --- PCbuild/_freeze_module.vcxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index d897925f58c0de..c9dbe195d9325a 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -159,6 +159,7 @@ + From 1bdfb758a9cfcc23b8a3bb003033a85458cb8c31 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 16:52:44 -0600 Subject: [PATCH 071/200] Use heap types, fixing pickling --- Include/internal/pycore_typeobject.h | 6 + Include/internal/pycore_typevarobject.h | 8 +- Lib/typing.py | 53 ++- Objects/object.c | 5 - Objects/typevarobject.c | 516 +++++++++++++----------- Objects/unionobject.c | 4 +- Python/bltinmodule.c | 4 - Python/pylifecycle.c | 3 +- 8 files changed, 325 insertions(+), 274 deletions(-) diff --git a/Include/internal/pycore_typeobject.h b/Include/internal/pycore_typeobject.h index 4f862a356ce3d0..19a37f0c84e9c7 100644 --- a/Include/internal/pycore_typeobject.h +++ b/Include/internal/pycore_typeobject.h @@ -83,6 +83,12 @@ struct types_state { size_t num_builtins_initialized; static_builtin_state builtins[_Py_MAX_STATIC_BUILTIN_TYPES]; PyObject *generic_type; + PyObject *typevar_type; + PyObject *typevartuple_type; + PyObject *paramspec_type; + PyObject *paramspecargs_type; + PyObject *paramspeckwargs_type; + PyObject *typealias_type; }; diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index 2b28ca0f54079d..c02f0fe477dcb9 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -8,19 +8,13 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -extern PyTypeObject _PyTypeVar_Type; -extern PyTypeObject _PyTypeVarTuple_Type; -extern PyTypeObject _PyParamSpec_Type; -extern PyTypeObject _PyParamSpecArgs_Type; -extern PyTypeObject _PyParamSpecKwargs_Type; -extern PyTypeObject _PyTypeAlias_Type; - extern PyObject *_Py_make_typevar(const char *, PyObject *); extern PyObject *_Py_make_paramspec(const char *); extern PyObject *_Py_make_typevartuple(const char *); extern PyObject *_Py_make_typealias(PyThreadState* unused, PyObject *); extern PyObject *_Py_subscript_generic(PyObject *); extern int _Py_initialize_generic(PyInterpreterState *); +extern void _Py_clear_generic_types(PyInterpreterState *); #ifdef __cplusplus } diff --git a/Lib/typing.py b/Lib/typing.py index 2c00efe60a8cea..fc8145c781512a 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -180,7 +180,11 @@ def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms= We append the repr() of the actual value (truncated to 100 chars). """ - invalid_generic_forms = (Generic, Protocol) + try: + invalid_generic_forms = (Generic, Protocol) + except NameError: + # Run during interpreter startup + return arg if not allow_special_forms: invalid_generic_forms += (ClassVar,) if is_argument: @@ -1052,7 +1056,8 @@ def _generic_class_getitem(cls, params): is_generic_or_protocol = cls in (Generic, Protocol) except NameError: # Happens during interpreter startup - is_generic_or_protocol = True + return _GenericAlias(cls, params, _paramspec_tvars=True) + if is_generic_or_protocol: # Generic and Protocol can only be subscripted with unique type variables. if not params: @@ -1776,12 +1781,27 @@ def _lazy_load_getattr_static(): _cleanups.append(_lazy_load_getattr_static.cache_clear) -class _Dummy1[T]: +class _Dummy[T, *Ts, **P]: pass -TypeVar = type(_Dummy1.__type_variables__[0]) -# Generic and Protocol must be defined before we can use a TypeVarTuple -Generic = _Dummy1.__mro__[1] +TypeVar = type(_Dummy.__type_variables__[0]) +TypeVarTuple = type(_Dummy.__type_variables__[1]) +ParamSpec = type(_Dummy.__type_variables__[2]) +ParamSpecArgs = type(ParamSpec("P").args) +ParamSpecKwargs = type(ParamSpec("P").kwargs) +Generic = _Dummy.__mro__[1] + +def _pickle_psargs(psargs): + return ParamSpecArgs, (psargs.__origin__,) + +copyreg.pickle(ParamSpecArgs, _pickle_psargs) + +def _pickle_pskwargs(pskwargs): + return ParamSpecKwargs, (pskwargs.__origin__,) + +copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) + +del _Dummy, _pickle_psargs, _pickle_pskwargs class _ProtocolMeta(ABCMeta): @@ -1926,27 +1946,6 @@ def _proto_hook(other): cls.__init__ = _no_init_or_replace_init -class _Dummy2[*Ts, **P](): - pass - -TypeVarTuple = type(_Dummy2.__type_variables__[0]) -ParamSpec = type(_Dummy2.__type_variables__[1]) -ParamSpecArgs = type(ParamSpec("P").args) -ParamSpecKwargs = type(ParamSpec("P").kwargs) - -def _pickle_psargs(psargs): - return ParamSpecArgs, (psargs.__origin__,) - -copyreg.pickle(ParamSpecArgs, _pickle_psargs) - -def _pickle_pskwargs(pskwargs): - return ParamSpecKwargs, (pskwargs.__origin__,) - -copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) - -del _Dummy1, _Dummy2, _pickle_psargs, _pickle_pskwargs - - class _AnnotatedAlias(_NotIterable, _GenericAlias, _root=True): """Runtime representation of an annotated type. diff --git a/Objects/object.c b/Objects/object.c index bd00ca248fd116..06243de8bddd95 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2087,11 +2087,6 @@ static PyTypeObject* static_types[] = { &_PyWeakref_CallableProxyType, &_PyWeakref_ProxyType, &_PyWeakref_RefType, - &_PyTypeVar_Type, - &_PyTypeVarTuple_Type, - &_PyParamSpec_Type, - &_PyParamSpecArgs_Type, - &_PyParamSpecKwargs_Type, // subclasses: _PyTypes_FiniTypes() deallocates them before their base // class diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 5263e4f73aaa1c..24737f12b821b9 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -8,8 +8,8 @@ /*[clinic input] class typevar "typevarobject *" "&_PyTypeVar_Type" class paramspec "paramspecobject *" "&_PyParamSpec_Type" -class paramspecargs "paramspecargsobject *" "&_PyParamSpecArgs_Type" -class paramspeckwargs "paramspeckwargsobject *" "&_PyParamSpecKwargs_Type" +class paramspecargs "paramspecattrobject *" "&_PyParamSpecArgs_Type" +class paramspeckwargs "paramspecattrobject *" "&_PyParamSpecKwargs_Type" class typevartuple "typevartupleobject *" "&_PyTypeVarTuple_Type" class typealias "typealiasobject *" "&_PyTypeAlias_Type" class Generic "PyObject *" "&PyGeneric_Type" @@ -88,7 +88,26 @@ make_union(PyObject *self, PyObject *other) { return call_typing_func_object("_make_union", args); } -static void typevarobject_dealloc(PyObject *self) +static PyObject * +caller(void) +{ + _PyInterpreterFrame *f = _PyThreadState_GET()->cframe->current_frame; + if (f == NULL) { + Py_RETURN_NONE; + } + if (f == NULL || f->f_funcobj == NULL) { + Py_RETURN_NONE; + } + PyObject *r = PyFunction_GetModule(f->f_funcobj); + if (!r) { + PyErr_Clear(); + r = Py_None; + } + return Py_NewRef(r); +} + +static void +typevar_dealloc(PyObject *self) { typevarobject *tv = (typevarobject *)self; @@ -101,7 +120,8 @@ static void typevarobject_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } -static int typevarobject_traverse(PyObject *self, visitproc visit, void *arg) +static int +typevar_traverse(PyObject *self, visitproc visit, void *arg) { typevarobject *tv = (typevarobject *)self; Py_VISIT(tv->bound); @@ -109,7 +129,7 @@ static int typevarobject_traverse(PyObject *self, visitproc visit, void *arg) return 0; } -static PyObject *typevarobject_repr(PyObject *self) +static PyObject *typevar_repr(PyObject *self) { typevarobject *tv = (typevarobject *)self; @@ -131,12 +151,14 @@ static PyMemberDef typevar_members[] = { {0} }; -static typevarobject *typevarobject_alloc(const char *name, PyObject *bound, - PyObject *constraints, - bool covariant, bool contravariant, - bool autovariance) +static typevarobject *typevar_alloc(const char *name, PyObject *bound, + PyObject *constraints, + bool covariant, bool contravariant, + bool autovariance, PyObject *module) { - typevarobject *tv = PyObject_GC_New(typevarobject, &_PyTypeVar_Type); + PyObject *tp = PyInterpreterState_Get()->types.typevar_type; + assert(tp != NULL); + typevarobject *tv = PyObject_GC_New(typevarobject, (PyTypeObject *)tp); if (tv == NULL) { return NULL; } @@ -153,8 +175,11 @@ static typevarobject *typevarobject_alloc(const char *name, PyObject *bound, tv->covariant = covariant; tv->contravariant = contravariant; tv->autovariance = autovariance; + if (module != NULL) { + PyObject_SetAttrString((PyObject *)tv, "__module__", module); + } - _PyObject_GC_TRACK(tv); + PyObject_GC_Track(tv); return tv; } @@ -220,10 +245,15 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, Py_XDECREF(bound); return NULL; } + PyObject *module = caller(); + if (module == NULL) { + Py_XDECREF(bound); + return NULL; + } - PyObject *tv = (PyObject *)typevarobject_alloc(name, bound, constraints, - covariant, contravariant, - autovariance); + PyObject *tv = (PyObject *)typevar_alloc(name, bound, constraints, + covariant, contravariant, + autovariance, module); Py_XDECREF(bound); return tv; } @@ -273,10 +303,6 @@ static PyMethodDef typevar_methods[] = { {0} }; -static PyNumberMethods typevar_as_number = { - .nb_or = make_union, -}; - PyDoc_STRVAR(typevar_doc, "Type variable.\n\ \n\ @@ -321,31 +347,36 @@ Type variables can be introspected. e.g.:\n\ Note that only type variables defined in global scope can be pickled.\n\ "); -PyTypeObject _PyTypeVar_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "typing.TypeVar", - .tp_basicsize = sizeof(typevarobject), - .tp_dealloc = typevarobject_dealloc, - .tp_alloc = PyType_GenericAlloc, - .tp_free = PyObject_GC_Del, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, - .tp_traverse = typevarobject_traverse, - .tp_repr = typevarobject_repr, - .tp_members = typevar_members, - .tp_methods = typevar_methods, - .tp_new = typevar_new, - .tp_as_number = &typevar_as_number, - .tp_doc = typevar_doc, +static PyType_Slot typevar_slots[] = { + {Py_tp_doc, (void *)typevar_doc}, + {Py_tp_methods, typevar_methods}, + {Py_nb_or, make_union}, + {Py_tp_new, typevar_new}, + {Py_tp_dealloc, typevar_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, typevar_traverse}, + {Py_tp_repr, typevar_repr}, + {Py_tp_members, typevar_members}, + {0, NULL}, +}; + +PyType_Spec typevar_spec = { + .name = "typing.TypeVar", + .basicsize = sizeof(typevarobject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE + | Py_TPFLAGS_MANAGED_DICT, + .slots = typevar_slots, }; typedef struct { PyObject_HEAD PyObject *__origin__; -} paramspecargsobject; +} paramspecattrobject; -static void paramspecargsobject_dealloc(PyObject *self) +static void paramspecattr_dealloc(PyObject *self) { - paramspecargsobject *psa = (paramspecargsobject *)self; + paramspecattrobject *psa = (paramspecattrobject *)self; _PyObject_GC_UNTRACK(self); @@ -354,47 +385,36 @@ static void paramspecargsobject_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } -static int paramspecargsobject_traverse(PyObject *self, visitproc visit, void *arg) +static int paramspecattr_traverse(PyObject *self, visitproc visit, void *arg) { - paramspecargsobject *psa = (paramspecargsobject *)self; + paramspecattrobject *psa = (paramspecattrobject *)self; Py_VISIT(psa->__origin__); return 0; } -static PyObject *paramspecargsobject_repr(PyObject *self) +static PyObject *paramspecattr_richcompare(PyObject *a, PyObject *b, int op) { - paramspecargsobject *psa = (paramspecargsobject *)self; - - if (Py_IS_TYPE(psa->__origin__, &_PyParamSpec_Type)) { - return PyUnicode_FromFormat("%s.args", - ((paramspecobject *)psa->__origin__)->name); - } - return PyUnicode_FromFormat("%R.args", psa->__origin__); -} - -static PyObject *paramspecargsobject_richcompare(PyObject *a, PyObject *b, int op) -{ - if (!Py_IS_TYPE(b, &_PyParamSpecArgs_Type)) { + if (!Py_IS_TYPE(a, Py_TYPE(b))) { Py_RETURN_NOTIMPLEMENTED; } if (op != Py_EQ && op != Py_NE) { Py_RETURN_NOTIMPLEMENTED; } return PyObject_RichCompare( - ((paramspecargsobject *)a)->__origin__, - ((paramspecargsobject *)b)->__origin__, + ((paramspecattrobject *)a)->__origin__, + ((paramspecattrobject *)b)->__origin__, op ); } -static PyMemberDef paramspecargs_members[] = { - {"__origin__", T_OBJECT, offsetof(paramspecargsobject, __origin__), READONLY}, +static PyMemberDef paramspecattr_members[] = { + {"__origin__", T_OBJECT, offsetof(paramspecattrobject, __origin__), READONLY}, {0} }; -static paramspecargsobject *paramspecargsobject_new(PyObject *origin) +static paramspecattrobject *paramspecattr_new(PyTypeObject *tp, PyObject *origin) { - paramspecargsobject *psa = PyObject_GC_New(paramspecargsobject, &_PyParamSpecArgs_Type); + paramspecattrobject *psa = PyObject_GC_New(paramspecattrobject, tp); if (psa == NULL) { return NULL; } @@ -403,6 +423,19 @@ static paramspecargsobject *paramspecargsobject_new(PyObject *origin) return psa; } +static PyObject *paramspecargs_repr(PyObject *self) +{ + paramspecattrobject *psa = (paramspecattrobject *)self; + + PyObject *tp = _PyInterpreterState_Get()->types.paramspec_type; + if (Py_IS_TYPE(psa->__origin__, (PyTypeObject *)tp)) { + return PyUnicode_FromFormat("%s.args", + ((paramspecobject *)psa->__origin__)->name); + } + return PyUnicode_FromFormat("%R.args", psa->__origin__); +} + + /*[clinic input] @classmethod paramspecargs.__new__ as paramspecargs_new @@ -416,7 +449,7 @@ static PyObject * paramspecargs_new_impl(PyTypeObject *type, PyObject *origin) /*[clinic end generated code: output=9a1463dc8942fe4e input=3596a0bb6183c208]*/ { - return (PyObject *)paramspecargsobject_new(origin); + return (PyObject *)paramspecattr_new(type, origin); } static PyObject * @@ -445,88 +478,39 @@ This type is meant for runtime introspection and has no special meaning to\n\ static type checkers.\n\ "); -PyTypeObject _PyParamSpecArgs_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "typing.ParamSpecArgs", - .tp_basicsize = sizeof(paramspecargsobject), - .tp_dealloc = paramspecargsobject_dealloc, - .tp_alloc = PyType_GenericAlloc, - .tp_free = PyObject_GC_Del, - .tp_repr = paramspecargsobject_repr, - .tp_richcompare = paramspecargsobject_richcompare, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, - .tp_traverse = paramspecargsobject_traverse, - .tp_members = paramspecargs_members, - .tp_methods = paramspecargs_methods, - .tp_new = paramspecargs_new, - .tp_doc = paramspecargs_doc, +static PyType_Slot paramspecargs_slots[] = { + {Py_tp_doc, (void *)paramspecargs_doc}, + {Py_tp_methods, paramspecargs_methods}, + {Py_tp_new, paramspecargs_new}, + {Py_tp_dealloc, paramspecattr_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, paramspecattr_traverse}, + {Py_tp_repr, paramspecargs_repr}, + {Py_tp_members, paramspecattr_members}, + {Py_tp_richcompare, paramspecattr_richcompare}, + {0, NULL}, }; -typedef struct { - PyObject_HEAD - PyObject *__origin__; -} paramspeckwargsobject; - -static void paramspeckwargsobject_dealloc(PyObject *self) -{ - paramspeckwargsobject *psk = (paramspeckwargsobject *)self; - - _PyObject_GC_UNTRACK(self); - - Py_XDECREF(psk->__origin__); - - Py_TYPE(self)->tp_free(self); -} - -static int paramspeckwargsobject_traverse(PyObject *self, visitproc visit, void *arg) -{ - paramspeckwargsobject *psk = (paramspeckwargsobject *)self; - Py_VISIT(psk->__origin__); - return 0; -} +PyType_Spec paramspecargs_spec = { + .name = "typing.ParamSpecArgs", + .basicsize = sizeof(paramspecattrobject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, + .slots = paramspecargs_slots, +}; -static PyObject *paramspeckwargsobject_repr(PyObject *self) +static PyObject *paramspeckwargs_repr(PyObject *self) { - paramspeckwargsobject *psk = (paramspeckwargsobject *)self; + paramspecattrobject *psk = (paramspecattrobject *)self; - if (Py_IS_TYPE(psk->__origin__, &_PyParamSpec_Type)) { + PyObject *tp = _PyInterpreterState_Get()->types.paramspec_type; + if (Py_IS_TYPE(psk->__origin__, (PyTypeObject *)tp)) { return PyUnicode_FromFormat("%s.kwargs", ((paramspecobject *)psk->__origin__)->name); } return PyUnicode_FromFormat("%R.kwargs", psk->__origin__); } -static PyObject *paramspeckwargsobject_richcompare(PyObject *a, PyObject *b, int op) -{ - if (!Py_IS_TYPE(b, &_PyParamSpecKwargs_Type)) { - Py_RETURN_NOTIMPLEMENTED; - } - if (op != Py_EQ && op != Py_NE) { - Py_RETURN_NOTIMPLEMENTED; - } - return PyObject_RichCompare( - ((paramspeckwargsobject *)a)->__origin__, - ((paramspeckwargsobject *)b)->__origin__, - op - ); -} - -static PyMemberDef paramspeckwargs_members[] = { - {"__origin__", T_OBJECT, offsetof(paramspeckwargsobject, __origin__), READONLY}, - {0} -}; - -static paramspeckwargsobject *paramspeckwargsobject_new(PyObject *origin) -{ - paramspeckwargsobject *psk = PyObject_GC_New(paramspeckwargsobject, &_PyParamSpecKwargs_Type); - if (psk == NULL) { - return NULL; - } - psk->__origin__ = Py_NewRef(origin); - _PyObject_GC_TRACK(psk); - return psk; -} - /*[clinic input] @classmethod paramspeckwargs.__new__ as paramspeckwargs_new @@ -540,7 +524,7 @@ static PyObject * paramspeckwargs_new_impl(PyTypeObject *type, PyObject *origin) /*[clinic end generated code: output=277b11967ebaf4ab input=981bca9b0cf9e40a]*/ { - return (PyObject *)paramspeckwargsobject_new(origin); + return (PyObject *)paramspecattr_new(type, origin); } static PyObject * @@ -569,24 +553,29 @@ This type is meant for runtime introspection and has no special meaning to\n\ static type checkers.\n\ "); -PyTypeObject _PyParamSpecKwargs_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "typing.ParamSpecKwargs", - .tp_basicsize = sizeof(paramspeckwargsobject), - .tp_dealloc = paramspeckwargsobject_dealloc, - .tp_alloc = PyType_GenericAlloc, - .tp_free = PyObject_GC_Del, - .tp_repr = paramspeckwargsobject_repr, - .tp_richcompare = paramspeckwargsobject_richcompare, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, - .tp_traverse = paramspeckwargsobject_traverse, - .tp_members = paramspeckwargs_members, - .tp_methods = paramspeckwargs_methods, - .tp_new = paramspeckwargs_new, - .tp_doc = paramspeckwargs_doc, +static PyType_Slot paramspeckwargs_slots[] = { + {Py_tp_doc, (void *)paramspeckwargs_doc}, + {Py_tp_methods, paramspeckwargs_methods}, + {Py_tp_new, paramspeckwargs_new}, + {Py_tp_dealloc, paramspecattr_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, paramspecattr_traverse}, + {Py_tp_repr, paramspeckwargs_repr}, + {Py_tp_members, paramspecattr_members}, + {Py_tp_richcompare, paramspecattr_richcompare}, + {0, NULL}, }; -static void paramspecobject_dealloc(PyObject *self) +PyType_Spec paramspeckwargs_spec = { + .name = "typing.ParamSpecKwargs", + .basicsize = sizeof(paramspecattrobject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, + .slots = paramspeckwargs_slots, +}; + +static void +paramspec_dealloc(PyObject *self) { paramspecobject *ps = (paramspecobject *)self; @@ -598,14 +587,16 @@ static void paramspecobject_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } -static int paramspecobject_traverse(PyObject *self, visitproc visit, void *arg) +static int +paramspec_traverse(PyObject *self, visitproc visit, void *arg) { paramspecobject *ps = (paramspecobject *)self; Py_VISIT(ps->bound); return 0; } -static PyObject *paramspecobject_repr(PyObject *self) +static PyObject * +paramspec_repr(PyObject *self) { paramspecobject *ps = (paramspecobject *)self; @@ -626,26 +617,32 @@ static PyMemberDef paramspec_members[] = { {0} }; -static PyObject *paramspecobject_args(PyObject *self, void *unused) +static PyObject * +paramspec_args(PyObject *self, void *unused) { - return (PyObject *)paramspecargsobject_new(self); + PyObject *tp = PyInterpreterState_Get()->types.paramspecargs_type; + return (PyObject *)paramspecattr_new((PyTypeObject *)tp, self); } -static PyObject *paramspecobject_kwargs(PyObject *self, void *unused) +static PyObject * +paramspec_kwargs(PyObject *self, void *unused) { - return (PyObject *)paramspeckwargsobject_new(self); + PyObject *tp = PyInterpreterState_Get()->types.paramspeckwargs_type; + return (PyObject *)paramspecattr_new((PyTypeObject *)tp, self); } static PyGetSetDef paramspec_getset[] = { - {"args", (getter)paramspecobject_args, NULL, "Represents positional arguments.", NULL}, - {"kwargs", (getter)paramspecobject_kwargs, NULL, "Represents keyword arguments.", NULL}, + {"args", (getter)paramspec_args, NULL, "Represents positional arguments.", NULL}, + {"kwargs", (getter)paramspec_kwargs, NULL, "Represents keyword arguments.", NULL}, {0}, }; -static paramspecobject *paramspecobject_alloc(const char *name, PyObject *bound, bool covariant, - bool contravariant, bool autovariance) +static paramspecobject * +paramspec_alloc(const char *name, PyObject *bound, bool covariant, + bool contravariant, bool autovariance, PyObject *module) { - paramspecobject *ps = PyObject_GC_New(paramspecobject, &_PyParamSpec_Type); + PyObject *tp = _PyInterpreterState_Get()->types.paramspec_type; + paramspecobject *ps = PyObject_GC_New(paramspecobject, (PyTypeObject *)tp); if (ps == NULL) { return NULL; } @@ -658,6 +655,9 @@ static paramspecobject *paramspecobject_alloc(const char *name, PyObject *bound, ps->covariant = covariant; ps->contravariant = contravariant; ps->autovariance = autovariance; + if (module != NULL) { + PyObject_SetAttrString((PyObject *)ps, "__module__", module); + } _PyObject_GC_TRACK(ps); return ps; } @@ -695,8 +695,13 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, return NULL; } } - PyObject *ps = (PyObject *)paramspecobject_alloc( - name, bound, covariant, contravariant, autovariance); + PyObject *module = caller(); + if (module == NULL) { + Py_XDECREF(bound); + return NULL; + } + PyObject *ps = (PyObject *)paramspec_alloc( + name, bound, covariant, contravariant, autovariance, module); Py_XDECREF(bound); return ps; } @@ -768,10 +773,6 @@ static PyMethodDef paramspec_methods[] = { {0} }; -static PyNumberMethods paramspec_as_number = { - .nb_or = make_union, -}; - PyDoc_STRVAR(paramspec_doc, "Parameter specification variable.\n\ \n\ @@ -818,26 +819,32 @@ Note that only parameter specification variables defined in global scope can\n\ be pickled.\n\ "); -PyTypeObject _PyParamSpec_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "typing.ParamSpec", - .tp_basicsize = sizeof(paramspecobject), - .tp_dealloc = paramspecobject_dealloc, - .tp_alloc = PyType_GenericAlloc, - .tp_free = PyObject_GC_Del, - .tp_repr = paramspecobject_repr, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE, - .tp_traverse = paramspecobject_traverse, - .tp_members = paramspec_members, - .tp_methods = paramspec_methods, - .tp_getset = paramspec_getset, - .tp_new = paramspec_new, - .tp_as_number = ¶mspec_as_number, - .tp_doc = paramspec_doc, +static PyType_Slot paramspec_slots[] = { + {Py_tp_doc, (void *)paramspec_doc}, + {Py_tp_members, paramspec_members}, + {Py_tp_methods, paramspec_methods}, + {Py_tp_getset, paramspec_getset}, + {Py_nb_or, make_union}, + {Py_tp_new, paramspec_new}, + {Py_tp_dealloc, paramspec_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, paramspec_traverse}, + {Py_tp_repr, paramspec_repr}, + {0, 0}, }; -static void typevartupleobject_dealloc(PyObject *self) +PyType_Spec paramspec_spec = { + .name = "typing.ParamSpec", + .basicsize = sizeof(paramspecobject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_IMMUTABLETYPE + | Py_TPFLAGS_MANAGED_DICT, + .slots = paramspec_slots, +}; + +static void typevartuple_dealloc(PyObject *self) { + _PyObject_GC_UNTRACK(self); typevartupleobject *tvt = (typevartupleobject *)self; free((void *)tvt->name); @@ -861,7 +868,7 @@ static PyObject *typevartuple_unpack(PyObject *tvt) return unpacked; } -static PyObject *typevartupleobject_iter(PyObject *self) +static PyObject *typevartuple_iter(PyObject *self) { PyObject *unpacked = typevartuple_unpack(self); if (unpacked == NULL) { @@ -878,7 +885,7 @@ static PyObject *typevartupleobject_iter(PyObject *self) return result; } -static PyObject *typevartupleobject_repr(PyObject *self) +static PyObject *typevartuple_repr(PyObject *self) { typevartupleobject *tvt = (typevartupleobject *)self; @@ -890,9 +897,10 @@ static PyMemberDef typevartuple_members[] = { {0} }; -static typevartupleobject *typevartupleobject_alloc(const char *name) +static typevartupleobject *typevartuple_alloc(const char *name, PyObject *module) { - typevartupleobject *tvt = PyObject_New(typevartupleobject, &_PyTypeVarTuple_Type); + PyObject *tp = _PyInterpreterState_Get()->types.typevartuple_type; + typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, (PyTypeObject *)tp); if (tvt == NULL) { return NULL; } @@ -901,6 +909,10 @@ static typevartupleobject *typevartupleobject_alloc(const char *name) Py_DECREF(tvt); return NULL; } + if (module != NULL) { + PyObject_SetAttrString((PyObject *)tvt, "__module__", module); + } + _PyObject_GC_TRACK(tvt); return tvt; } @@ -917,7 +929,11 @@ static PyObject * typevartuple_impl(PyTypeObject *type, const char *name) /*[clinic end generated code: output=a5a5bc3437a27749 input=d89424a0e967cee6]*/ { - return (PyObject *)typevartupleobject_alloc(name); + PyObject *module = caller(); + if (module == NULL) { + return NULL; + } + return (PyObject *)typevartuple_alloc(name, module); } /*[clinic input] @@ -975,6 +991,12 @@ typevartuple_mro_entries(PyObject *self, PyObject *args) return NULL; } +static int +typevartuple_traverse(typevartupleobject *o, visitproc visit, void *arg) +{ + return 0; +} + static PyMethodDef typevartuple_methods[] = { TYPEVARTUPLE_TYPING_SUBST_METHODDEF TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF @@ -1008,35 +1030,45 @@ For more details, see PEP 646.\n\ Note that only TypeVarTuples defined in global scope can be pickled.\n\ "); -PyTypeObject _PyTypeVarTuple_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "typing.TypeVarTuple", - .tp_basicsize = sizeof(typevartupleobject), - .tp_dealloc = typevartupleobject_dealloc, - .tp_alloc = PyType_GenericAlloc, - .tp_iter = typevartupleobject_iter, - .tp_repr = typevartupleobject_repr, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE, - .tp_members = typevartuple_members, - .tp_methods = typevartuple_methods, - .tp_new = typevartuple, - .tp_doc = typevartuple_doc, +PyType_Slot typevartuple_slots[] = { + {Py_tp_doc, (void *)typevartuple_doc}, + {Py_tp_members, typevartuple_members}, + {Py_tp_methods, typevartuple_methods}, + {Py_tp_new, typevartuple}, + {Py_tp_iter, typevartuple_iter}, + {Py_tp_repr, typevartuple_repr}, + {Py_tp_dealloc, typevartuple_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, typevartuple_traverse}, + {0, 0}, +}; + +PyType_Spec typevartuple_spec = { + .name = "typing.TypeVarTuple", + .basicsize = sizeof(typevartupleobject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_MANAGED_DICT + | Py_TPFLAGS_HAVE_GC, + .slots = typevartuple_slots, }; -PyObject *_Py_make_typevar(const char *name, PyObject *bound_or_constraints) { +PyObject * +_Py_make_typevar(const char *name, PyObject *bound_or_constraints) { if (bound_or_constraints != NULL && PyTuple_CheckExact(bound_or_constraints)) { - return (PyObject *)typevarobject_alloc(name, NULL, bound_or_constraints, false, false, true); + return (PyObject *)typevar_alloc(name, NULL, bound_or_constraints, false, false, true, NULL); } else { - return (PyObject *)typevarobject_alloc(name, bound_or_constraints, NULL, false, false, true); + return (PyObject *)typevar_alloc(name, bound_or_constraints, NULL, false, false, true, NULL); } } -PyObject *_Py_make_paramspec(const char *name) { - return (PyObject *)paramspecobject_alloc(name, NULL, false, false, true); +PyObject * +_Py_make_paramspec(const char *name) { + return (PyObject *)paramspec_alloc(name, NULL, false, false, true, NULL); } -PyObject *_Py_make_typevartuple(const char *name) { - return (PyObject *)typevartupleobject_alloc(name); +PyObject * +_Py_make_typevartuple(const char *name) { + return (PyObject *)typevartuple_alloc(name, NULL); } static void @@ -1067,8 +1099,8 @@ static PyMemberDef typealias_members[] = { static typealiasobject * typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) { - typealiasobject *ta = (typealiasobject *)_PyTypeAlias_Type.tp_alloc( - &_PyTypeAlias_Type, 0); + PyObject *tp = PyInterpreterState_Get()->types.typealias_type; + typealiasobject *ta = PyObject_GC_New(typealiasobject, (PyTypeObject *)tp); if (ta == NULL) { return NULL; } @@ -1080,6 +1112,7 @@ typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value ta->type_params = Py_XNewRef(type_params); ta->compute_value = Py_NewRef(compute_value); ta->value = NULL; + _PyObject_GC_TRACK(ta); return ta; } @@ -1117,19 +1150,23 @@ Type aliases are created through the type statement:\n\ type Alias = int\n\ "); -PyTypeObject _PyTypeAlias_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - .tp_name = "TypeAlias", - .tp_basicsize = sizeof(typealiasobject), - .tp_dealloc = typealias_dealloc, - .tp_alloc = PyType_GenericAlloc, - .tp_free = PyObject_GC_Del, - .tp_repr = typealias_repr, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC, - .tp_members = typealias_members, - .tp_methods = typealias_methods, - .tp_doc = typealias_doc, - .tp_traverse = (traverseproc)typealias_traverse, +static PyType_Slot typealias_slots[] = { + {Py_tp_doc, (void *)typealias_doc}, + {Py_tp_members, typealias_members}, + {Py_tp_methods, typealias_methods}, + {Py_tp_dealloc, typealias_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, (traverseproc)typealias_traverse}, + {Py_tp_repr, typealias_repr}, + {0, 0}, +}; + +PyType_Spec typealias_spec = { + .name = "typing.TypeAlias", + .basicsize = sizeof(typealiasobject), + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC, + .slots = typealias_slots, }; PyObject * @@ -1231,9 +1268,10 @@ static int contains_typevartuple(PyTupleObject *params) { Py_ssize_t n = PyTuple_GET_SIZE(params); + PyObject *tp = PyInterpreterState_Get()->types.typevartuple_type; for (Py_ssize_t i = 0; i < n; i++) { PyObject *param = PyTuple_GET_ITEM(params, i); - if (Py_TYPE(param) == &_PyTypeVarTuple_Type) { + if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { return 1; } } @@ -1248,9 +1286,10 @@ _Py_subscript_generic(PyObject *params) if (contains_typevartuple((PyTupleObject *)params)) { Py_ssize_t n = PyTuple_GET_SIZE(params); PyObject *new_params = PyTuple_New(n); + PyObject *tp = PyInterpreterState_Get()->types.typevartuple_type; for (Py_ssize_t i = 0; i < n; i++) { PyObject *param = PyTuple_GET_ITEM(params, i); - if (Py_TYPE(param) == &_PyTypeVarTuple_Type) { + if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { PyObject *unpacked = typevartuple_unpack(param); if (unpacked == NULL) { Py_DECREF(new_params); @@ -1308,10 +1347,33 @@ PyType_Spec generic_spec = { int _Py_initialize_generic(PyInterpreterState *interp) { - PyObject *type = PyType_FromSpec(&generic_spec); - if (type == NULL) { - return -1; - } - interp->types.generic_type = type; +#define MAKE_TYPE(name) \ + do { \ + PyObject *name ## _type = PyType_FromSpec(&name ## _spec); \ + if (name ## _type == NULL) { \ + return -1; \ + } \ + interp->types.name ## _type = name ## _type; \ + } while(0) + + MAKE_TYPE(generic); + MAKE_TYPE(typevar); + MAKE_TYPE(typevartuple); + MAKE_TYPE(paramspec); + MAKE_TYPE(paramspecargs); + MAKE_TYPE(paramspeckwargs); + MAKE_TYPE(typealias); +#undef MAKE_TYPE return 0; } + +void _Py_clear_generic_types(PyInterpreterState *interp) +{ + Py_CLEAR(interp->types.generic_type); + Py_CLEAR(interp->types.typevar_type); + Py_CLEAR(interp->types.typevartuple_type); + Py_CLEAR(interp->types.paramspec_type); + Py_CLEAR(interp->types.paramspecargs_type); + Py_CLEAR(interp->types.paramspeckwargs_type); + Py_CLEAR(interp->types.typealias_type); +} diff --git a/Objects/unionobject.c b/Objects/unionobject.c index b84c9b8ecedd94..5bc639316478df 100644 --- a/Objects/unionobject.c +++ b/Objects/unionobject.c @@ -151,9 +151,7 @@ is_unionable(PyObject *obj) return (obj == Py_None || PyType_Check(obj) || _PyGenericAlias_Check(obj) || - _PyUnion_Check(obj) || - Py_IS_TYPE(obj, &_PyTypeVar_Type) || - Py_IS_TYPE(obj, &_PyParamSpec_Type)); + _PyUnion_Check(obj)); } PyObject * diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 3eb2b04e52972f..28b5680e9c27e2 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3092,10 +3092,6 @@ _PyBuiltin_Init(PyInterpreterState *interp) SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type); SETBUILTIN("zip", &PyZip_Type); - // TODO these shouldn't be builtins, remove when PEP 695 is fully implemented - SETBUILTIN("TypeVar", &_PyTypeVar_Type); - SETBUILTIN("TypeVarTuple", &_PyTypeVarTuple_Type); - SETBUILTIN("ParamSpec", &_PyParamSpec_Type); debug = PyBool_FromLong(config->optimization_level == 0); if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { Py_DECREF(debug); diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index a07e41044d28d8..4e0e7a31d2c079 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -28,6 +28,7 @@ #include "pycore_traceback.h" // _Py_DumpTracebackThreads() #include "pycore_tuple.h" // _PyTuple_InitTypes() #include "pycore_typeobject.h" // _PyTypes_InitTypes() +#include "pycore_typevarobject.h" // _Py_clear_generic_types() #include "pycore_unicodeobject.h" // _PyUnicode_InitTypes() #include "opcode.h" @@ -1697,7 +1698,7 @@ finalize_interp_clear(PyThreadState *tstate) int is_main_interp = _Py_IsMainInterpreter(tstate->interp); _PyExc_ClearExceptionGroupType(tstate->interp); - Py_CLEAR(tstate->interp->types.generic_type); + _Py_clear_generic_types(tstate->interp); /* Clear interpreter state and all thread states */ _PyInterpreterState_Clear(tstate); From 308c7c172c679f5fa8ec78319f4be01b140867f1 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 17:11:52 -0600 Subject: [PATCH 072/200] Fix GC --- Objects/typevarobject.c | 78 +++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 24737f12b821b9..99d85955d02143 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -76,7 +76,9 @@ static PyObject *type_check(PyObject *arg) { if (args == NULL) { return NULL; } - return call_typing_func_object("_type_check", args); + PyObject *result = call_typing_func_object("_type_check", args); + Py_DECREF(args); + return result; } static PyObject * @@ -85,7 +87,9 @@ make_union(PyObject *self, PyObject *other) { if (args == NULL) { return NULL; } - return call_typing_func_object("_make_union", args); + PyObject *result = call_typing_func_object("_make_union", args); + Py_DECREF(args); + return result; } static PyObject * @@ -109,6 +113,7 @@ caller(void) static void typevar_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); typevarobject *tv = (typevarobject *)self; _PyObject_GC_UNTRACK(self); @@ -116,16 +121,20 @@ typevar_dealloc(PyObject *self) free((void *)tv->name); Py_XDECREF(tv->bound); Py_XDECREF(tv->constraints); + _PyObject_ClearManagedDict(self); Py_TYPE(self)->tp_free(self); + Py_DecRef(tp); } static int typevar_traverse(PyObject *self, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(self)); typevarobject *tv = (typevarobject *)self; Py_VISIT(tv->bound); Py_VISIT(tv->constraints); + _PyObject_VisitManagedDict(self, visit, arg); return 0; } @@ -255,6 +264,7 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, covariant, contravariant, autovariance, module); Py_XDECREF(bound); + Py_XDECREF(module); return tv; } @@ -273,7 +283,9 @@ typevar_typing_subst_impl(typevarobject *self, PyObject *arg) if (args == NULL) { return NULL; } - return call_typing_func_object("_typevar_subst", args); + PyObject *result = call_typing_func_object("_typevar_subst", args); + Py_DECREF(args); + return result; } /*[clinic input] @@ -374,7 +386,8 @@ typedef struct { PyObject *__origin__; } paramspecattrobject; -static void paramspecattr_dealloc(PyObject *self) +static void +paramspecattr_dealloc(PyObject *self) { paramspecattrobject *psa = (paramspecattrobject *)self; @@ -385,14 +398,16 @@ static void paramspecattr_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } -static int paramspecattr_traverse(PyObject *self, visitproc visit, void *arg) +static int +paramspecattr_traverse(PyObject *self, visitproc visit, void *arg) { paramspecattrobject *psa = (paramspecattrobject *)self; Py_VISIT(psa->__origin__); return 0; } -static PyObject *paramspecattr_richcompare(PyObject *a, PyObject *b, int op) +static PyObject * +paramspecattr_richcompare(PyObject *a, PyObject *b, int op) { if (!Py_IS_TYPE(a, Py_TYPE(b))) { Py_RETURN_NOTIMPLEMENTED; @@ -412,7 +427,8 @@ static PyMemberDef paramspecattr_members[] = { {0} }; -static paramspecattrobject *paramspecattr_new(PyTypeObject *tp, PyObject *origin) +static paramspecattrobject * +paramspecattr_new(PyTypeObject *tp, PyObject *origin) { paramspecattrobject *psa = PyObject_GC_New(paramspecattrobject, tp); if (psa == NULL) { @@ -423,7 +439,8 @@ static paramspecattrobject *paramspecattr_new(PyTypeObject *tp, PyObject *origin return psa; } -static PyObject *paramspecargs_repr(PyObject *self) +static PyObject * +paramspecargs_repr(PyObject *self) { paramspecattrobject *psa = (paramspecattrobject *)self; @@ -577,21 +594,26 @@ PyType_Spec paramspeckwargs_spec = { static void paramspec_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); paramspecobject *ps = (paramspecobject *)self; _PyObject_GC_UNTRACK(self); free((void *)ps->name); Py_XDECREF(ps->bound); + _PyObject_ClearManagedDict(self); Py_TYPE(self)->tp_free(self); + Py_DECREF(tp); } static int paramspec_traverse(PyObject *self, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(self)); paramspecobject *ps = (paramspecobject *)self; Py_VISIT(ps->bound); + _PyObject_VisitManagedDict(self, visit, arg); return 0; } @@ -703,6 +725,7 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, PyObject *ps = (PyObject *)paramspec_alloc( name, bound, covariant, contravariant, autovariance, module); Py_XDECREF(bound); + Py_DECREF(module); return ps; } @@ -722,7 +745,9 @@ paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg) if (args == NULL) { return NULL; } - return call_typing_func_object("_paramspec_subst", args); + PyObject *result = call_typing_func_object("_paramspec_subst", args); + Py_DECREF(args); + return result; } /*[clinic input] @@ -742,7 +767,9 @@ paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias, if (args_tuple == NULL) { return NULL; } - return call_typing_func_object("_paramspec_prepare_subst", args_tuple); + PyObject *result = call_typing_func_object("_paramspec_prepare_subst", args_tuple); + Py_DECREF(args_tuple); + return result; } /*[clinic input] @@ -842,16 +869,22 @@ PyType_Spec paramspec_spec = { .slots = paramspec_slots, }; -static void typevartuple_dealloc(PyObject *self) +static void +typevartuple_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); _PyObject_GC_UNTRACK(self); typevartupleobject *tvt = (typevartupleobject *)self; free((void *)tvt->name); + _PyObject_ClearManagedDict(self); + Py_TYPE(self)->tp_free(self); + Py_DECREF(tp); } -static PyObject *typevartuple_unpack(PyObject *tvt) +static PyObject * +typevartuple_unpack(PyObject *tvt) { PyObject *typing = PyImport_ImportModule("typing"); if (typing == NULL) { @@ -868,7 +901,8 @@ static PyObject *typevartuple_unpack(PyObject *tvt) return unpacked; } -static PyObject *typevartuple_iter(PyObject *self) +static PyObject * +typevartuple_iter(PyObject *self) { PyObject *unpacked = typevartuple_unpack(self); if (unpacked == NULL) { @@ -885,7 +919,8 @@ static PyObject *typevartuple_iter(PyObject *self) return result; } -static PyObject *typevartuple_repr(PyObject *self) +static PyObject * +typevartuple_repr(PyObject *self) { typevartupleobject *tvt = (typevartupleobject *)self; @@ -897,7 +932,8 @@ static PyMemberDef typevartuple_members[] = { {0} }; -static typevartupleobject *typevartuple_alloc(const char *name, PyObject *module) +static typevartupleobject * +typevartuple_alloc(const char *name, PyObject *module) { PyObject *tp = _PyInterpreterState_Get()->types.typevartuple_type; typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, (PyTypeObject *)tp); @@ -933,7 +969,9 @@ typevartuple_impl(PyTypeObject *type, const char *name) if (module == NULL) { return NULL; } - return (PyObject *)typevartuple_alloc(name, module); + PyObject *result = (PyObject *)typevartuple_alloc(name, module); + Py_DECREF(module); + return result; } /*[clinic input] @@ -968,7 +1006,9 @@ typevartuple_typing_prepare_subst_impl(typevartupleobject *self, if (args_tuple == NULL) { return NULL; } - return call_typing_func_object("_typevartuple_prepare_subst", args_tuple); + PyObject *result = call_typing_func_object("_typevartuple_prepare_subst", args_tuple); + Py_DECREF(args_tuple); + return result; } /*[clinic input] @@ -992,8 +1032,10 @@ typevartuple_mro_entries(PyObject *self, PyObject *args) } static int -typevartuple_traverse(typevartupleobject *o, visitproc visit, void *arg) +typevartuple_traverse(PyObject *self, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(self)); + _PyObject_VisitManagedDict(self, visit, arg); return 0; } From c4ce394b67a6603dbcfee3fbd207c47250042ac9 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 17:54:35 -0600 Subject: [PATCH 073/200] Self-review - Use the right name for the new TypeVar attribute (infer_variance, not autovariance) - Simpler intrinsics (avoid some wrapper functions) - Undo some unnecessary changes - Consistent styling of function declarations --- .../pycore_global_objects_fini_generated.h | 2 +- Include/internal/pycore_global_strings.h | 2 +- .../internal/pycore_runtime_init_generated.h | 2 +- Include/internal/pycore_typevarobject.h | 8 +- .../internal/pycore_unicodeobject_generated.h | 6 +- Objects/clinic/typevarobject.c.h | 34 ++++---- Objects/funcobject.c | 3 +- Objects/typeobject.c | 7 +- Objects/typevarobject.c | 84 +++++++++++-------- Objects/unionobject.c | 1 - Python/bltinmodule.c | 1 - Python/intrinsics.c | 26 +----- Python/symtable.c | 12 +-- Tools/c-analyzer/cpython/globals-to-fix.tsv | 6 -- 14 files changed, 85 insertions(+), 109 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 7d9bf1f447ebd2..b5d434886c696e 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -795,7 +795,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(attribute)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(authorizer_callback)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autocommit)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(autovariance)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(b)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(backtick)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(base)); @@ -972,6 +971,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(incoming)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(indexgroup)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(inf)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(infer_variance)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(inheritable)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(initial_bytes)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index fa6e8281ae41bd..9dc1f53bb9e22d 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -283,7 +283,6 @@ struct _Py_global_strings { STRUCT_FOR_ID(attribute) STRUCT_FOR_ID(authorizer_callback) STRUCT_FOR_ID(autocommit) - STRUCT_FOR_ID(autovariance) STRUCT_FOR_ID(b) STRUCT_FOR_ID(backtick) STRUCT_FOR_ID(base) @@ -460,6 +459,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(incoming) STRUCT_FOR_ID(indexgroup) STRUCT_FOR_ID(inf) + STRUCT_FOR_ID(infer_variance) STRUCT_FOR_ID(inheritable) STRUCT_FOR_ID(initial) STRUCT_FOR_ID(initial_bytes) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index ba5bcd58a90845..f6990ed3bc1266 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -789,7 +789,6 @@ extern "C" { INIT_ID(attribute), \ INIT_ID(authorizer_callback), \ INIT_ID(autocommit), \ - INIT_ID(autovariance), \ INIT_ID(b), \ INIT_ID(backtick), \ INIT_ID(base), \ @@ -966,6 +965,7 @@ extern "C" { INIT_ID(incoming), \ INIT_ID(indexgroup), \ INIT_ID(inf), \ + INIT_ID(infer_variance), \ INIT_ID(inheritable), \ INIT_ID(initial), \ INIT_ID(initial_bytes), \ diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index c02f0fe477dcb9..9e8b175ad231fc 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -9,10 +9,10 @@ extern "C" { #endif extern PyObject *_Py_make_typevar(const char *, PyObject *); -extern PyObject *_Py_make_paramspec(const char *); -extern PyObject *_Py_make_typevartuple(const char *); -extern PyObject *_Py_make_typealias(PyThreadState* unused, PyObject *); -extern PyObject *_Py_subscript_generic(PyObject *); +extern PyObject *_Py_make_paramspec(PyThreadState *, PyObject *); +extern PyObject *_Py_make_typevartuple(PyThreadState *, PyObject *); +extern PyObject *_Py_make_typealias(PyThreadState *, PyObject *); +extern PyObject *_Py_subscript_generic(PyThreadState *, PyObject *); extern int _Py_initialize_generic(PyInterpreterState *); extern void _Py_clear_generic_types(PyInterpreterState *); diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index c277982fe3ba09..e4fc8680f0bf99 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -687,9 +687,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(autocommit); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); - string = &_Py_ID(autovariance); - assert(_PyUnicode_CheckConsistency(string, 1)); - _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(b); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); @@ -1218,6 +1215,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(inf); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(infer_variance); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(inheritable); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index c4a8709951953d..f677d208cff898 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -10,7 +10,7 @@ preserve PyDoc_STRVAR(typevar_new__doc__, "typevar(name, *constraints, *, bound=None, covariant=False,\n" -" contravariant=False, autovariance=False)\n" +" contravariant=False, infer_variance=False)\n" "--\n" "\n" "Create a TypeVar."); @@ -18,7 +18,7 @@ PyDoc_STRVAR(typevar_new__doc__, static PyObject * typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, PyObject *bound, int covariant, int contravariant, - int autovariance); + int infer_variance); static PyObject * typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) @@ -33,7 +33,7 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) - .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(infer_variance), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -42,7 +42,7 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "autovariance", NULL}; + static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "infer_variance", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, .fname = "typevar", @@ -58,7 +58,7 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *bound = Py_None; int covariant = 0; int contravariant = 0; - int autovariance = 0; + int infer_variance = 0; fastargs = _PyArg_UnpackKeywordsWithVararg(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, 1, argsbuf); if (!fastargs) { @@ -105,12 +105,12 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto skip_optional_kwonly; } } - autovariance = PyObject_IsTrue(fastargs[5]); - if (autovariance < 0) { + infer_variance = PyObject_IsTrue(fastargs[5]); + if (infer_variance < 0) { goto exit; } skip_optional_kwonly: - return_value = typevar_new_impl(type, name, constraints, bound, covariant, contravariant, autovariance); + return_value = typevar_new_impl(type, name, constraints, bound, covariant, contravariant, infer_variance); exit: Py_XDECREF(constraints); @@ -298,14 +298,14 @@ paramspeckwargs_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyDoc_STRVAR(paramspec_new__doc__, "paramspec(name, *, bound=None, covariant=False, contravariant=False,\n" -" autovariance=False)\n" +" infer_variance=False)\n" "--\n" "\n" "Create a ParamSpec object."); static PyObject * paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, - int covariant, int contravariant, int autovariance); + int covariant, int contravariant, int infer_variance); static PyObject * paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) @@ -320,7 +320,7 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *ob_item[NUM_KEYWORDS]; } _kwtuple = { .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) - .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(autovariance), }, + .ob_item = { &_Py_ID(name), &_Py_ID(bound), &_Py_ID(covariant), &_Py_ID(contravariant), &_Py_ID(infer_variance), }, }; #undef NUM_KEYWORDS #define KWTUPLE (&_kwtuple.ob_base.ob_base) @@ -329,7 +329,7 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) # define KWTUPLE NULL #endif // !Py_BUILD_CORE - static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "autovariance", NULL}; + static const char * const _keywords[] = {"name", "bound", "covariant", "contravariant", "infer_variance", NULL}; static _PyArg_Parser _parser = { .keywords = _keywords, .fname = "paramspec", @@ -344,7 +344,7 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *bound = Py_None; int covariant = 0; int contravariant = 0; - int autovariance = 0; + int infer_variance = 0; fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); if (!fastargs) { @@ -390,12 +390,12 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto skip_optional_kwonly; } } - autovariance = PyObject_IsTrue(fastargs[4]); - if (autovariance < 0) { + infer_variance = PyObject_IsTrue(fastargs[4]); + if (infer_variance < 0) { goto exit; } skip_optional_kwonly: - return_value = paramspec_new_impl(type, name, bound, covariant, contravariant, autovariance); + return_value = paramspec_new_impl(type, name, bound, covariant, contravariant, infer_variance); exit: return return_value; @@ -739,4 +739,4 @@ typealias_reduce(typealiasobject *self, PyObject *Py_UNUSED(ignored)) { return typealias_reduce_impl(self); } -/*[clinic end generated code: output=92385d7cbb5c1b03 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=468f0011fd3e47d8 input=a9049054013a1b77]*/ diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 0a0e2bbb5caa24..c17a12753357f0 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -662,8 +662,7 @@ func_get_type_variables(PyFunctionObject *op, void *Py_UNUSED(ignored)) } assert(PyTuple_Check(op->func_typevars)); - Py_XINCREF(op->func_typevars); - return op->func_typevars; + return Py_NewRef(op->func_typevars); } static PyGetSetDef func_getsetlist[] = { diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 6f6e623c0ff8ce..b9541d2f4dfbb4 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1146,13 +1146,10 @@ type_get_annotations(PyTypeObject *type, void *context) static PyObject * type_get_type_variables(PyTypeObject *type, void *context) { - PyObject *params; + PyObject *params = PyDict_GetItem(type->tp_dict, &_Py_ID(__type_variables__)); - params = PyDict_GetItem(type->tp_dict, &_Py_ID(__type_variables__)); - if (params) { - Py_INCREF(params); - return params; + return Py_NewRef(params); } return PyTuple_New(0); diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index e2479f86274a31..83705416292099 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -23,7 +23,7 @@ typedef struct { PyObject *constraints; bool covariant; bool contravariant; - bool autovariance; + bool infer_variance; } typevarobject; typedef struct { @@ -37,7 +37,7 @@ typedef struct { PyObject *bound; bool covariant; bool contravariant; - bool autovariance; + bool infer_variance; } paramspecobject; typedef struct { @@ -50,7 +50,9 @@ typedef struct { #include "clinic/typevarobject.c.h" -static PyObject *call_typing_func_object(const char *name, PyObject *args) { +static PyObject * +call_typing_func_object(const char *name, PyObject *args) +{ PyObject *typing = PyImport_ImportModule("typing"); if (typing == NULL) { return NULL; @@ -66,7 +68,9 @@ static PyObject *call_typing_func_object(const char *name, PyObject *args) { return result; } -static PyObject *type_check(PyObject *arg) { +static PyObject * +type_check(PyObject *arg) +{ // Calling typing.py here leads to bootstrapping problems if (Py_IsNone(arg)) { return Py_NewRef(Py_TYPE(arg)); @@ -82,7 +86,8 @@ static PyObject *type_check(PyObject *arg) { } static PyObject * -make_union(PyObject *self, PyObject *other) { +make_union(PyObject *self, PyObject *other) +{ PyObject *args = PyTuple_Pack(2, self, other); if (args == NULL) { return NULL; @@ -138,11 +143,12 @@ typevar_traverse(PyObject *self, visitproc visit, void *arg) return 0; } -static PyObject *typevar_repr(PyObject *self) +static PyObject * +typevar_repr(PyObject *self) { typevarobject *tv = (typevarobject *)self; - if (tv->autovariance) { + if (tv->infer_variance) { return PyUnicode_FromFormat("%s", tv->name); } @@ -156,14 +162,14 @@ static PyMemberDef typevar_members[] = { {"__constraints__", T_OBJECT, offsetof(typevarobject, constraints), READONLY}, {"__covariant__", T_BOOL, offsetof(typevarobject, covariant), READONLY}, {"__contravariant__", T_BOOL, offsetof(typevarobject, contravariant), READONLY}, - {"__autovariance__", T_BOOL, offsetof(typevarobject, autovariance), READONLY}, + {"__infer_variance__", T_BOOL, offsetof(typevarobject, infer_variance), READONLY}, {0} }; -static typevarobject *typevar_alloc(const char *name, PyObject *bound, - PyObject *constraints, - bool covariant, bool contravariant, - bool autovariance, PyObject *module) +static typevarobject * +typevar_alloc(const char *name, PyObject *bound, PyObject *constraints, + bool covariant, bool contravariant, bool infer_variance, + PyObject *module) { PyObject *tp = PyInterpreterState_Get()->cached_objects.typevar_type; assert(tp != NULL); @@ -183,7 +189,7 @@ static typevarobject *typevar_alloc(const char *name, PyObject *bound, tv->covariant = covariant; tv->contravariant = contravariant; - tv->autovariance = autovariance; + tv->infer_variance = infer_variance; if (module != NULL) { PyObject_SetAttrString((PyObject *)tv, "__module__", module); } @@ -202,7 +208,7 @@ typevar.__new__ as typevar_new bound: object = None covariant: bool = False contravariant: bool = False - autovariance: bool = False + infer_variance: bool = False Create a TypeVar. [clinic start generated code]*/ @@ -210,8 +216,8 @@ Create a TypeVar. static PyObject * typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, PyObject *bound, int covariant, int contravariant, - int autovariance) -/*[clinic end generated code: output=e74ea8371ab8103a input=9d08a995b997a11b]*/ + int infer_variance) +/*[clinic end generated code: output=463d42203b82ea59 input=55a3db20c1cf1450]*/ { if (covariant && contravariant) { PyErr_SetString(PyExc_ValueError, @@ -219,9 +225,9 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, return NULL; } - if (autovariance && (covariant || contravariant)) { + if (infer_variance && (covariant || contravariant)) { PyErr_SetString(PyExc_ValueError, - "Variance cannot be specified with autovariance."); + "Variance cannot be specified with infer_variance."); return NULL; } @@ -262,7 +268,7 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, PyObject *tv = (PyObject *)typevar_alloc(name, bound, constraints, covariant, contravariant, - autovariance, module); + infer_variance, module); Py_XDECREF(bound); Py_XDECREF(module); return tv; @@ -516,7 +522,8 @@ PyType_Spec paramspecargs_spec = { .slots = paramspecargs_slots, }; -static PyObject *paramspeckwargs_repr(PyObject *self) +static PyObject * +paramspeckwargs_repr(PyObject *self) { paramspecattrobject *psk = (paramspecattrobject *)self; @@ -622,7 +629,7 @@ paramspec_repr(PyObject *self) { paramspecobject *ps = (paramspecobject *)self; - if (ps->autovariance) { + if (ps->infer_variance) { return PyUnicode_FromFormat("%s", ps->name); } @@ -635,7 +642,7 @@ static PyMemberDef paramspec_members[] = { {"__bound__", T_OBJECT, offsetof(paramspecobject, bound), READONLY}, {"__covariant__", T_BOOL, offsetof(paramspecobject, covariant), READONLY}, {"__contravariant__", T_BOOL, offsetof(paramspecobject, contravariant), READONLY}, - {"__autovariance__", T_BOOL, offsetof(paramspecobject, autovariance), READONLY}, + {"__infer_variance__", T_BOOL, offsetof(paramspecobject, infer_variance), READONLY}, {0} }; @@ -661,7 +668,7 @@ static PyGetSetDef paramspec_getset[] = { static paramspecobject * paramspec_alloc(const char *name, PyObject *bound, bool covariant, - bool contravariant, bool autovariance, PyObject *module) + bool contravariant, bool infer_variance, PyObject *module) { PyObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; paramspecobject *ps = PyObject_GC_New(paramspecobject, (PyTypeObject *)tp); @@ -676,7 +683,7 @@ paramspec_alloc(const char *name, PyObject *bound, bool covariant, ps->bound = Py_XNewRef(bound); ps->covariant = covariant; ps->contravariant = contravariant; - ps->autovariance = autovariance; + ps->infer_variance = infer_variance; if (module != NULL) { PyObject_SetAttrString((PyObject *)ps, "__module__", module); } @@ -693,22 +700,22 @@ paramspec.__new__ as paramspec_new bound: object = None covariant: bool = False contravariant: bool = False - autovariance: bool = False + infer_variance: bool = False Create a ParamSpec object. [clinic start generated code]*/ static PyObject * paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, - int covariant, int contravariant, int autovariance) -/*[clinic end generated code: output=d1693f0a5be7d69d input=09c84e07c5c0722e]*/ + int covariant, int contravariant, int infer_variance) +/*[clinic end generated code: output=846484852fb0dda8 input=f83ea6382c481f21]*/ { if (covariant && contravariant) { PyErr_SetString(PyExc_ValueError, "Bivariant types are not supported."); return NULL; } - if (autovariance && (covariant || contravariant)) { - PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with autovariance."); + if (infer_variance && (covariant || contravariant)) { + PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with infer_variance."); return NULL; } if (bound != NULL) { @@ -723,7 +730,7 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, return NULL; } PyObject *ps = (PyObject *)paramspec_alloc( - name, bound, covariant, contravariant, autovariance, module); + name, bound, covariant, contravariant, infer_variance, module); Py_XDECREF(bound); Py_DECREF(module); return ps; @@ -1095,7 +1102,8 @@ PyType_Spec typevartuple_spec = { }; PyObject * -_Py_make_typevar(const char *name, PyObject *bound_or_constraints) { +_Py_make_typevar(const char *name, PyObject *bound_or_constraints) +{ if (bound_or_constraints != NULL && PyTuple_CheckExact(bound_or_constraints)) { return (PyObject *)typevar_alloc(name, NULL, bound_or_constraints, false, false, true, NULL); } else { @@ -1104,13 +1112,17 @@ _Py_make_typevar(const char *name, PyObject *bound_or_constraints) { } PyObject * -_Py_make_paramspec(const char *name) { - return (PyObject *)paramspec_alloc(name, NULL, false, false, true, NULL); +_Py_make_paramspec(PyThreadState *unused, PyObject *v) +{ + assert(PyUnicode_Check(v)); + return (PyObject *)paramspec_alloc(PyUnicode_AsUTF8(v), NULL, false, false, true, NULL); } PyObject * -_Py_make_typevartuple(const char *name) { - return (PyObject *)typevartuple_alloc(name, NULL); +_Py_make_typevartuple(PyThreadState *unused, PyObject *v) +{ + assert(PyUnicode_Check(v)); + return (PyObject *)typevartuple_alloc(PyUnicode_AsUTF8(v), NULL); } static void @@ -1321,7 +1333,7 @@ contains_typevartuple(PyTupleObject *params) } PyObject * -_Py_subscript_generic(PyObject *params) +_Py_subscript_generic(PyThreadState* unused, PyObject *params) { assert(PyTuple_Check(params)); // TypeVarTuple must be unpacked when passed to Generic, so we do that here. diff --git a/Objects/unionobject.c b/Objects/unionobject.c index 5bc639316478df..f273f7d15ef25f 100644 --- a/Objects/unionobject.c +++ b/Objects/unionobject.c @@ -1,7 +1,6 @@ // types.UnionType -- used to represent e.g. Union[int, str], int | str #include "Python.h" #include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK -#include "pycore_typevarobject.h" // _PyTypeVar_Type #include "pycore_unionobject.h" #include "structmember.h" diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 28b5680e9c27e2..fcb4d7a9a975c6 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -11,7 +11,6 @@ #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_ceval.h" // _PyEval_Vector() -#include "pycore_typevarobject.h" #include "clinic/bltinmodule.c.h" diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 0e74ed1371a9e5..01ac4b2eeb8737 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -207,26 +207,6 @@ make_typevar(PyThreadState* unused, PyObject *v) return _Py_make_typevar(PyUnicode_AsUTF8(v), NULL); } -static PyObject * -make_paramspec(PyThreadState* unused, PyObject *v) -{ - assert(PyUnicode_Check(v)); - return _Py_make_paramspec(PyUnicode_AsUTF8(v)); -} - -static PyObject * -make_typevartuple(PyThreadState* unused, PyObject *v) -{ - assert(PyUnicode_Check(v)); - return _Py_make_typevartuple(PyUnicode_AsUTF8(v)); -} - -static PyObject * -subscript_generic(PyThreadState* unused, PyObject *v) -{ - return _Py_subscript_generic(v); -} - const instrinsic_func1 _PyIntrinsics_UnaryFunctions[] = { [0] = no_intrinsic, @@ -237,9 +217,9 @@ _PyIntrinsics_UnaryFunctions[] = { [INTRINSIC_UNARY_POSITIVE] = unary_pos, [INTRINSIC_LIST_TO_TUPLE] = list_to_tuple, [INTRINSIC_TYPEVAR] = make_typevar, - [INTRINSIC_PARAMSPEC] = make_paramspec, - [INTRINSIC_TYPEVARTUPLE] = make_typevartuple, - [INTRINSIC_SUBSCRIPT_GENERIC] = subscript_generic, + [INTRINSIC_PARAMSPEC] = _Py_make_paramspec, + [INTRINSIC_TYPEVARTUPLE] = _Py_make_typevartuple, + [INTRINSIC_SUBSCRIPT_GENERIC] = _Py_subscript_generic, [INTRINSIC_TYPEALIAS] = _Py_make_typealias, }; diff --git a/Python/symtable.c b/Python/symtable.c index 8af56e5d5f0fbc..6fb9cdb7e9ea5d 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -393,10 +393,7 @@ PySymtable_Lookup(struct symtable *st, void *key) long _PyST_GetSymbol(PySTEntryObject *ste, PyObject *name) { - PyObject *v = NULL; - if (v == NULL) { - v = PyDict_GetItemWithError(ste->ste_symbols, name); - } + PyObject *v = PyDict_GetItemWithError(ste->ste_symbols, name); if (!v) return 0; assert(PyLong_Check(v)); @@ -407,7 +404,6 @@ int _PyST_GetScope(PySTEntryObject *ste, PyObject *name) { long symbol = _PyST_GetSymbol(ste, name); - assert(!PyErr_Occurred()); return (symbol >> SCOPE_OFFSET) & SCOPE_MASK; } @@ -847,7 +843,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, assert(c && PySTEntry_Check(c)); entry = (PySTEntryObject*)c; if (!analyze_child_block(entry, newbound, newfree, newglobal, - allfree)) + allfree)) goto error; /* Check if any children have free variables */ if (entry->ste_free || entry->ste_child_free) @@ -1033,6 +1029,7 @@ symtable_add_def_helper(struct symtable *st, PyObject *name, int flag, struct _s long val; PyObject *mangled = _Py_Mangle(st->st_private, name); + if (!mangled) return 0; dict = ste->ste_symbols; @@ -1276,7 +1273,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); } switch (s->kind) { - case FunctionDef_kind: { + case FunctionDef_kind: if (!symtable_add_def(st, s->v.FunctionDef.name, DEF_LOCAL, LOCATION(s))) VISIT_QUIT(st, 0); if (s->v.FunctionDef.args->defaults) @@ -1314,7 +1311,6 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_QUIT(st, 0); } break; - } case ClassDef_kind: { PyObject *tmp; if (!symtable_add_def(st, s->v.ClassDef.name, DEF_LOCAL, LOCATION(s))) diff --git a/Tools/c-analyzer/cpython/globals-to-fix.tsv b/Tools/c-analyzer/cpython/globals-to-fix.tsv index fbb4cbdf1610be..849fd5d9a1e8d5 100644 --- a/Tools/c-analyzer/cpython/globals-to-fix.tsv +++ b/Tools/c-analyzer/cpython/globals-to-fix.tsv @@ -89,12 +89,6 @@ Objects/tupleobject.c - PyTuple_Type - Objects/typeobject.c - PyBaseObject_Type - Objects/typeobject.c - PySuper_Type - Objects/typeobject.c - PyType_Type - -Objects/typevarobject.c - _PyTypeVar_Type - -Objects/typevarobject.c - _PyParamSpecArgs_Type - -Objects/typevarobject.c - _PyParamSpecKwargs_Type - -Objects/typevarobject.c - _PyParamSpec_Type - -Objects/typevarobject.c - _PyTypeVarTuple_Type - -Objects/typevarobject.c- _PyTypeAlias_Type - Objects/unicodeobject.c - PyUnicodeIter_Type - Objects/unicodeobject.c - PyUnicode_Type - Objects/weakrefobject.c - _PyWeakref_CallableProxyType - From f02199f6a782067b34890e75d9f5a3610ed48f03 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 18:12:37 -0600 Subject: [PATCH 074/200] It's supposed to be called TypeAliasType --- Lib/typing.py | 35 ++++------------------------------- Objects/typevarobject.c | 2 +- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/Lib/typing.py b/Lib/typing.py index fc8145c781512a..414e146bb5637d 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -937,36 +937,6 @@ def __reduce__(self): return self.__name__ -class TypeAliasType(_Final, _Immutable, _PickleUsingNameMixin, _root=True): - """Type alias allocated through the use of a "type" statement. - """ - def __init__(self, name, parameters): - self.__value__ = None - self.__name__ = name - self.__parameters__ = parameters - self.__arguments__ = None - - @_tp_cache - def __getitem__(self, args): - if len(self.__parameters__) == 0: - raise TypeError(f"Type alias is not generic") - if self.__arguments__: - raise TypeError(f"Cannot subscript already-subscripted type alias") - copy = TypeAliasType(self.__name__, self.__parameters__) - copy.__value__ = self.__value__ - copy.__arguments__ = args - return copy - - def __repr__(self): - return self.__name__ - - def __or__(self, right): - return Union[self, right] - - def __ror__(self, left): - return Union[left, self] - - def _typevar_subst(self, arg): msg = "Parameters to generic types must be types." arg = _type_check(arg, msg, is_argument=True) @@ -1801,7 +1771,10 @@ def _pickle_pskwargs(pskwargs): copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) -del _Dummy, _pickle_psargs, _pickle_pskwargs +type _Alias = int +TypeAliasType = type(_Alias) + +del _Dummy, _pickle_psargs, _pickle_pskwargs, _Alias class _ProtocolMeta(ABCMeta): diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 83705416292099..d7d5ed25ba390d 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1217,7 +1217,7 @@ static PyType_Slot typealias_slots[] = { }; PyType_Spec typealias_spec = { - .name = "typing.TypeAlias", + .name = "typing.TypeAliasType", .basicsize = sizeof(typealiasobject), .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_HAVE_GC, .slots = typealias_slots, From 3fe019b2d92b6e03968b5573502205b862aa3354 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 18:45:55 -0600 Subject: [PATCH 075/200] Allow evaluating TypeAlias --- Lib/test/test_type_aliases.py | 8 +- Objects/typevarobject.c | 154 +++++++++++++++++++++------------- 2 files changed, 100 insertions(+), 62 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 09f817befeb113..85d12adf634b28 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -55,7 +55,7 @@ def test_alias_value_01(self): self.assertIsInstance(TA1, TypeAliasType) self.assertEqual(TA1.__value__, int) self.assertEqual(TA1.__parameters__, ()) - self.assertEqual(TA1.__type_variables__, ()) + self.assertEqual(TA1.__type_params__, ()) type TA2 = TA1 | str @@ -64,7 +64,7 @@ def test_alias_value_01(self): self.assertEqual(a, TA1) self.assertEqual(b, str) self.assertEqual(TA2.__parameters__, ()) - self.assertEqual(TA2.__type_variables__, ()) + self.assertEqual(TA2.__type_params__, ()) def test_alias_access_02(self): class Parent[A]: @@ -75,7 +75,7 @@ class Parent[A]: self.assertEqual(len(Parent.__parameters__), 1) a = Parent.__parameters__[0] b = Parent.TA1.__parameters__[0] - self.assertEqual(Parent.TA1.__type_variables__, (a, b)) + self.assertEqual(Parent.TA1.__type_params__, (a, b)) def test_alias_access_02(self): def outer[A](): @@ -88,5 +88,5 @@ def outer[A](): self.assertEqual(len(outer.__type_variables__), 1) a = outer.__type_variables__[0] b = o.__parameters__[0] - self.assertEqual(o.__type_variables__, (a, b)) + self.assertEqual(o.__type_params__, (b,)) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index d7d5ed25ba390d..11fe727adfe080 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -115,6 +115,68 @@ caller(void) return Py_NewRef(r); } +static PyObject * +typevartuple_unpack(PyObject *tvt) +{ + PyObject *typing = PyImport_ImportModule("typing"); + if (typing == NULL) { + return NULL; + } + PyObject *unpack = PyObject_GetAttrString(typing, "Unpack"); + if (unpack == NULL) { + Py_DECREF(typing); + return NULL; + } + PyObject *unpacked = PyObject_GetItem(unpack, tvt); + Py_DECREF(typing); + Py_DECREF(unpack); + return unpacked; +} + +static int +contains_typevartuple(PyTupleObject *params) +{ + Py_ssize_t n = PyTuple_GET_SIZE(params); + PyObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *param = PyTuple_GET_ITEM(params, i); + if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { + return 1; + } + } + return 0; +} + +static PyObject * +unpack_typevartuples(PyObject *params) +{ + assert(PyTuple_Check(params)); + // TypeVarTuple must be unpacked when passed to Generic, so we do that here. + if (contains_typevartuple((PyTupleObject *)params)) { + Py_ssize_t n = PyTuple_GET_SIZE(params); + PyObject *new_params = PyTuple_New(n); + PyObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; + for (Py_ssize_t i = 0; i < n; i++) { + PyObject *param = PyTuple_GET_ITEM(params, i); + if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { + PyObject *unpacked = typevartuple_unpack(param); + if (unpacked == NULL) { + Py_DECREF(new_params); + return NULL; + } + PyTuple_SET_ITEM(new_params, i, unpacked); + } + else { + PyTuple_SET_ITEM(new_params, i, Py_NewRef(param)); + } + } + return new_params; + } + else { + return Py_NewRef(params); + } +} + static void typevar_dealloc(PyObject *self) { @@ -890,24 +952,6 @@ typevartuple_dealloc(PyObject *self) Py_DECREF(tp); } -static PyObject * -typevartuple_unpack(PyObject *tvt) -{ - PyObject *typing = PyImport_ImportModule("typing"); - if (typing == NULL) { - return NULL; - } - PyObject *unpack = PyObject_GetAttrString(typing, "Unpack"); - if (unpack == NULL) { - Py_DECREF(typing); - return NULL; - } - PyObject *unpacked = PyObject_GetItem(unpack, tvt); - Py_DECREF(typing); - Py_DECREF(unpack); - return unpacked; -} - static PyObject * typevartuple_iter(PyObject *self) { @@ -1150,6 +1194,37 @@ static PyMemberDef typealias_members[] = { {0} }; +static PyObject * +typealias_value(PyObject *self, void *unused) +{ + typealiasobject *ta = (typealiasobject *)self; + if (ta->value != NULL) { + return Py_NewRef(ta->value); + } + PyObject *result = PyObject_CallNoArgs(ta->compute_value); + if (result == NULL) { + return NULL; + } + ta->value = Py_NewRef(result); + return result; +} + +static PyObject * +typealias_parameters(PyObject *self, void *unused) +{ + typealiasobject *ta = (typealiasobject *)self; + if (ta->type_params == NULL || Py_IsNone(ta->type_params)) { + return PyTuple_New(0); + } + return unpack_typevartuples(ta->type_params); +} + +static PyGetSetDef typealias_getset[] = { + {"__parameters__", typealias_parameters, (setter)NULL, NULL, NULL}, + {"__value__", typealias_value, (setter)NULL, NULL, NULL}, + {0} +}; + static typealiasobject * typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) { @@ -1163,7 +1238,7 @@ typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value Py_DECREF(ta); return NULL; } - ta->type_params = Py_XNewRef(type_params); + ta->type_params = Py_IsNone(type_params) ? PyTuple_New(0) : Py_XNewRef(type_params); ta->compute_value = Py_NewRef(compute_value); ta->value = NULL; _PyObject_GC_TRACK(ta); @@ -1208,6 +1283,7 @@ static PyType_Slot typealias_slots[] = { {Py_tp_doc, (void *)typealias_doc}, {Py_tp_members, typealias_members}, {Py_tp_methods, typealias_methods}, + {Py_tp_getset, typealias_getset}, {Py_tp_dealloc, typealias_dealloc}, {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, @@ -1318,48 +1394,10 @@ generic_class_getitem(PyTypeObject *cls, PyObject *args, PyObject *kwargs) return call_typing_args_kwargs("_generic_class_getitem", cls, args, kwargs); } -static int -contains_typevartuple(PyTupleObject *params) -{ - Py_ssize_t n = PyTuple_GET_SIZE(params); - PyObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; - for (Py_ssize_t i = 0; i < n; i++) { - PyObject *param = PyTuple_GET_ITEM(params, i); - if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { - return 1; - } - } - return 0; -} - PyObject * _Py_subscript_generic(PyThreadState* unused, PyObject *params) { - assert(PyTuple_Check(params)); - // TypeVarTuple must be unpacked when passed to Generic, so we do that here. - if (contains_typevartuple((PyTupleObject *)params)) { - Py_ssize_t n = PyTuple_GET_SIZE(params); - PyObject *new_params = PyTuple_New(n); - PyObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; - for (Py_ssize_t i = 0; i < n; i++) { - PyObject *param = PyTuple_GET_ITEM(params, i); - if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { - PyObject *unpacked = typevartuple_unpack(param); - if (unpacked == NULL) { - Py_DECREF(new_params); - return NULL; - } - PyTuple_SET_ITEM(new_params, i, unpacked); - } - else { - PyTuple_SET_ITEM(new_params, i, Py_NewRef(param)); - } - } - params = new_params; - } - else { - Py_INCREF(params); - } + params = unpack_typevartuples(params); PyInterpreterState *interp = PyInterpreterState_Get(); if (interp->cached_objects.generic_type == NULL) { From 737d96aa744b515afccb892655407daf0f35fbc0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 21:10:37 -0600 Subject: [PATCH 076/200] Support __or__ on type aliases --- Objects/typevarobject.c | 1 + Objects/unionobject.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 11fe727adfe080..1ea4442e3c8d4c 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1289,6 +1289,7 @@ static PyType_Slot typealias_slots[] = { {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, (traverseproc)typealias_traverse}, {Py_tp_repr, typealias_repr}, + {Py_nb_or, _Py_union_type_or}, {0, 0}, }; diff --git a/Objects/unionobject.c b/Objects/unionobject.c index f273f7d15ef25f..9806678b804857 100644 --- a/Objects/unionobject.c +++ b/Objects/unionobject.c @@ -147,10 +147,14 @@ get_types(PyObject **obj, Py_ssize_t *size) static int is_unionable(PyObject *obj) { - return (obj == Py_None || + if (obj == Py_None || PyType_Check(obj) || _PyGenericAlias_Check(obj) || - _PyUnion_Check(obj)); + _PyUnion_Check(obj)) { + return 1; + } + PyInterpreterState *interp = PyInterpreterState_Get(); + return Py_IS_TYPE(obj, interp->cached_objects.typealias_type); } PyObject * From 6fe9476fd6d494fb1516f6b06bb7ec791b8368d4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 21:33:16 -0600 Subject: [PATCH 077/200] fix | and subscripting on TypeAliasType --- Lib/test/test_type_aliases.py | 9 ++++++++- Objects/typevarobject.c | 28 +++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 85d12adf634b28..a3c8fffeed5fe9 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -1,4 +1,5 @@ import textwrap +import types import unittest from typing import TypeAliasType @@ -86,7 +87,13 @@ def outer[A](): self.assertIsInstance(o, TypeAliasType) self.assertEqual(len(o.__parameters__), 1) self.assertEqual(len(outer.__type_variables__), 1) - a = outer.__type_variables__[0] b = o.__parameters__[0] self.assertEqual(o.__type_params__, (b,)) + def test_subscripting(self): + type NonGeneric = int + type Generic[A] = dict[A, A] + + with self.assertRaises(TypeError): + NonGeneric[int] + self.assertIsInstance(Generic[int], types.GenericAlias) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 1ea4442e3c8d4c..8b49ca4d737d88 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1190,7 +1190,6 @@ typealias_repr(PyObject *self) static PyMemberDef typealias_members[] = { {"__name__", T_STRING, offsetof(typealiasobject, name), READONLY}, - {"__type_params__", T_OBJECT, offsetof(typealiasobject, type_params), READONLY}, {0} }; @@ -1213,14 +1212,25 @@ static PyObject * typealias_parameters(PyObject *self, void *unused) { typealiasobject *ta = (typealiasobject *)self; - if (ta->type_params == NULL || Py_IsNone(ta->type_params)) { + if (ta->type_params == NULL) { return PyTuple_New(0); } return unpack_typevartuples(ta->type_params); } +static PyObject * +typealias_type_params(PyObject *self, void *unused) +{ + typealiasobject *ta = (typealiasobject *)self; + if (ta->type_params == NULL) { + return PyTuple_New(0); + } + return ta->type_params; +} + static PyGetSetDef typealias_getset[] = { {"__parameters__", typealias_parameters, (setter)NULL, NULL, NULL}, + {"__type_params__", typealias_type_params, (setter)NULL, NULL, NULL}, {"__value__", typealias_value, (setter)NULL, NULL, NULL}, {0} }; @@ -1238,7 +1248,7 @@ typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value Py_DECREF(ta); return NULL; } - ta->type_params = Py_IsNone(type_params) ? PyTuple_New(0) : Py_XNewRef(type_params); + ta->type_params = Py_IsNone(type_params) ? NULL : Py_XNewRef(type_params); ta->compute_value = Py_NewRef(compute_value); ta->value = NULL; _PyObject_GC_TRACK(ta); @@ -1266,6 +1276,17 @@ typealias_reduce_impl(typealiasobject *self) return PyUnicode_FromString(self->name); } +static PyObject * +typealias_subscript(PyObject *self, PyObject *args) +{ + if (((typealiasobject *)self)->type_params == NULL) { + PyErr_SetString(PyExc_TypeError, + "Only generic type aliases are subscriptable"); + return NULL; + } + return Py_GenericAlias(self, args); +} + static PyMethodDef typealias_methods[] = { TYPEALIAS_REDUCE_METHODDEF {0} @@ -1284,6 +1305,7 @@ static PyType_Slot typealias_slots[] = { {Py_tp_members, typealias_members}, {Py_tp_methods, typealias_methods}, {Py_tp_getset, typealias_getset}, + {Py_mp_subscript, typealias_subscript}, {Py_tp_dealloc, typealias_dealloc}, {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, From 80a9efb9cd61ee758280da2c8d4d08bb46e27462 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 24 Apr 2023 22:04:46 -0600 Subject: [PATCH 078/200] Test fixes and new tests --- Lib/test/test_type_params.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 59511b10844381..a4e65d8aad80d2 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -227,6 +227,13 @@ class Child[T](Base): pass """) exec(code, {}) + def test_nonlocal(self): + def outer2[T](): + + def inner1(): + nonlocal T # Syntax error: nonlocal binding not allowed for type parameter + + class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): @@ -263,20 +270,20 @@ def func1[A: str, B: str | int, C: (int, str)](): self.assertIsInstance(a, TypeVar) self.assertEqual(a.__bound__, str) - self.assertTrue(a.__autovariance__) + self.assertTrue(a.__infer_variance__) self.assertFalse(a.__covariant__) self.assertFalse(a.__contravariant__) self.assertIsInstance(b, TypeVar) self.assertEqual(b.__bound__, str | int) - self.assertTrue(b.__autovariance__) + self.assertTrue(b.__infer_variance__) self.assertFalse(b.__covariant__) self.assertFalse(b.__contravariant__) self.assertIsInstance(c, TypeVar) self.assertEqual(c.__bound__, None) self.assertEqual(c.__constraints__, (int, str)) - self.assertTrue(c.__autovariance__) + self.assertTrue(c.__infer_variance__) self.assertFalse(c.__covariant__) self.assertFalse(c.__contravariant__) @@ -354,7 +361,7 @@ def func1[**A](): a = func1() self.assertIsInstance(a, ParamSpec) - self.assertTrue(a.__autovariance__) + self.assertTrue(a.__infer_variance__) self.assertFalse(a.__covariant__) self.assertFalse(a.__contravariant__) From 21b3aec4ba25405aa22461f2cdb2b0de19d746e4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 05:30:13 -0600 Subject: [PATCH 079/200] Add syntax error for nonlocal as specified by the PEP --- Lib/test/test_type_params.py | 10 ++++-- Python/symtable.c | 59 ++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 23 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index a4e65d8aad80d2..d034422bc29f64 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -228,10 +228,14 @@ class Child[T](Base): pass exec(code, {}) def test_nonlocal(self): - def outer2[T](): + code = textwrap.dedent("""\ + def outer2[T](): - def inner1(): - nonlocal T # Syntax error: nonlocal binding not allowed for type parameter + def inner1(): + nonlocal T # Syntax error: nonlocal binding not allowed for type parameter + """) + with self.assertRaisesRegex(SyntaxError, "nonlocal binding not allowed for type parameter 'T'"): + exec(code, {}) diff --git a/Python/symtable.c b/Python/symtable.c index 6fb9cdb7e9ea5d..d1148a3e5012c5 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -511,7 +511,11 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); if (PySet_Add(global, name) < 0) return 0; - if (bound && (PySet_Discard(bound, name) < 0)) + if (!bound) + return 1; + if (!PyDict_Contains(bound, name)) + return 1; + if (PyDict_DelItem(bound, name) < 0) return 0; return 1; } @@ -521,21 +525,34 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, "nonlocal declaration not allowed at module level"); return error_at_directive(ste, name); } - if (!PySet_Contains(bound, name)) { + PyObject *flags = PyDict_GetItem(bound, name); + if (flags == NULL) { PyErr_Format(PyExc_SyntaxError, "no binding for nonlocal '%U' found", name); return error_at_directive(ste, name); } + if (PyLong_AsLong(flags) & DEF_TYPE_PARAM) { + PyErr_Format(PyExc_SyntaxError, + "nonlocal binding not allowed for type parameter '%U'", + name); + return error_at_directive(ste, name); + } SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; } if (flags & DEF_BOUND) { SET_SCOPE(scopes, name, LOCAL); - if (PySet_Add(local, name) < 0) + PyObject *flags_obj = PyLong_FromLong(flags); + if (flags_obj == NULL) + return 0; + if (PyDict_SetItem(local, name, flags_obj) < 0) { + Py_DECREF(flags_obj); return 0; + } + Py_DECREF(flags_obj); if (PySet_Discard(global, name) < 0) return 0; return 1; @@ -545,7 +562,7 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, Note that having a non-NULL bound implies that the block is nested. */ - if (bound && PySet_Contains(bound, name)) { + if (bound && PyDict_Contains(bound, name)) { SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; @@ -690,7 +707,7 @@ update_symbols(PyObject *symbols, PyObject *scopes, goto error; } /* Handle global symbol */ - if (bound && !PySet_Contains(bound, name)) { + if (bound && !PyDict_Contains(bound, name)) { Py_DECREF(name); continue; /* it's a global */ } @@ -740,12 +757,11 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, { PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL; PyObject *newglobal = NULL, *newfree = NULL, *allfree = NULL; - PyObject *newbound_with_type_params = NULL; PyObject *temp; int i, success = 0; Py_ssize_t pos = 0; - local = PySet_New(NULL); /* collect new names bound in block */ + local = PyDict_New(); /* collect new names bound in block */ if (!local) goto error; scopes = PyDict_New(); /* collect scopes defined for each name */ @@ -769,7 +785,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, newfree = PySet_New(NULL); if (!newfree) goto error; - newbound = PySet_New(NULL); + newbound = PyDict_New(); if (!newbound) goto error; @@ -786,10 +802,9 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_DECREF(temp); /* Pass down previously bound symbols */ if (bound) { - temp = PyNumber_InPlaceOr(newbound, bound); - if (!temp) + if (PyDict_Update(newbound, bound) < 0) { goto error; - Py_DECREF(temp); + } } } @@ -804,17 +819,15 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, if (ste->ste_type != ClassBlock) { /* Add function locals to bound set */ if (ste->ste_type == FunctionBlock) { - temp = PyNumber_InPlaceOr(newbound, local); - if (!temp) + if (PyDict_Update(newbound, local) < 0) { goto error; - Py_DECREF(temp); + } } /* Pass down previously bound symbols */ if (bound) { - temp = PyNumber_InPlaceOr(newbound, bound); - if (!temp) + if (PyDict_Update(newbound, bound) < 0) { goto error; - Py_DECREF(temp); + } } /* Pass down known globals */ temp = PyNumber_InPlaceOr(newglobal, global); @@ -824,8 +837,15 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, } else { /* Special-case __class__ */ - if (PySet_Add(newbound, &_Py_ID(__class__)) < 0) + PyObject *flags = PyLong_FromLong(0); + if (flags == NULL) { goto error; + } + if (PyDict_SetItem(newbound, &_Py_ID(__class__), flags) < 0) { + Py_DECREF(flags); + goto error; + } + Py_DECREF(flags); } /* Recursively call analyze_child_block() on each child block. @@ -877,7 +897,6 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_XDECREF(newglobal); Py_XDECREF(newfree); Py_XDECREF(allfree); - Py_XDECREF(newbound_with_type_params); if (!success) assert(PyErr_Occurred()); return success; @@ -897,7 +916,7 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, dictionaries. */ - temp_bound = PySet_New(bound); + temp_bound = PyDict_Copy(bound); if (!temp_bound) goto error; temp_free = PySet_New(free); From 30487a5e188fe2ae4d276d0926539cbe5e2dc38e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 06:14:54 -0600 Subject: [PATCH 080/200] Implement TypeAlias repr --- Include/internal/pycore_global_objects.h | 14 +-- Lib/test/test_type_aliases.py | 30 +++++ Objects/typevarobject.c | 141 ++++++++++++++++++----- 3 files changed, 146 insertions(+), 39 deletions(-) diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h index c0195e043f5547..40cc04d5d1702c 100644 --- a/Include/internal/pycore_global_objects.h +++ b/Include/internal/pycore_global_objects.h @@ -69,13 +69,13 @@ struct _Py_interp_cached_objects { pytype_slotdef *type_slots_ptrs[MAX_EQUIV]; /* TypeVar and related types */ - PyObject *generic_type; - PyObject *typevar_type; - PyObject *typevartuple_type; - PyObject *paramspec_type; - PyObject *paramspecargs_type; - PyObject *paramspeckwargs_type; - PyObject *typealias_type; + PyTypeObject *generic_type; + PyTypeObject *typevar_type; + PyTypeObject *typevartuple_type; + PyTypeObject *paramspec_type; + PyTypeObject *paramspecargs_type; + PyTypeObject *paramspeckwargs_type; + PyTypeObject *typealias_type; }; #define _Py_INTERP_STATIC_OBJECT(interp, NAME) \ diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index a3c8fffeed5fe9..26b2662e070640 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -97,3 +97,33 @@ def test_subscripting(self): with self.assertRaises(TypeError): NonGeneric[int] self.assertIsInstance(Generic[int], types.GenericAlias) + + def test_repr(self): + type Simple = int + self.assertEqual(repr(Simple), "") + + class FancyRepr: + def __repr__(self): + return "" + type Fancy = FancyRepr() + self.assertEqual(repr(Fancy), ">") + + class FancyMeta(type): + def __repr__(self): + return f"" + class FancyCls(metaclass=FancyMeta): + pass + type Fancy2 = FancyCls + self.assertEqual(repr(Fancy2), ">") + + type NoRepr = 1 / 0 + self.assertEqual(repr(NoRepr), ">") + + class FailingRepr: + def __repr__(self): + raise ValueError("nope") + type Failing = FailingRepr() + self.assertEqual(repr(Failing), ">") + + type Generic[T, *Ts, **P] = int + self.assertEqual(repr(Generic), "") diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 8b49ca4d737d88..6342a21fc45fd7 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -137,10 +137,10 @@ static int contains_typevartuple(PyTupleObject *params) { Py_ssize_t n = PyTuple_GET_SIZE(params); - PyObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; for (Py_ssize_t i = 0; i < n; i++) { PyObject *param = PyTuple_GET_ITEM(params, i); - if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { + if (Py_IS_TYPE(param, tp)) { return 1; } } @@ -155,10 +155,10 @@ unpack_typevartuples(PyObject *params) if (contains_typevartuple((PyTupleObject *)params)) { Py_ssize_t n = PyTuple_GET_SIZE(params); PyObject *new_params = PyTuple_New(n); - PyObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; for (Py_ssize_t i = 0; i < n; i++) { PyObject *param = PyTuple_GET_ITEM(params, i); - if (Py_IS_TYPE(param, (PyTypeObject *)tp)) { + if (Py_IS_TYPE(param, tp)) { PyObject *unpacked = typevartuple_unpack(param); if (unpacked == NULL) { Py_DECREF(new_params); @@ -233,9 +233,9 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *constraints, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { - PyObject *tp = PyInterpreterState_Get()->cached_objects.typevar_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevar_type; assert(tp != NULL); - typevarobject *tv = PyObject_GC_New(typevarobject, (PyTypeObject *)tp); + typevarobject *tv = PyObject_GC_New(typevarobject, tp); if (tv == NULL) { return NULL; } @@ -512,8 +512,8 @@ paramspecargs_repr(PyObject *self) { paramspecattrobject *psa = (paramspecattrobject *)self; - PyObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; - if (Py_IS_TYPE(psa->__origin__, (PyTypeObject *)tp)) { + PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; + if (Py_IS_TYPE(psa->__origin__, tp)) { return PyUnicode_FromFormat("%s.args", ((paramspecobject *)psa->__origin__)->name); } @@ -589,8 +589,8 @@ paramspeckwargs_repr(PyObject *self) { paramspecattrobject *psk = (paramspecattrobject *)self; - PyObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; - if (Py_IS_TYPE(psk->__origin__, (PyTypeObject *)tp)) { + PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; + if (Py_IS_TYPE(psk->__origin__, tp)) { return PyUnicode_FromFormat("%s.kwargs", ((paramspecobject *)psk->__origin__)->name); } @@ -711,15 +711,15 @@ static PyMemberDef paramspec_members[] = { static PyObject * paramspec_args(PyObject *self, void *unused) { - PyObject *tp = PyInterpreterState_Get()->cached_objects.paramspecargs_type; - return (PyObject *)paramspecattr_new((PyTypeObject *)tp, self); + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspecargs_type; + return (PyObject *)paramspecattr_new(tp, self); } static PyObject * paramspec_kwargs(PyObject *self, void *unused) { - PyObject *tp = PyInterpreterState_Get()->cached_objects.paramspeckwargs_type; - return (PyObject *)paramspecattr_new((PyTypeObject *)tp, self); + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspeckwargs_type; + return (PyObject *)paramspecattr_new(tp, self); } static PyGetSetDef paramspec_getset[] = { @@ -732,8 +732,8 @@ static paramspecobject * paramspec_alloc(const char *name, PyObject *bound, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { - PyObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; - paramspecobject *ps = PyObject_GC_New(paramspecobject, (PyTypeObject *)tp); + PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; + paramspecobject *ps = PyObject_GC_New(paramspecobject, tp); if (ps == NULL) { return NULL; } @@ -986,8 +986,8 @@ static PyMemberDef typevartuple_members[] = { static typevartupleobject * typevartuple_alloc(const char *name, PyObject *module) { - PyObject *tp = _PyInterpreterState_Get()->cached_objects.typevartuple_type; - typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, (PyTypeObject *)tp); + PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.typevartuple_type; + typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, tp); if (tvt == NULL) { return NULL; } @@ -1181,11 +1181,96 @@ typealias_dealloc(PyObject *self) Py_TYPE(self)->tp_free(self); } +static PyObject * +typealias_evaluate(typealiasobject *ta) +{ + if (ta->value != NULL) { + return Py_NewRef(ta->value); + } + PyObject *result = PyObject_CallNoArgs(ta->compute_value); + if (result == NULL) { + return NULL; + } + ta->value = Py_NewRef(result); + return result; +} + static PyObject * typealias_repr(PyObject *self) { typealiasobject *ta = (typealiasobject *)self; - return PyUnicode_FromFormat("%s", ta->name); + PyObject *value_repr = NULL; + PyObject *value = typealias_evaluate(ta); + if (value == NULL) { + PyErr_Clear(); + value_repr = PyUnicode_FromString(""); + } + else if (PyType_Check(value) && Py_TYPE(value)->tp_repr == PyType_Type.tp_repr + && ((PyTypeObject *)value)->tp_name != NULL) { + value_repr = PyUnicode_FromString(((PyTypeObject *)value)->tp_name); + Py_DECREF(value); + } + else { + value_repr = PyObject_Repr(value); + Py_DECREF(value); + if (value_repr == NULL) { + PyErr_Clear(); + value_repr = PyUnicode_FromString(""); + } + } + if (value_repr == NULL) { + // PyUnicode_FromString failed + return NULL; + } + PyObject *result = NULL; + if (ta->type_params != NULL) { + _PyUnicodeWriter writer; + _PyUnicodeWriter_Init(&writer); + PyTupleObject *type_params = (PyTupleObject *)ta->type_params; + Py_ssize_t count = PyTuple_GET_SIZE(type_params); + PyInterpreterState *interp = PyInterpreterState_Get(); + for (Py_ssize_t i = 0; i < count; i++) { + PyObject *type_param = PyTuple_GET_ITEM(type_params, i); + if (i > 0 && _PyUnicodeWriter_WriteASCIIString(&writer, ", ", 2) < 0) { + _PyUnicodeWriter_Dealloc(&writer); + goto error; + } + if (Py_IS_TYPE(type_param, interp->cached_objects.paramspec_type)) { + if (_PyUnicodeWriter_WriteASCIIString(&writer, "**", 2) < 0) { + _PyUnicodeWriter_Dealloc(&writer); + goto error; + } + } + else if (Py_IS_TYPE(type_param, interp->cached_objects.typevartuple_type)) { + if (_PyUnicodeWriter_WriteASCIIString(&writer, "*", 1) < 0) { + _PyUnicodeWriter_Dealloc(&writer); + goto error; + } + } + PyObject *type_param_repr = PyObject_Repr(type_param); + if (type_param_repr == NULL) { + _PyUnicodeWriter_Dealloc(&writer); + goto error; + } + if (_PyUnicodeWriter_WriteStr(&writer, type_param_repr) < 0) { + Py_DECREF(type_param_repr); + _PyUnicodeWriter_Dealloc(&writer); + goto error; + } + Py_DECREF(type_param_repr); + } + PyObject *params_repr = _PyUnicodeWriter_Finish(&writer); + if (params_repr == NULL) { + goto error; + } + result = PyUnicode_FromFormat("", ta->name, params_repr, value_repr); + } + else { + result = PyUnicode_FromFormat("", ta->name, value_repr); + } +error: + Py_DECREF(value_repr); + return result; } static PyMemberDef typealias_members[] = { @@ -1197,15 +1282,7 @@ static PyObject * typealias_value(PyObject *self, void *unused) { typealiasobject *ta = (typealiasobject *)self; - if (ta->value != NULL) { - return Py_NewRef(ta->value); - } - PyObject *result = PyObject_CallNoArgs(ta->compute_value); - if (result == NULL) { - return NULL; - } - ta->value = Py_NewRef(result); - return result; + return typealias_evaluate(ta); } static PyObject * @@ -1225,7 +1302,7 @@ typealias_type_params(PyObject *self, void *unused) if (ta->type_params == NULL) { return PyTuple_New(0); } - return ta->type_params; + return Py_NewRef(ta->type_params); } static PyGetSetDef typealias_getset[] = { @@ -1238,8 +1315,8 @@ static PyGetSetDef typealias_getset[] = { static typealiasobject * typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) { - PyObject *tp = PyInterpreterState_Get()->cached_objects.typealias_type; - typealiasobject *ta = PyObject_GC_New(typealiasobject, (PyTypeObject *)tp); + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typealias_type; + typealiasobject *ta = PyObject_GC_New(typealiasobject, tp); if (ta == NULL) { return NULL; } @@ -1464,7 +1541,7 @@ int _Py_initialize_generic(PyInterpreterState *interp) { #define MAKE_TYPE(name) \ do { \ - PyObject *name ## _type = PyType_FromSpec(&name ## _spec); \ + PyTypeObject *name ## _type = (PyTypeObject *)PyType_FromSpec(&name ## _spec); \ if (name ## _type == NULL) { \ return -1; \ } \ From 1575c66cd587d1847a9193931f9ad39fb92adefc Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 06:25:21 -0600 Subject: [PATCH 081/200] __type_variables__ -> __type_params__ --- .../pycore_global_objects_fini_generated.h | 2 +- Include/internal/pycore_global_strings.h | 2 +- .../internal/pycore_runtime_init_generated.h | 2 +- .../internal/pycore_unicodeobject_generated.h | 2 +- Lib/test/test_type_aliases.py | 2 +- Lib/test/test_type_params.py | 21 +++++++++---------- Lib/typing.py | 6 +++--- Objects/funcobject.c | 4 ++-- Objects/typeobject.c | 6 +++--- Python/compile.c | 2 +- Python/symtable.c | 2 +- 11 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index b5d434886c696e..b70c622dd1d370 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -727,7 +727,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__subclasshook__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__truediv__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__trunc__)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__type_variables__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__type_params__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_is_unpacked_typevartuple__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_prepare_subst__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__typing_subst__)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 9dc1f53bb9e22d..29bf60403c33bf 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -215,7 +215,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(__subclasshook__) STRUCT_FOR_ID(__truediv__) STRUCT_FOR_ID(__trunc__) - STRUCT_FOR_ID(__type_variables__) + STRUCT_FOR_ID(__type_params__) STRUCT_FOR_ID(__typing_is_unpacked_typevartuple__) STRUCT_FOR_ID(__typing_prepare_subst__) STRUCT_FOR_ID(__typing_subst__) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index f6990ed3bc1266..73134816574fae 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -721,7 +721,7 @@ extern "C" { INIT_ID(__subclasshook__), \ INIT_ID(__truediv__), \ INIT_ID(__trunc__), \ - INIT_ID(__type_variables__), \ + INIT_ID(__type_params__), \ INIT_ID(__typing_is_unpacked_typevartuple__), \ INIT_ID(__typing_prepare_subst__), \ INIT_ID(__typing_subst__), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index e4fc8680f0bf99..fd265484eef456 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -483,7 +483,7 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(__trunc__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); - string = &_Py_ID(__type_variables__); + string = &_Py_ID(__type_params__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(__typing_is_unpacked_typevartuple__); diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 26b2662e070640..87d91f365d8ebf 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -86,7 +86,7 @@ def outer[A](): o = outer() self.assertIsInstance(o, TypeAliasType) self.assertEqual(len(o.__parameters__), 1) - self.assertEqual(len(outer.__type_variables__), 1) + self.assertEqual(len(outer.__type_params__), 1) b = o.__parameters__[0] self.assertEqual(o.__type_params__, (b,)) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index d034422bc29f64..1c09deb7c957d0 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -238,7 +238,6 @@ def inner1(): exec(code, {}) - class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): code = textwrap.dedent("""\ @@ -379,8 +378,8 @@ def get_typeparams(): return A, B, C, D a, b, c, d = Outer.Inner.get_typeparams() - self.assertEqual(Outer.__type_variables__, (a, b)) - self.assertEqual(Outer.Inner.__type_variables__, (c, d)) + self.assertEqual(Outer.__type_params__, (a, b)) + self.assertEqual(Outer.Inner.__type_params__, (c, d)) self.assertEqual(Outer.__parameters__, (a, b)) self.assertEqual(Outer.Inner.__parameters__, (c, d)) @@ -389,17 +388,17 @@ def test_typeparams_dunder_class_02(self): class ClassA: pass - self.assertEqual(ClassA.__type_variables__, ()) + self.assertEqual(ClassA.__type_params__, ()) def test_typeparams_dunder_class_03(self): code = textwrap.dedent("""\ class ClassA[A](): pass - ClassA.__type_variables__ = () + ClassA.__type_params__ = () """ ) - with self.assertRaisesRegex(AttributeError, "attribute '__type_variables__' of 'type' objects is not writable"): + with self.assertRaisesRegex(AttributeError, "attribute '__type_params__' of 'type' objects is not writable"): exec(code, {}) def test_typeparams_dunder_function_01(self): @@ -411,22 +410,22 @@ def inner[C, D](): inner = outer() a, b, c, d = inner() - self.assertEqual(outer.__type_variables__, (a, b)) - self.assertEqual(inner.__type_variables__, (c, d)) + self.assertEqual(outer.__type_params__, (a, b)) + self.assertEqual(inner.__type_params__, (c, d)) def test_typeparams_dunder_function_02(self): def func1(): pass - self.assertEqual(func1.__type_variables__, ()) + self.assertEqual(func1.__type_params__, ()) def test_typeparams_dunder_function_03(self): code = textwrap.dedent("""\ def func[A](): pass - func.__type_variables__ = () + func.__type_params__ = () """ ) - with self.assertRaisesRegex(AttributeError, "attribute '__type_variables__' of 'function' objects is not writable"): + with self.assertRaisesRegex(AttributeError, "attribute '__type_params__' of 'function' objects is not writable"): exec(code, {}) diff --git a/Lib/typing.py b/Lib/typing.py index 414e146bb5637d..a73fe22d89a086 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1754,9 +1754,9 @@ def _lazy_load_getattr_static(): class _Dummy[T, *Ts, **P]: pass -TypeVar = type(_Dummy.__type_variables__[0]) -TypeVarTuple = type(_Dummy.__type_variables__[1]) -ParamSpec = type(_Dummy.__type_variables__[2]) +TypeVar = type(_Dummy.__type_params__[0]) +TypeVarTuple = type(_Dummy.__type_params__[1]) +ParamSpec = type(_Dummy.__type_params__[2]) ParamSpecArgs = type(ParamSpec("P").args) ParamSpecKwargs = type(ParamSpec("P").kwargs) Generic = _Dummy.__mro__[1] diff --git a/Objects/funcobject.c b/Objects/funcobject.c index c17a12753357f0..101155c5a6c753 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -655,7 +655,7 @@ func_set_annotations(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(igno } static PyObject * -func_get_type_variables(PyFunctionObject *op, void *Py_UNUSED(ignored)) +func_get_type_params(PyFunctionObject *op, void *Py_UNUSED(ignored)) { if (op->func_typevars == NULL) { return PyTuple_New(0); @@ -676,7 +676,7 @@ static PyGetSetDef func_getsetlist[] = { {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict}, {"__name__", (getter)func_get_name, (setter)func_set_name}, {"__qualname__", (getter)func_get_qualname, (setter)func_set_qualname}, - {"__type_variables__", (getter)func_get_type_variables, NULL}, + {"__type_params__", (getter)func_get_type_params, NULL}, {NULL} /* Sentinel */ }; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index b9541d2f4dfbb4..f3a8723baaf85c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1144,9 +1144,9 @@ type_get_annotations(PyTypeObject *type, void *context) } static PyObject * -type_get_type_variables(PyTypeObject *type, void *context) +type_get_type_params(PyTypeObject *type, void *context) { - PyObject *params = PyDict_GetItem(type->tp_dict, &_Py_ID(__type_variables__)); + PyObject *params = PyDict_GetItem(type->tp_dict, &_Py_ID(__type_params__)); if (params) { return Py_NewRef(params); @@ -1229,7 +1229,7 @@ static PyGetSetDef type_getsets[] = { {"__doc__", (getter)type_get_doc, (setter)type_set_doc, NULL}, {"__text_signature__", (getter)type_get_text_signature, NULL, NULL}, {"__annotations__", (getter)type_get_annotations, (setter)type_set_annotations, NULL}, - {"__type_variables__", (getter)type_get_type_variables, NULL, NULL}, + {"__type_params__", (getter)type_get_type_params, NULL, NULL}, {0} }; diff --git a/Python/compile.c b/Python/compile.c index 8b113d2f2ea8f4..6036cfc9151f65 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2296,7 +2296,7 @@ compiler_set_type_params_in_class(struct compiler *c, location loc) { _Py_DECLARE_STR(type_params, ".type_params"); RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_ID(__type_variables__), Store)); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_ID(__type_params__), Store)); return 1; } diff --git a/Python/symtable.c b/Python/symtable.c index d1148a3e5012c5..bdc098742a9ba6 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1354,7 +1354,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) tmp = st->st_private; st->st_private = s->v.ClassDef.name; if (asdl_seq_LEN(s->v.ClassDef.typeparams) > 0) { - if (!symtable_add_def(st, &_Py_ID(__type_variables__), + if (!symtable_add_def(st, &_Py_ID(__type_params__), DEF_LOCAL, LOCATION(s))) { VISIT_QUIT(st, 0); } From a6045f0e3eb5fbd69818ed82b3b8940eeadb9af2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 06:32:09 -0600 Subject: [PATCH 082/200] Remove POP_NULL --- Include/internal/pycore_opcode.h | 16 +- Include/opcode.h | 27 +- Lib/opcode.py | 1 - Python/bytecodes.c | 4 - Python/compile.c | 4 +- Python/generated_cases.c.h | 913 +++++++++++++++---------------- Python/opcode_metadata.h | 5 - Python/opcode_targets.h | 14 +- 8 files changed, 482 insertions(+), 502 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index e81e8c9d2fbfd5..1075966f1e2455 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -195,7 +195,6 @@ const uint8_t _PyOpcode_Deopt[256] = { [POP_JUMP_IF_NONE] = POP_JUMP_IF_NONE, [POP_JUMP_IF_NOT_NONE] = POP_JUMP_IF_NOT_NONE, [POP_JUMP_IF_TRUE] = POP_JUMP_IF_TRUE, - [POP_NULL] = POP_NULL, [POP_TOP] = POP_TOP, [PUSH_EXC_INFO] = PUSH_EXC_INFO, [PUSH_NULL] = PUSH_NULL, @@ -327,9 +326,9 @@ static const char *const _PyOpcode_OpName[266] = { [RETURN_VALUE] = "RETURN_VALUE", [LOAD_FAST__LOAD_FAST] = "LOAD_FAST__LOAD_FAST", [SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS", - [POP_NULL] = "POP_NULL", - [LOAD_LOCALS] = "LOAD_LOCALS", [LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN", + [LOAD_LOCALS] = "LOAD_LOCALS", + [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", [POP_EXCEPT] = "POP_EXCEPT", [STORE_NAME] = "STORE_NAME", [DELETE_NAME] = "DELETE_NAME", @@ -352,9 +351,9 @@ static const char *const _PyOpcode_OpName[266] = { [IMPORT_NAME] = "IMPORT_NAME", [IMPORT_FROM] = "IMPORT_FROM", [JUMP_FORWARD] = "JUMP_FORWARD", - [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", [STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE", [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", + [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", [POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE", [POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE", [LOAD_GLOBAL] = "LOAD_GLOBAL", @@ -384,7 +383,7 @@ static const char *const _PyOpcode_OpName[266] = { [JUMP_BACKWARD] = "JUMP_BACKWARD", [LOAD_SUPER_ATTR] = "LOAD_SUPER_ATTR", [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", - [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", + [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [EXTENDED_ARG] = "EXTENDED_ARG", [LIST_APPEND] = "LIST_APPEND", [SET_ADD] = "SET_ADD", @@ -394,21 +393,21 @@ static const char *const _PyOpcode_OpName[266] = { [YIELD_VALUE] = "YIELD_VALUE", [RESUME] = "RESUME", [MATCH_CLASS] = "MATCH_CLASS", - [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", + [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [FORMAT_VALUE] = "FORMAT_VALUE", [BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP", [BUILD_STRING] = "BUILD_STRING", - [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", + [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [LIST_EXTEND] = "LIST_EXTEND", [SET_UPDATE] = "SET_UPDATE", [DICT_MERGE] = "DICT_MERGE", [DICT_UPDATE] = "DICT_UPDATE", - [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [SEND_GEN] = "SEND_GEN", + [167] = "<167>", [168] = "<168>", [169] = "<169>", [170] = "<170>", @@ -511,6 +510,7 @@ static const char *const _PyOpcode_OpName[266] = { #endif #define EXTRA_CASES \ + case 167: \ case 168: \ case 169: \ case 170: \ diff --git a/Include/opcode.h b/Include/opcode.h index 0df2a5de7cecda..c5ebf8f651ee03 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -45,7 +45,6 @@ extern "C" { #define RETURN_GENERATOR 75 #define RETURN_VALUE 83 #define SETUP_ANNOTATIONS 85 -#define POP_NULL 86 #define LOAD_LOCALS 87 #define POP_EXCEPT 89 #define HAVE_ARGUMENT 90 @@ -199,19 +198,19 @@ extern "C" { #define LOAD_CONST__LOAD_FAST 81 #define LOAD_FAST__LOAD_CONST 82 #define LOAD_FAST__LOAD_FAST 84 -#define LOAD_GLOBAL_BUILTIN 88 -#define LOAD_GLOBAL_MODULE 111 -#define STORE_ATTR_INSTANCE_VALUE 112 -#define STORE_ATTR_SLOT 113 -#define STORE_ATTR_WITH_HINT 143 -#define STORE_FAST__LOAD_FAST 153 -#define STORE_FAST__STORE_FAST 154 -#define STORE_SUBSCR_DICT 158 -#define STORE_SUBSCR_LIST_INT 159 -#define UNPACK_SEQUENCE_LIST 160 -#define UNPACK_SEQUENCE_TUPLE 161 -#define UNPACK_SEQUENCE_TWO_TUPLE 166 -#define SEND_GEN 167 +#define LOAD_GLOBAL_BUILTIN 86 +#define LOAD_GLOBAL_MODULE 88 +#define STORE_ATTR_INSTANCE_VALUE 111 +#define STORE_ATTR_SLOT 112 +#define STORE_ATTR_WITH_HINT 113 +#define STORE_FAST__LOAD_FAST 143 +#define STORE_FAST__STORE_FAST 153 +#define STORE_SUBSCR_DICT 154 +#define STORE_SUBSCR_LIST_INT 158 +#define UNPACK_SEQUENCE_LIST 159 +#define UNPACK_SEQUENCE_TUPLE 160 +#define UNPACK_SEQUENCE_TWO_TUPLE 161 +#define SEND_GEN 166 #define HAS_ARG(op) ((((op) >= HAVE_ARGUMENT) && (!IS_PSEUDO_OPCODE(op)))\ || ((op) == JUMP) \ diff --git a/Lib/opcode.py b/Lib/opcode.py index 1034573f323725..8a7d08b83e7f2a 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -131,7 +131,6 @@ def pseudo_op(name, op, real_ops): def_op('RETURN_VALUE', 83) def_op('SETUP_ANNOTATIONS', 85) -def_op('POP_NULL', 86) def_op('LOAD_LOCALS', 87) def_op('POP_EXCEPT', 89) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 53d2bee00f403a..5494c4d23fc744 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -218,10 +218,6 @@ dummy_func( res = NULL; } - inst(POP_NULL, (value --)) { - assert(value == NULL); - } - macro(END_FOR) = POP_TOP + POP_TOP; inst(INSTRUMENTED_END_FOR, (receiver, value --)) { diff --git a/Python/compile.c b/Python/compile.c index 6036cfc9151f65..d48ca438aab5e9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2176,7 +2176,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) if (asdl_seq_LEN(typeparams) > 0) { ADDOP(c, loc, PUSH_NULL); // We'll swap in the callable here later. - ADDOP(c, loc, PUSH_NULL); + ADDOP_LOAD_CONST(c, loc, Py_None); PySTEntryObject *ste = PySymtable_Lookup(c->c_st, (void *)typeparams); if (ste == NULL) { return ERROR; @@ -2283,7 +2283,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } Py_DECREF(co); ADDOP_I(c, loc, SWAP, num_typeparam_args + 2); - ADDOP(c, loc, POP_NULL); + ADDOP(c, loc, POP_TOP); ADDOP_I(c, loc, CALL, num_typeparam_args); } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index b10fb1c8c3cf40..39fc66127849f9 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -256,28 +256,19 @@ DISPATCH(); } - TARGET(POP_NULL) { - PyObject *value = stack_pointer[-1]; - #line 222 "Python/bytecodes.c" - assert(value == NULL); - #line 264 "Python/generated_cases.c.h" - STACK_SHRINK(1); - DISPATCH(); - } - TARGET(END_FOR) { PyObject *_tmp_1 = stack_pointer[-1]; PyObject *_tmp_2 = stack_pointer[-2]; { PyObject *value = _tmp_1; #line 214 "Python/bytecodes.c" - #line 275 "Python/generated_cases.c.h" + #line 266 "Python/generated_cases.c.h" Py_DECREF(value); } { PyObject *value = _tmp_2; #line 214 "Python/bytecodes.c" - #line 281 "Python/generated_cases.c.h" + #line 272 "Python/generated_cases.c.h" Py_DECREF(value); } STACK_SHRINK(2); @@ -287,7 +278,7 @@ TARGET(INSTRUMENTED_END_FOR) { PyObject *value = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; - #line 228 "Python/bytecodes.c" + #line 224 "Python/bytecodes.c" /* Need to create a fake StopIteration error here, * to conform to PEP 380 */ if (PyGen_Check(receiver)) { @@ -297,7 +288,7 @@ } PyErr_SetRaisedException(NULL); } - #line 301 "Python/generated_cases.c.h" + #line 292 "Python/generated_cases.c.h" Py_DECREF(receiver); Py_DECREF(value); STACK_SHRINK(2); @@ -307,9 +298,9 @@ TARGET(END_SEND) { PyObject *value = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; - #line 241 "Python/bytecodes.c" + #line 237 "Python/bytecodes.c" Py_DECREF(receiver); - #line 313 "Python/generated_cases.c.h" + #line 304 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; DISPATCH(); @@ -318,7 +309,7 @@ TARGET(INSTRUMENTED_END_SEND) { PyObject *value = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; - #line 245 "Python/bytecodes.c" + #line 241 "Python/bytecodes.c" if (PyGen_Check(receiver) || PyCoro_CheckExact(receiver)) { PyErr_SetObject(PyExc_StopIteration, value); if (monitor_stop_iteration(tstate, frame, next_instr-1)) { @@ -327,7 +318,7 @@ PyErr_SetRaisedException(NULL); } Py_DECREF(receiver); - #line 331 "Python/generated_cases.c.h" + #line 322 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; DISPATCH(); @@ -336,13 +327,13 @@ TARGET(UNARY_NEGATIVE) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 256 "Python/bytecodes.c" + #line 252 "Python/bytecodes.c" res = PyNumber_Negative(value); - #line 342 "Python/generated_cases.c.h" + #line 333 "Python/generated_cases.c.h" Py_DECREF(value); - #line 258 "Python/bytecodes.c" + #line 254 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; - #line 346 "Python/generated_cases.c.h" + #line 337 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -350,11 +341,11 @@ TARGET(UNARY_NOT) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 262 "Python/bytecodes.c" + #line 258 "Python/bytecodes.c" int err = PyObject_IsTrue(value); - #line 356 "Python/generated_cases.c.h" + #line 347 "Python/generated_cases.c.h" Py_DECREF(value); - #line 264 "Python/bytecodes.c" + #line 260 "Python/bytecodes.c" if (err < 0) goto pop_1_error; if (err == 0) { res = Py_True; @@ -363,7 +354,7 @@ res = Py_False; } Py_INCREF(res); - #line 367 "Python/generated_cases.c.h" + #line 358 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -371,13 +362,13 @@ TARGET(UNARY_INVERT) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 275 "Python/bytecodes.c" + #line 271 "Python/bytecodes.c" res = PyNumber_Invert(value); - #line 377 "Python/generated_cases.c.h" + #line 368 "Python/generated_cases.c.h" Py_DECREF(value); - #line 277 "Python/bytecodes.c" + #line 273 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; - #line 381 "Python/generated_cases.c.h" + #line 372 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -386,7 +377,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; - #line 294 "Python/bytecodes.c" + #line 290 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -394,7 +385,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (prod == NULL) goto pop_2_error; - #line 398 "Python/generated_cases.c.h" + #line 389 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = prod; next_instr += 1; @@ -405,14 +396,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *prod; - #line 304 "Python/bytecodes.c" + #line 300 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); double dprod = ((PyFloatObject *)left)->ob_fval * ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dprod, prod); - #line 416 "Python/generated_cases.c.h" + #line 407 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = prod; next_instr += 1; @@ -423,7 +414,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; - #line 313 "Python/bytecodes.c" + #line 309 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(!PyLong_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -431,7 +422,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (sub == NULL) goto pop_2_error; - #line 435 "Python/generated_cases.c.h" + #line 426 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sub; next_instr += 1; @@ -442,13 +433,13 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sub; - #line 323 "Python/bytecodes.c" + #line 319 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(!PyFloat_CheckExact(right), BINARY_OP); STAT_INC(BINARY_OP, hit); double dsub = ((PyFloatObject *)left)->ob_fval - ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsub, sub); - #line 452 "Python/generated_cases.c.h" + #line 443 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sub; next_instr += 1; @@ -459,7 +450,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 331 "Python/bytecodes.c" + #line 327 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -467,7 +458,7 @@ _Py_DECREF_SPECIALIZED(left, _PyUnicode_ExactDealloc); _Py_DECREF_SPECIALIZED(right, _PyUnicode_ExactDealloc); if (res == NULL) goto pop_2_error; - #line 471 "Python/generated_cases.c.h" + #line 462 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -477,7 +468,7 @@ TARGET(BINARY_OP_INPLACE_ADD_UNICODE) { PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; - #line 347 "Python/bytecodes.c" + #line 343 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); _Py_CODEUNIT true_next = next_instr[INLINE_CACHE_ENTRIES_BINARY_OP]; @@ -504,7 +495,7 @@ if (*target_local == NULL) goto pop_2_error; // The STORE_FAST is already done. JUMPBY(INLINE_CACHE_ENTRIES_BINARY_OP + 1); - #line 508 "Python/generated_cases.c.h" + #line 499 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -513,14 +504,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; - #line 376 "Python/bytecodes.c" + #line 372 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); STAT_INC(BINARY_OP, hit); double dsum = ((PyFloatObject *)left)->ob_fval + ((PyFloatObject *)right)->ob_fval; DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dsum, sum); - #line 524 "Python/generated_cases.c.h" + #line 515 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sum; next_instr += 1; @@ -531,7 +522,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *sum; - #line 385 "Python/bytecodes.c" + #line 381 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), BINARY_OP); DEOPT_IF(Py_TYPE(right) != Py_TYPE(left), BINARY_OP); STAT_INC(BINARY_OP, hit); @@ -539,7 +530,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); if (sum == NULL) goto pop_2_error; - #line 543 "Python/generated_cases.c.h" + #line 534 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = sum; next_instr += 1; @@ -552,7 +543,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; PyObject *res; - #line 403 "Python/bytecodes.c" + #line 399 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinarySubscrCache *cache = (_PyBinarySubscrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -564,12 +555,12 @@ DECREMENT_ADAPTIVE_COUNTER(cache->counter); #endif /* ENABLE_SPECIALIZATION */ res = PyObject_GetItem(container, sub); - #line 568 "Python/generated_cases.c.h" + #line 559 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); - #line 415 "Python/bytecodes.c" + #line 411 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 573 "Python/generated_cases.c.h" + #line 564 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -581,7 +572,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *res; - #line 419 "Python/bytecodes.c" + #line 415 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); // Can't use ERROR_IF() here, because we haven't // DECREF'ed container yet, and we still own slice. @@ -594,7 +585,7 @@ } Py_DECREF(container); if (res == NULL) goto pop_3_error; - #line 598 "Python/generated_cases.c.h" + #line 589 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = res; DISPATCH(); @@ -605,7 +596,7 @@ PyObject *start = stack_pointer[-2]; PyObject *container = stack_pointer[-3]; PyObject *v = stack_pointer[-4]; - #line 434 "Python/bytecodes.c" + #line 430 "Python/bytecodes.c" PyObject *slice = _PyBuildSlice_ConsumeRefs(start, stop); int err; if (slice == NULL) { @@ -618,7 +609,7 @@ Py_DECREF(v); Py_DECREF(container); if (err) goto pop_4_error; - #line 622 "Python/generated_cases.c.h" + #line 613 "Python/generated_cases.c.h" STACK_SHRINK(4); DISPATCH(); } @@ -627,7 +618,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *res; - #line 449 "Python/bytecodes.c" + #line 445 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), BINARY_SUBSCR); @@ -641,7 +632,7 @@ Py_INCREF(res); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(list); - #line 645 "Python/generated_cases.c.h" + #line 636 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -652,7 +643,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *tuple = stack_pointer[-2]; PyObject *res; - #line 465 "Python/bytecodes.c" + #line 461 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(sub), BINARY_SUBSCR); DEOPT_IF(!PyTuple_CheckExact(tuple), BINARY_SUBSCR); @@ -666,7 +657,7 @@ Py_INCREF(res); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(tuple); - #line 670 "Python/generated_cases.c.h" + #line 661 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -677,7 +668,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *res; - #line 481 "Python/bytecodes.c" + #line 477 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(dict), BINARY_SUBSCR); STAT_INC(BINARY_SUBSCR, hit); res = PyDict_GetItemWithError(dict, sub); @@ -685,14 +676,14 @@ if (!_PyErr_Occurred(tstate)) { _PyErr_SetKeyError(sub); } - #line 689 "Python/generated_cases.c.h" + #line 680 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); - #line 489 "Python/bytecodes.c" + #line 485 "Python/bytecodes.c" if (true) goto pop_2_error; } Py_INCREF(res); // Do this before DECREF'ing dict, sub - #line 696 "Python/generated_cases.c.h" + #line 687 "Python/generated_cases.c.h" Py_DECREF(dict); Py_DECREF(sub); STACK_SHRINK(1); @@ -704,7 +695,7 @@ TARGET(BINARY_SUBSCR_GETITEM) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; - #line 496 "Python/bytecodes.c" + #line 492 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(container); DEOPT_IF(!PyType_HasFeature(tp, Py_TPFLAGS_HEAPTYPE), BINARY_SUBSCR); PyHeapTypeObject *ht = (PyHeapTypeObject *)tp; @@ -726,15 +717,15 @@ JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 730 "Python/generated_cases.c.h" + #line 721 "Python/generated_cases.c.h" } TARGET(LIST_APPEND) { PyObject *v = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 520 "Python/bytecodes.c" + #line 516 "Python/bytecodes.c" if (_PyList_AppendTakeRef((PyListObject *)list, v) < 0) goto pop_1_error; - #line 738 "Python/generated_cases.c.h" + #line 729 "Python/generated_cases.c.h" STACK_SHRINK(1); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -743,13 +734,13 @@ TARGET(SET_ADD) { PyObject *v = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 525 "Python/bytecodes.c" + #line 521 "Python/bytecodes.c" int err = PySet_Add(set, v); - #line 749 "Python/generated_cases.c.h" + #line 740 "Python/generated_cases.c.h" Py_DECREF(v); - #line 527 "Python/bytecodes.c" + #line 523 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 753 "Python/generated_cases.c.h" + #line 744 "Python/generated_cases.c.h" STACK_SHRINK(1); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -762,7 +753,7 @@ PyObject *container = stack_pointer[-2]; PyObject *v = stack_pointer[-3]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 538 "Python/bytecodes.c" + #line 534 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { next_instr--; @@ -777,13 +768,13 @@ #endif /* ENABLE_SPECIALIZATION */ /* container[sub] = v */ int err = PyObject_SetItem(container, sub, v); - #line 781 "Python/generated_cases.c.h" + #line 772 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(container); Py_DECREF(sub); - #line 553 "Python/bytecodes.c" + #line 549 "Python/bytecodes.c" if (err) goto pop_3_error; - #line 787 "Python/generated_cases.c.h" + #line 778 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -793,7 +784,7 @@ PyObject *sub = stack_pointer[-1]; PyObject *list = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; - #line 557 "Python/bytecodes.c" + #line 553 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(sub), STORE_SUBSCR); DEOPT_IF(!PyList_CheckExact(list), STORE_SUBSCR); @@ -810,7 +801,7 @@ Py_DECREF(old_value); _Py_DECREF_SPECIALIZED(sub, (destructor)PyObject_Free); Py_DECREF(list); - #line 814 "Python/generated_cases.c.h" + #line 805 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -820,13 +811,13 @@ PyObject *sub = stack_pointer[-1]; PyObject *dict = stack_pointer[-2]; PyObject *value = stack_pointer[-3]; - #line 576 "Python/bytecodes.c" + #line 572 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(dict), STORE_SUBSCR); STAT_INC(STORE_SUBSCR, hit); int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, value); Py_DECREF(dict); if (err) goto pop_3_error; - #line 830 "Python/generated_cases.c.h" + #line 821 "Python/generated_cases.c.h" STACK_SHRINK(3); next_instr += 1; DISPATCH(); @@ -835,15 +826,15 @@ TARGET(DELETE_SUBSCR) { PyObject *sub = stack_pointer[-1]; PyObject *container = stack_pointer[-2]; - #line 584 "Python/bytecodes.c" + #line 580 "Python/bytecodes.c" /* del container[sub] */ int err = PyObject_DelItem(container, sub); - #line 842 "Python/generated_cases.c.h" + #line 833 "Python/generated_cases.c.h" Py_DECREF(container); Py_DECREF(sub); - #line 587 "Python/bytecodes.c" + #line 583 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 847 "Python/generated_cases.c.h" + #line 838 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -851,14 +842,14 @@ TARGET(CALL_INTRINSIC_1) { PyObject *value = stack_pointer[-1]; PyObject *res; - #line 591 "Python/bytecodes.c" + #line 587 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_1); res = _PyIntrinsics_UnaryFunctions[oparg](tstate, value); - #line 858 "Python/generated_cases.c.h" + #line 849 "Python/generated_cases.c.h" Py_DECREF(value); - #line 594 "Python/bytecodes.c" + #line 590 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; - #line 862 "Python/generated_cases.c.h" + #line 853 "Python/generated_cases.c.h" stack_pointer[-1] = res; DISPATCH(); } @@ -867,15 +858,15 @@ PyObject *value1 = stack_pointer[-1]; PyObject *value2 = stack_pointer[-2]; PyObject *res; - #line 598 "Python/bytecodes.c" + #line 594 "Python/bytecodes.c" assert(oparg <= MAX_INTRINSIC_2); res = _PyIntrinsics_BinaryFunctions[oparg](tstate, value2, value1); - #line 874 "Python/generated_cases.c.h" + #line 865 "Python/generated_cases.c.h" Py_DECREF(value2); Py_DECREF(value1); - #line 601 "Python/bytecodes.c" + #line 597 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 879 "Python/generated_cases.c.h" + #line 870 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -883,7 +874,7 @@ TARGET(RAISE_VARARGS) { PyObject **args = (stack_pointer - oparg); - #line 605 "Python/bytecodes.c" + #line 601 "Python/bytecodes.c" PyObject *cause = NULL, *exc = NULL; switch (oparg) { case 2: @@ -901,12 +892,12 @@ break; } if (true) { STACK_SHRINK(oparg); goto error; } - #line 905 "Python/generated_cases.c.h" + #line 896 "Python/generated_cases.c.h" } TARGET(INTERPRETER_EXIT) { PyObject *retval = stack_pointer[-1]; - #line 625 "Python/bytecodes.c" + #line 621 "Python/bytecodes.c" assert(frame == &entry_frame); assert(_PyFrame_IsIncomplete(frame)); STACK_SHRINK(1); // Since we're not going to DISPATCH() @@ -917,12 +908,12 @@ assert(!_PyErr_Occurred(tstate)); _Py_LeaveRecursiveCallTstate(tstate); return retval; - #line 921 "Python/generated_cases.c.h" + #line 912 "Python/generated_cases.c.h" } TARGET(RETURN_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 638 "Python/bytecodes.c" + #line 634 "Python/bytecodes.c" STACK_SHRINK(1); assert(EMPTY()); _PyFrame_SetStackPointer(frame, stack_pointer); @@ -935,12 +926,12 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 939 "Python/generated_cases.c.h" + #line 930 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_RETURN_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 653 "Python/bytecodes.c" + #line 649 "Python/bytecodes.c" int err = _Py_call_instrumentation_arg( tstate, PY_MONITORING_EVENT_PY_RETURN, frame, next_instr-1, retval); @@ -957,11 +948,11 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 961 "Python/generated_cases.c.h" + #line 952 "Python/generated_cases.c.h" } TARGET(RETURN_CONST) { - #line 672 "Python/bytecodes.c" + #line 668 "Python/bytecodes.c" PyObject *retval = GETITEM(frame->f_code->co_consts, oparg); Py_INCREF(retval); assert(EMPTY()); @@ -975,11 +966,11 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 979 "Python/generated_cases.c.h" + #line 970 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_RETURN_CONST) { - #line 688 "Python/bytecodes.c" + #line 684 "Python/bytecodes.c" PyObject *retval = GETITEM(frame->f_code->co_consts, oparg); int err = _Py_call_instrumentation_arg( tstate, PY_MONITORING_EVENT_PY_RETURN, @@ -997,13 +988,13 @@ frame->prev_instr += frame->return_offset; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 1001 "Python/generated_cases.c.h" + #line 992 "Python/generated_cases.c.h" } TARGET(GET_AITER) { PyObject *obj = stack_pointer[-1]; PyObject *iter; - #line 708 "Python/bytecodes.c" + #line 704 "Python/bytecodes.c" unaryfunc getter = NULL; PyTypeObject *type = Py_TYPE(obj); @@ -1016,16 +1007,16 @@ "'async for' requires an object with " "__aiter__ method, got %.100s", type->tp_name); - #line 1020 "Python/generated_cases.c.h" + #line 1011 "Python/generated_cases.c.h" Py_DECREF(obj); - #line 721 "Python/bytecodes.c" + #line 717 "Python/bytecodes.c" if (true) goto pop_1_error; } iter = (*getter)(obj); - #line 1027 "Python/generated_cases.c.h" + #line 1018 "Python/generated_cases.c.h" Py_DECREF(obj); - #line 726 "Python/bytecodes.c" + #line 722 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; if (Py_TYPE(iter)->tp_as_async == NULL || @@ -1038,7 +1029,7 @@ Py_DECREF(iter); if (true) goto pop_1_error; } - #line 1042 "Python/generated_cases.c.h" + #line 1033 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -1046,7 +1037,7 @@ TARGET(GET_ANEXT) { PyObject *aiter = stack_pointer[-1]; PyObject *awaitable; - #line 741 "Python/bytecodes.c" + #line 737 "Python/bytecodes.c" unaryfunc getter = NULL; PyObject *next_iter = NULL; PyTypeObject *type = Py_TYPE(aiter); @@ -1090,7 +1081,7 @@ } } - #line 1094 "Python/generated_cases.c.h" + #line 1085 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = awaitable; PREDICT(LOAD_CONST); @@ -1101,16 +1092,16 @@ PREDICTED(GET_AWAITABLE); PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 788 "Python/bytecodes.c" + #line 784 "Python/bytecodes.c" iter = _PyCoro_GetAwaitableIter(iterable); if (iter == NULL) { format_awaitable_error(tstate, Py_TYPE(iterable), oparg); } - #line 1112 "Python/generated_cases.c.h" + #line 1103 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 795 "Python/bytecodes.c" + #line 791 "Python/bytecodes.c" if (iter != NULL && PyCoro_CheckExact(iter)) { PyObject *yf = _PyGen_yf((PyGenObject*)iter); @@ -1128,7 +1119,7 @@ if (iter == NULL) goto pop_1_error; - #line 1132 "Python/generated_cases.c.h" + #line 1123 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -1139,7 +1130,7 @@ PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; PyObject *retval; - #line 821 "Python/bytecodes.c" + #line 817 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PySendCache *cache = (_PySendCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1185,7 +1176,7 @@ } } Py_DECREF(v); - #line 1189 "Python/generated_cases.c.h" + #line 1180 "Python/generated_cases.c.h" stack_pointer[-1] = retval; next_instr += 1; DISPATCH(); @@ -1194,7 +1185,7 @@ TARGET(SEND_GEN) { PyObject *v = stack_pointer[-1]; PyObject *receiver = stack_pointer[-2]; - #line 869 "Python/bytecodes.c" + #line 865 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)receiver; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type && Py_TYPE(gen) != &PyCoro_Type, SEND); @@ -1209,12 +1200,12 @@ tstate->exc_info = &gen->gi_exc_state; JUMPBY(INLINE_CACHE_ENTRIES_SEND); DISPATCH_INLINED(gen_frame); - #line 1213 "Python/generated_cases.c.h" + #line 1204 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_YIELD_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 886 "Python/bytecodes.c" + #line 882 "Python/bytecodes.c" assert(frame != &entry_frame); PyGenObject *gen = _PyFrame_GetGenerator(frame); gen->gi_frame_state = FRAME_SUSPENDED; @@ -1231,12 +1222,12 @@ gen_frame->previous = NULL; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 1235 "Python/generated_cases.c.h" + #line 1226 "Python/generated_cases.c.h" } TARGET(YIELD_VALUE) { PyObject *retval = stack_pointer[-1]; - #line 905 "Python/bytecodes.c" + #line 901 "Python/bytecodes.c" // NOTE: It's important that YIELD_VALUE never raises an exception! // The compiler treats any exception raised here as a failed close() // or throw() call. @@ -1252,15 +1243,15 @@ gen_frame->previous = NULL; _PyFrame_StackPush(frame, retval); goto resume_frame; - #line 1256 "Python/generated_cases.c.h" + #line 1247 "Python/generated_cases.c.h" } TARGET(POP_EXCEPT) { PyObject *exc_value = stack_pointer[-1]; - #line 923 "Python/bytecodes.c" + #line 919 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; Py_XSETREF(exc_info->exc_value, exc_value); - #line 1264 "Python/generated_cases.c.h" + #line 1255 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -1268,7 +1259,7 @@ TARGET(RERAISE) { PyObject *exc = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); - #line 928 "Python/bytecodes.c" + #line 924 "Python/bytecodes.c" assert(oparg >= 0 && oparg <= 2); if (oparg) { PyObject *lasti = values[0]; @@ -1286,26 +1277,26 @@ Py_INCREF(exc); _PyErr_SetRaisedException(tstate, exc); goto exception_unwind; - #line 1290 "Python/generated_cases.c.h" + #line 1281 "Python/generated_cases.c.h" } TARGET(END_ASYNC_FOR) { PyObject *exc = stack_pointer[-1]; PyObject *awaitable = stack_pointer[-2]; - #line 948 "Python/bytecodes.c" + #line 944 "Python/bytecodes.c" assert(exc && PyExceptionInstance_Check(exc)); if (PyErr_GivenExceptionMatches(exc, PyExc_StopAsyncIteration)) { - #line 1299 "Python/generated_cases.c.h" + #line 1290 "Python/generated_cases.c.h" Py_DECREF(awaitable); Py_DECREF(exc); - #line 951 "Python/bytecodes.c" + #line 947 "Python/bytecodes.c" } else { Py_INCREF(exc); _PyErr_SetRaisedException(tstate, exc); goto exception_unwind; } - #line 1309 "Python/generated_cases.c.h" + #line 1300 "Python/generated_cases.c.h" STACK_SHRINK(2); DISPATCH(); } @@ -1316,23 +1307,23 @@ PyObject *sub_iter = stack_pointer[-3]; PyObject *none; PyObject *value; - #line 960 "Python/bytecodes.c" + #line 956 "Python/bytecodes.c" assert(throwflag); assert(exc_value && PyExceptionInstance_Check(exc_value)); if (PyErr_GivenExceptionMatches(exc_value, PyExc_StopIteration)) { value = Py_NewRef(((PyStopIterationObject *)exc_value)->value); - #line 1325 "Python/generated_cases.c.h" + #line 1316 "Python/generated_cases.c.h" Py_DECREF(sub_iter); Py_DECREF(last_sent_val); Py_DECREF(exc_value); - #line 965 "Python/bytecodes.c" + #line 961 "Python/bytecodes.c" none = Py_NewRef(Py_None); } else { _PyErr_SetRaisedException(tstate, Py_NewRef(exc_value)); goto exception_unwind; } - #line 1336 "Python/generated_cases.c.h" + #line 1327 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = value; stack_pointer[-2] = none; @@ -1341,9 +1332,9 @@ TARGET(LOAD_ASSERTION_ERROR) { PyObject *value; - #line 974 "Python/bytecodes.c" + #line 970 "Python/bytecodes.c" value = Py_NewRef(PyExc_AssertionError); - #line 1347 "Python/generated_cases.c.h" + #line 1338 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1351,7 +1342,7 @@ TARGET(LOAD_BUILD_CLASS) { PyObject *bc; - #line 978 "Python/bytecodes.c" + #line 974 "Python/bytecodes.c" if (PyDict_CheckExact(BUILTINS())) { bc = _PyDict_GetItemWithError(BUILTINS(), &_Py_ID(__build_class__)); @@ -1373,7 +1364,7 @@ if (true) goto error; } } - #line 1377 "Python/generated_cases.c.h" + #line 1368 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = bc; DISPATCH(); @@ -1381,7 +1372,7 @@ TARGET(LOAD_LOCALS) { PyObject *locals; - #line 1002 "Python/bytecodes.c" + #line 998 "Python/bytecodes.c" locals = LOCALS(); if (locals == NULL) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -1389,7 +1380,7 @@ if (true) goto error; } Py_INCREF(locals); - #line 1393 "Python/generated_cases.c.h" + #line 1384 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = locals; DISPATCH(); @@ -1397,33 +1388,33 @@ TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 1012 "Python/bytecodes.c" + #line 1008 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); - #line 1408 "Python/generated_cases.c.h" + #line 1399 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1019 "Python/bytecodes.c" + #line 1015 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); - #line 1417 "Python/generated_cases.c.h" + #line 1408 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1026 "Python/bytecodes.c" + #line 1022 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1421 "Python/generated_cases.c.h" + #line 1412 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { - #line 1030 "Python/bytecodes.c" + #line 1026 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1440,7 +1431,7 @@ name); goto error; } - #line 1444 "Python/generated_cases.c.h" + #line 1435 "Python/generated_cases.c.h" DISPATCH(); } @@ -1448,7 +1439,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 1056 "Python/bytecodes.c" + #line 1052 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1461,11 +1452,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); - #line 1465 "Python/generated_cases.c.h" + #line 1456 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1069 "Python/bytecodes.c" + #line 1065 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1469 "Python/generated_cases.c.h" + #line 1460 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1475,14 +1466,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1073 "Python/bytecodes.c" + #line 1069 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); - #line 1486 "Python/generated_cases.c.h" + #line 1477 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1493,7 +1484,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1083 "Python/bytecodes.c" + #line 1079 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1501,7 +1492,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1505 "Python/generated_cases.c.h" + #line 1496 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1512,7 +1503,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1094 "Python/bytecodes.c" + #line 1090 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1520,7 +1511,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1524 "Python/generated_cases.c.h" + #line 1515 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1530,15 +1521,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 1105 "Python/bytecodes.c" + #line 1101 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); - #line 1538 "Python/generated_cases.c.h" + #line 1529 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1109 "Python/bytecodes.c" + #line 1105 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1542 "Python/generated_cases.c.h" + #line 1533 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1549,7 +1540,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 1120 "Python/bytecodes.c" + #line 1116 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1565,12 +1556,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); - #line 1569 "Python/generated_cases.c.h" + #line 1560 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1136 "Python/bytecodes.c" + #line 1132 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 1574 "Python/generated_cases.c.h" + #line 1565 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1578,34 +1569,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1140 "Python/bytecodes.c" + #line 1136 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); - #line 1585 "Python/generated_cases.c.h" + #line 1576 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1143 "Python/bytecodes.c" + #line 1139 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1589 "Python/generated_cases.c.h" + #line 1580 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1147 "Python/bytecodes.c" + #line 1143 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); - #line 1599 "Python/generated_cases.c.h" + #line 1590 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1150 "Python/bytecodes.c" + #line 1146 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1603 "Python/generated_cases.c.h" + #line 1594 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { - #line 1154 "Python/bytecodes.c" + #line 1150 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1617,13 +1608,13 @@ } goto error; } - #line 1621 "Python/generated_cases.c.h" + #line 1612 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASS_OR_GLOBAL) { PyObject *v; - #line 1168 "Python/bytecodes.c" + #line 1164 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = GETLOCAL(0); if (locals == NULL) { @@ -1682,7 +1673,7 @@ } } } - #line 1686 "Python/generated_cases.c.h" + #line 1677 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1690,7 +1681,7 @@ TARGET(LOAD_NAME) { PyObject *v; - #line 1229 "Python/bytecodes.c" + #line 1225 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = LOCALS(); if (locals == NULL) { @@ -1749,7 +1740,7 @@ } } } - #line 1753 "Python/generated_cases.c.h" + #line 1744 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1760,7 +1751,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1296 "Python/bytecodes.c" + #line 1292 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1812,7 +1803,7 @@ } } null = NULL; - #line 1816 "Python/generated_cases.c.h" + #line 1807 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1826,7 +1817,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1350 "Python/bytecodes.c" + #line 1346 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1837,7 +1828,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1841 "Python/generated_cases.c.h" + #line 1832 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1852,7 +1843,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1363 "Python/bytecodes.c" + #line 1359 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1867,7 +1858,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1871 "Python/generated_cases.c.h" + #line 1862 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1877,16 +1868,16 @@ } TARGET(DELETE_FAST) { - #line 1380 "Python/bytecodes.c" + #line 1376 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1885 "Python/generated_cases.c.h" + #line 1876 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1386 "Python/bytecodes.c" + #line 1382 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1895,12 +1886,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1899 "Python/generated_cases.c.h" + #line 1890 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1397 "Python/bytecodes.c" + #line 1393 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1911,13 +1902,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1915 "Python/generated_cases.c.h" + #line 1906 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1410 "Python/bytecodes.c" + #line 1406 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1949,7 +1940,7 @@ } Py_INCREF(value); } - #line 1953 "Python/generated_cases.c.h" + #line 1944 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1957,7 +1948,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1444 "Python/bytecodes.c" + #line 1440 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1965,7 +1956,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1969 "Python/generated_cases.c.h" + #line 1960 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1973,18 +1964,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1454 "Python/bytecodes.c" + #line 1450 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 1982 "Python/generated_cases.c.h" + #line 1973 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1461 "Python/bytecodes.c" + #line 1457 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1995,22 +1986,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 1999 "Python/generated_cases.c.h" + #line 1990 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1474 "Python/bytecodes.c" + #line 1470 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2008 "Python/generated_cases.c.h" + #line 1999 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1476 "Python/bytecodes.c" + #line 1472 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2014 "Python/generated_cases.c.h" + #line 2005 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2020,10 +2011,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1480 "Python/bytecodes.c" + #line 1476 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2027 "Python/generated_cases.c.h" + #line 2018 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2033,10 +2024,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1485 "Python/bytecodes.c" + #line 1481 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2040 "Python/generated_cases.c.h" + #line 2031 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2046,7 +2037,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1490 "Python/bytecodes.c" + #line 1486 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2057,13 +2048,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2061 "Python/generated_cases.c.h" + #line 2052 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1501 "Python/bytecodes.c" + #line 1497 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2067 "Python/generated_cases.c.h" + #line 2058 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2072,13 +2063,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1508 "Python/bytecodes.c" + #line 1504 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2078 "Python/generated_cases.c.h" + #line 2069 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1510 "Python/bytecodes.c" + #line 1506 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2082 "Python/generated_cases.c.h" + #line 2073 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2086,7 +2077,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1514 "Python/bytecodes.c" + #line 1510 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2101,7 +2092,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2105 "Python/generated_cases.c.h" + #line 2096 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2111,7 +2102,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1531 "Python/bytecodes.c" + #line 1527 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2119,13 +2110,13 @@ if (map == NULL) goto error; - #line 2123 "Python/generated_cases.c.h" + #line 2114 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1539 "Python/bytecodes.c" + #line 1535 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2129 "Python/generated_cases.c.h" + #line 2120 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2133,7 +2124,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1543 "Python/bytecodes.c" + #line 1539 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2173,7 +2164,7 @@ Py_DECREF(ann_dict); } } - #line 2177 "Python/generated_cases.c.h" + #line 2168 "Python/generated_cases.c.h" DISPATCH(); } @@ -2181,7 +2172,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1585 "Python/bytecodes.c" + #line 1581 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2191,14 +2182,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2195 "Python/generated_cases.c.h" + #line 2186 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1595 "Python/bytecodes.c" + #line 1591 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2202 "Python/generated_cases.c.h" + #line 2193 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2206,7 +2197,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1599 "Python/bytecodes.c" + #line 1595 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2214,12 +2205,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2218 "Python/generated_cases.c.h" + #line 2209 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1607 "Python/bytecodes.c" + #line 1603 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2223 "Python/generated_cases.c.h" + #line 2214 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2227,17 +2218,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1613 "Python/bytecodes.c" + #line 1609 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2236 "Python/generated_cases.c.h" + #line 2227 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1618 "Python/bytecodes.c" + #line 1614 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2241 "Python/generated_cases.c.h" + #line 2232 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2247,13 +2238,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1625 "Python/bytecodes.c" + #line 1621 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2257 "Python/generated_cases.c.h" + #line 2248 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2265,7 +2256,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1634 "Python/bytecodes.c" + #line 1630 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); if (global_super == (PyObject *)&PySuper_Type && PyType_Check(class)) { int method = 0; @@ -2287,17 +2278,17 @@ } else { PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2291 "Python/generated_cases.c.h" + #line 2282 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1656 "Python/bytecodes.c" + #line 1652 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; } - #line 2301 "Python/generated_cases.c.h" + #line 2292 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2311,7 +2302,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1678 "Python/bytecodes.c" + #line 1674 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2345,9 +2336,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2349 "Python/generated_cases.c.h" + #line 2340 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1712 "Python/bytecodes.c" + #line 1708 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2356,12 +2347,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2360 "Python/generated_cases.c.h" + #line 2351 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1721 "Python/bytecodes.c" + #line 1717 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2365 "Python/generated_cases.c.h" + #line 2356 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2375,7 +2366,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1726 "Python/bytecodes.c" + #line 1722 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2388,7 +2379,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2392 "Python/generated_cases.c.h" + #line 2383 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2403,7 +2394,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1742 "Python/bytecodes.c" + #line 1738 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2416,7 +2407,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2420 "Python/generated_cases.c.h" + #line 2411 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2431,7 +2422,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1758 "Python/bytecodes.c" + #line 1754 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2458,7 +2449,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2462 "Python/generated_cases.c.h" + #line 2453 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2473,7 +2464,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1788 "Python/bytecodes.c" + #line 1784 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2483,7 +2474,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2487 "Python/generated_cases.c.h" + #line 2478 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2498,7 +2489,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1801 "Python/bytecodes.c" + #line 1797 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2510,7 +2501,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2514 "Python/generated_cases.c.h" + #line 2505 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2524,7 +2515,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1816 "Python/bytecodes.c" + #line 1812 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2548,7 +2539,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2552 "Python/generated_cases.c.h" + #line 2543 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2556,7 +2547,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1842 "Python/bytecodes.c" + #line 1838 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2582,7 +2573,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2586 "Python/generated_cases.c.h" + #line 2577 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2590,7 +2581,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1870 "Python/bytecodes.c" + #line 1866 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2608,7 +2599,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2612 "Python/generated_cases.c.h" + #line 2603 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2619,7 +2610,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1890 "Python/bytecodes.c" + #line 1886 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2658,7 +2649,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2662 "Python/generated_cases.c.h" + #line 2653 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2669,7 +2660,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1931 "Python/bytecodes.c" + #line 1927 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2679,7 +2670,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2683 "Python/generated_cases.c.h" + #line 2674 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2691,7 +2682,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1950 "Python/bytecodes.c" + #line 1946 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2704,12 +2695,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2708 "Python/generated_cases.c.h" + #line 2699 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1963 "Python/bytecodes.c" + #line 1959 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2713 "Python/generated_cases.c.h" + #line 2704 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2720,7 +2711,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1967 "Python/bytecodes.c" + #line 1963 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2732,7 +2723,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2736 "Python/generated_cases.c.h" + #line 2727 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2743,7 +2734,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1982 "Python/bytecodes.c" + #line 1978 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2759,7 +2750,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2763 "Python/generated_cases.c.h" + #line 2754 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2770,7 +2761,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2001 "Python/bytecodes.c" + #line 1997 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2783,7 +2774,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2787 "Python/generated_cases.c.h" + #line 2778 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2794,14 +2785,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2016 "Python/bytecodes.c" + #line 2012 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2800 "Python/generated_cases.c.h" + #line 2791 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2018 "Python/bytecodes.c" + #line 2014 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2805 "Python/generated_cases.c.h" + #line 2796 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2811,15 +2802,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2022 "Python/bytecodes.c" + #line 2018 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2817 "Python/generated_cases.c.h" + #line 2808 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2024 "Python/bytecodes.c" + #line 2020 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2823 "Python/generated_cases.c.h" + #line 2814 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2830,12 +2821,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2029 "Python/bytecodes.c" + #line 2025 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2836 "Python/generated_cases.c.h" + #line 2827 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2031 "Python/bytecodes.c" + #line 2027 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2843,10 +2834,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2847 "Python/generated_cases.c.h" + #line 2838 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2039 "Python/bytecodes.c" + #line 2035 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2855,7 +2846,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2859 "Python/generated_cases.c.h" + #line 2850 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2865,21 +2856,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2050 "Python/bytecodes.c" + #line 2046 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2872 "Python/generated_cases.c.h" + #line 2863 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2053 "Python/bytecodes.c" + #line 2049 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2879 "Python/generated_cases.c.h" + #line 2870 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2058 "Python/bytecodes.c" + #line 2054 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2883 "Python/generated_cases.c.h" + #line 2874 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2888,15 +2879,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2062 "Python/bytecodes.c" + #line 2058 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2895 "Python/generated_cases.c.h" + #line 2886 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2065 "Python/bytecodes.c" + #line 2061 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2900 "Python/generated_cases.c.h" + #line 2891 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2905,29 +2896,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2069 "Python/bytecodes.c" + #line 2065 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2913 "Python/generated_cases.c.h" + #line 2904 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2075 "Python/bytecodes.c" + #line 2071 "Python/bytecodes.c" JUMPBY(oparg); - #line 2922 "Python/generated_cases.c.h" + #line 2913 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2079 "Python/bytecodes.c" + #line 2075 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2931 "Python/generated_cases.c.h" + #line 2922 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2935,7 +2926,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2085 "Python/bytecodes.c" + #line 2081 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2945,9 +2936,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2949 "Python/generated_cases.c.h" + #line 2940 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2095 "Python/bytecodes.c" + #line 2091 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2955,14 +2946,14 @@ if (err < 0) goto pop_1_error; } } - #line 2959 "Python/generated_cases.c.h" + #line 2950 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2105 "Python/bytecodes.c" + #line 2101 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2972,9 +2963,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2976 "Python/generated_cases.c.h" + #line 2967 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2115 "Python/bytecodes.c" + #line 2111 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2982,67 +2973,67 @@ if (err < 0) goto pop_1_error; } } - #line 2986 "Python/generated_cases.c.h" + #line 2977 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2125 "Python/bytecodes.c" + #line 2121 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 2995 "Python/generated_cases.c.h" + #line 2986 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2127 "Python/bytecodes.c" + #line 2123 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3003 "Python/generated_cases.c.h" + #line 2994 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2135 "Python/bytecodes.c" + #line 2131 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3016 "Python/generated_cases.c.h" + #line 3007 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2141 "Python/bytecodes.c" + #line 2137 "Python/bytecodes.c" } - #line 3020 "Python/generated_cases.c.h" + #line 3011 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2145 "Python/bytecodes.c" + #line 2141 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3033 "Python/generated_cases.c.h" + #line 3024 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2154 "Python/bytecodes.c" + #line 2150 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3046 "Python/generated_cases.c.h" + #line 3037 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3053,16 +3044,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2162 "Python/bytecodes.c" + #line 2158 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3062 "Python/generated_cases.c.h" + #line 3053 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2167 "Python/bytecodes.c" + #line 2163 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3070,7 +3061,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3074 "Python/generated_cases.c.h" + #line 3065 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3079,10 +3070,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2177 "Python/bytecodes.c" + #line 2173 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3086 "Python/generated_cases.c.h" + #line 3077 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3092,10 +3083,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2183 "Python/bytecodes.c" + #line 2179 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3099 "Python/generated_cases.c.h" + #line 3090 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3106,11 +3097,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2189 "Python/bytecodes.c" + #line 2185 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3114 "Python/generated_cases.c.h" + #line 3105 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3119,14 +3110,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2195 "Python/bytecodes.c" + #line 2191 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3126 "Python/generated_cases.c.h" + #line 3117 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2198 "Python/bytecodes.c" + #line 2194 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3130 "Python/generated_cases.c.h" + #line 3121 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3134,7 +3125,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2202 "Python/bytecodes.c" + #line 2198 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3157,11 +3148,11 @@ if (iter == NULL) { goto error; } - #line 3161 "Python/generated_cases.c.h" + #line 3152 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2225 "Python/bytecodes.c" + #line 2221 "Python/bytecodes.c" } - #line 3165 "Python/generated_cases.c.h" + #line 3156 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3172,7 +3163,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2244 "Python/bytecodes.c" + #line 2240 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3203,7 +3194,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3207 "Python/generated_cases.c.h" + #line 3198 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3211,7 +3202,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2277 "Python/bytecodes.c" + #line 2273 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3237,14 +3228,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3241 "Python/generated_cases.c.h" + #line 3232 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2305 "Python/bytecodes.c" + #line 2301 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3264,7 +3255,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3268 "Python/generated_cases.c.h" + #line 3259 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3274,7 +3265,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2327 "Python/bytecodes.c" + #line 2323 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3294,7 +3285,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3298 "Python/generated_cases.c.h" + #line 3289 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3304,7 +3295,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2349 "Python/bytecodes.c" + #line 2345 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3322,7 +3313,7 @@ if (next == NULL) { goto error; } - #line 3326 "Python/generated_cases.c.h" + #line 3317 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3331,7 +3322,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2369 "Python/bytecodes.c" + #line 2365 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3346,14 +3337,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3350 "Python/generated_cases.c.h" + #line 3341 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2386 "Python/bytecodes.c" + #line 2382 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3376,16 +3367,16 @@ Py_DECREF(enter); goto error; } - #line 3380 "Python/generated_cases.c.h" + #line 3371 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2409 "Python/bytecodes.c" + #line 2405 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3389 "Python/generated_cases.c.h" + #line 3380 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3397,7 +3388,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2419 "Python/bytecodes.c" + #line 2415 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3423,16 +3414,16 @@ Py_DECREF(enter); goto error; } - #line 3427 "Python/generated_cases.c.h" + #line 3418 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2445 "Python/bytecodes.c" + #line 2441 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3436 "Python/generated_cases.c.h" + #line 3427 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3444,7 +3435,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2454 "Python/bytecodes.c" + #line 2450 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3465,7 +3456,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3469 "Python/generated_cases.c.h" + #line 3460 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3474,7 +3465,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2477 "Python/bytecodes.c" + #line 2473 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3484,7 +3475,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3488 "Python/generated_cases.c.h" + #line 3479 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3498,7 +3489,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2489 "Python/bytecodes.c" + #line 2485 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3515,7 +3506,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3519 "Python/generated_cases.c.h" + #line 3510 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3529,7 +3520,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2508 "Python/bytecodes.c" + #line 2504 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3539,7 +3530,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3543 "Python/generated_cases.c.h" + #line 3534 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3553,7 +3544,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2520 "Python/bytecodes.c" + #line 2516 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3567,7 +3558,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3571 "Python/generated_cases.c.h" + #line 3562 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3576,16 +3567,16 @@ } TARGET(KW_NAMES) { - #line 2536 "Python/bytecodes.c" + #line 2532 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3584 "Python/generated_cases.c.h" + #line 3575 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2542 "Python/bytecodes.c" + #line 2538 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3598,7 +3589,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3602 "Python/generated_cases.c.h" + #line 3593 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3608,7 +3599,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2587 "Python/bytecodes.c" + #line 2583 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3690,7 +3681,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3694 "Python/generated_cases.c.h" + #line 3685 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3702,7 +3693,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2675 "Python/bytecodes.c" + #line 2671 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3712,7 +3703,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3716 "Python/generated_cases.c.h" + #line 3707 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3721,7 +3712,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2687 "Python/bytecodes.c" + #line 2683 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3747,7 +3738,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3751 "Python/generated_cases.c.h" + #line 3742 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3755,7 +3746,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2715 "Python/bytecodes.c" + #line 2711 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3791,7 +3782,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3795 "Python/generated_cases.c.h" + #line 3786 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3799,7 +3790,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2753 "Python/bytecodes.c" + #line 2749 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3809,7 +3800,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3813 "Python/generated_cases.c.h" + #line 3804 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3822,7 +3813,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2765 "Python/bytecodes.c" + #line 2761 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3833,7 +3824,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3837 "Python/generated_cases.c.h" + #line 3828 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3847,7 +3838,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2779 "Python/bytecodes.c" + #line 2775 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3858,7 +3849,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3862 "Python/generated_cases.c.h" + #line 3853 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3872,7 +3863,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2793 "Python/bytecodes.c" + #line 2789 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3894,7 +3885,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3898 "Python/generated_cases.c.h" + #line 3889 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3908,7 +3899,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2818 "Python/bytecodes.c" + #line 2814 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3936,7 +3927,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3940 "Python/generated_cases.c.h" + #line 3931 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3950,7 +3941,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2849 "Python/bytecodes.c" + #line 2845 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3982,7 +3973,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 3986 "Python/generated_cases.c.h" + #line 3977 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3996,7 +3987,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2884 "Python/bytecodes.c" + #line 2880 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4028,7 +4019,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4032 "Python/generated_cases.c.h" + #line 4023 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4042,7 +4033,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2919 "Python/bytecodes.c" + #line 2915 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4067,7 +4058,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4071 "Python/generated_cases.c.h" + #line 4062 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4080,7 +4071,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2946 "Python/bytecodes.c" + #line 2942 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4107,7 +4098,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4111 "Python/generated_cases.c.h" + #line 4102 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4119,7 +4110,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2976 "Python/bytecodes.c" + #line 2972 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4137,14 +4128,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4141 "Python/generated_cases.c.h" + #line 4132 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2996 "Python/bytecodes.c" + #line 2992 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4175,7 +4166,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4179 "Python/generated_cases.c.h" + #line 4170 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4188,7 +4179,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3030 "Python/bytecodes.c" + #line 3026 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4217,7 +4208,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4221 "Python/generated_cases.c.h" + #line 4212 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4230,7 +4221,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3062 "Python/bytecodes.c" + #line 3058 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4259,7 +4250,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4263 "Python/generated_cases.c.h" + #line 4254 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4272,7 +4263,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3094 "Python/bytecodes.c" + #line 3090 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4300,7 +4291,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4304 "Python/generated_cases.c.h" + #line 4295 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4310,9 +4301,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3125 "Python/bytecodes.c" + #line 3121 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4316 "Python/generated_cases.c.h" + #line 4307 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4321,7 +4312,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3129 "Python/bytecodes.c" + #line 3125 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4364,14 +4355,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4368 "Python/generated_cases.c.h" + #line 4359 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3172 "Python/bytecodes.c" + #line 3168 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4375 "Python/generated_cases.c.h" + #line 4366 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4387,7 +4378,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3183 "Python/bytecodes.c" + #line 3179 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4420,14 +4411,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4424 "Python/generated_cases.c.h" + #line 4415 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3218 "Python/bytecodes.c" + #line 3214 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4448,7 +4439,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4452 "Python/generated_cases.c.h" + #line 4443 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4456,15 +4447,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3241 "Python/bytecodes.c" + #line 3237 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4462 "Python/generated_cases.c.h" + #line 4453 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3243 "Python/bytecodes.c" + #line 3239 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4468 "Python/generated_cases.c.h" + #line 4459 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4475,7 +4466,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3247 "Python/bytecodes.c" + #line 3243 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4510,7 +4501,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4514 "Python/generated_cases.c.h" + #line 4505 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4519,10 +4510,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3284 "Python/bytecodes.c" + #line 3280 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4526 "Python/generated_cases.c.h" + #line 4517 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4534,7 +4525,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3289 "Python/bytecodes.c" + #line 3285 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4549,12 +4540,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4553 "Python/generated_cases.c.h" + #line 4544 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3304 "Python/bytecodes.c" + #line 3300 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4558 "Python/generated_cases.c.h" + #line 4549 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4564,16 +4555,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3309 "Python/bytecodes.c" + #line 3305 "Python/bytecodes.c" assert(oparg >= 2); - #line 4570 "Python/generated_cases.c.h" + #line 4561 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3313 "Python/bytecodes.c" + #line 3309 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4593,11 +4584,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4597 "Python/generated_cases.c.h" + #line 4588 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3335 "Python/bytecodes.c" + #line 3331 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4609,26 +4600,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4613 "Python/generated_cases.c.h" + #line 4604 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3349 "Python/bytecodes.c" + #line 3345 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4619 "Python/generated_cases.c.h" + #line 4610 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3353 "Python/bytecodes.c" + #line 3349 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4626 "Python/generated_cases.c.h" + #line 4617 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3358 "Python/bytecodes.c" + #line 3354 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4637,12 +4628,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4641 "Python/generated_cases.c.h" + #line 4632 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3369 "Python/bytecodes.c" + #line 3365 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4651,12 +4642,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4655 "Python/generated_cases.c.h" + #line 4646 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3380 "Python/bytecodes.c" + #line 3376 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4669,12 +4660,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4673 "Python/generated_cases.c.h" + #line 4664 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3395 "Python/bytecodes.c" + #line 3391 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4687,30 +4678,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4691 "Python/generated_cases.c.h" + #line 4682 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3410 "Python/bytecodes.c" + #line 3406 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4702 "Python/generated_cases.c.h" + #line 4693 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3418 "Python/bytecodes.c" + #line 3414 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4709 "Python/generated_cases.c.h" + #line 4700 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3423 "Python/bytecodes.c" + #line 3419 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4716 "Python/generated_cases.c.h" + #line 4707 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index ba193bc7229006..28ba2310b066ba 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -39,8 +39,6 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 1; case PUSH_NULL: return 0; - case POP_NULL: - return 1; case END_FOR: return 1+1; case INSTRUMENTED_END_FOR: @@ -431,8 +429,6 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case PUSH_NULL: return 1; - case POP_NULL: - return 0; case END_FOR: return 0+0; case INSTRUMENTED_END_FOR: @@ -812,7 +808,6 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [LOAD_CONST__LOAD_FAST] = { true, INSTR_FMT_IBIB }, [POP_TOP] = { true, INSTR_FMT_IX }, [PUSH_NULL] = { true, INSTR_FMT_IX }, - [POP_NULL] = { true, INSTR_FMT_IX }, [END_FOR] = { true, INSTR_FMT_IB }, [INSTRUMENTED_END_FOR] = { true, INSTR_FMT_IX }, [END_SEND] = { true, INSTR_FMT_IX }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index e892159d08827e..dad81648185eab 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -85,9 +85,9 @@ static void *opcode_targets[256] = { &&TARGET_RETURN_VALUE, &&TARGET_LOAD_FAST__LOAD_FAST, &&TARGET_SETUP_ANNOTATIONS, - &&TARGET_POP_NULL, - &&TARGET_LOAD_LOCALS, &&TARGET_LOAD_GLOBAL_BUILTIN, + &&TARGET_LOAD_LOCALS, + &&TARGET_LOAD_GLOBAL_MODULE, &&TARGET_POP_EXCEPT, &&TARGET_STORE_NAME, &&TARGET_DELETE_NAME, @@ -110,9 +110,9 @@ static void *opcode_targets[256] = { &&TARGET_IMPORT_NAME, &&TARGET_IMPORT_FROM, &&TARGET_JUMP_FORWARD, - &&TARGET_LOAD_GLOBAL_MODULE, &&TARGET_STORE_ATTR_INSTANCE_VALUE, &&TARGET_STORE_ATTR_SLOT, + &&TARGET_STORE_ATTR_WITH_HINT, &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_LOAD_GLOBAL, @@ -142,7 +142,7 @@ static void *opcode_targets[256] = { &&TARGET_JUMP_BACKWARD, &&TARGET_LOAD_SUPER_ATTR, &&TARGET_CALL_FUNCTION_EX, - &&TARGET_STORE_ATTR_WITH_HINT, + &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_EXTENDED_ARG, &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, @@ -152,24 +152,24 @@ static void *opcode_targets[256] = { &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, - &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_STORE_FAST__STORE_FAST, + &&TARGET_STORE_SUBSCR_DICT, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, - &&TARGET_STORE_SUBSCR_DICT, &&TARGET_STORE_SUBSCR_LIST_INT, &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_UNPACK_SEQUENCE_TUPLE, + &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, + &&_unknown_opcode, &&TARGET_CALL, &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, From 2c8b4f1755ac88db9afa2ad36a0c61605b549c91 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 08:37:55 -0600 Subject: [PATCH 083/200] Lazily evaluate TypeVar bounds/constraints --- Include/internal/pycore_intrinsics.h | 3 +- Include/internal/pycore_typevarobject.h | 2 +- Lib/test/test_type_params.py | 36 +++++++++++++++ Objects/typevarobject.c | 60 ++++++++++++++++++++----- Python/compile.c | 24 +++++++++- Python/intrinsics.c | 16 +++++-- Python/symtable.c | 9 +++- 7 files changed, 132 insertions(+), 18 deletions(-) diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index cb6240b5b309d5..806e61d78dbbda 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -20,8 +20,9 @@ #define INTRINSIC_PREP_RERAISE_STAR 1 #define INTRINSIC_TYPEVAR_WITH_BOUND 2 +#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3 -#define MAX_INTRINSIC_2 2 +#define MAX_INTRINSIC_2 3 typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value); diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index 9e8b175ad231fc..9f312fbba0740a 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -8,7 +8,7 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -extern PyObject *_Py_make_typevar(const char *, PyObject *); +extern PyObject *_Py_make_typevar(const char *, PyObject *, PyObject *); extern PyObject *_Py_make_paramspec(PyThreadState *, PyObject *); extern PyObject *_Py_make_typevartuple(PyThreadState *, PyObject *); extern PyObject *_Py_make_typealias(PyThreadState *, PyObject *); diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 1c09deb7c957d0..af98bab1365818 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -4,6 +4,7 @@ from typing import TypeVar, TypeVarTuple, ParamSpec + class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): code = """def func[**A, A](): ...""" @@ -238,6 +239,41 @@ def inner1(): exec(code, {}) +class TypeParamsLazyEvaluationTest(unittest.TestCase): + def test_recursive_class(self): + class Foo[T: Foo, U: (Foo, Foo)]: + pass + + type_params = Foo.__type_params__ + self.assertEqual(len(type_params), 2) + self.assertEqual(type_params[0].__name__, "T") + self.assertEqual(type_params[0].__bound__, Foo) + self.assertEqual(type_params[0].__constraints__, None) + + self.assertEqual(type_params[1].__name__, "U") + self.assertEqual(type_params[1].__bound__, None) + self.assertEqual(type_params[1].__constraints__, (Foo, Foo)) + + def test_evaluation_error(self): + class Foo[T: Undefined, U: (Undefined,)]: + pass + + type_params = Foo.__type_params__ + with self.assertRaises(NameError): + type_params[0].__bound__ + self.assertEqual(type_params[0].__constraints__, None) + self.assertEqual(type_params[1].__bound__, None) + with self.assertRaises(NameError): + type_params[1].__constraints__ + + Undefined = "defined" + self.assertEqual(type_params[0].__bound__, "defined") + self.assertEqual(type_params[0].__constraints__, None) + + self.assertEqual(type_params[1].__bound__, None) + self.assertEqual(type_params[1].__constraints__, ("defined",)) + + class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): code = textwrap.dedent("""\ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 6342a21fc45fd7..213f6483683bf5 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -20,7 +20,9 @@ typedef struct { PyObject_HEAD const char *name; PyObject *bound; + PyObject *evaluate_bound; PyObject *constraints; + PyObject *evaluate_constraints; bool covariant; bool contravariant; bool infer_variance; @@ -187,7 +189,9 @@ typevar_dealloc(PyObject *self) free((void *)tv->name); Py_XDECREF(tv->bound); + Py_XDECREF(tv->evaluate_bound); Py_XDECREF(tv->constraints); + Py_XDECREF(tv->evaluate_constraints); _PyObject_ClearManagedDict(self); Py_TYPE(self)->tp_free(self); @@ -200,7 +204,9 @@ typevar_traverse(PyObject *self, visitproc visit, void *arg) Py_VISIT(Py_TYPE(self)); typevarobject *tv = (typevarobject *)self; Py_VISIT(tv->bound); + Py_VISIT(tv->evaluate_bound); Py_VISIT(tv->constraints); + Py_VISIT(tv->evaluate_constraints); _PyObject_VisitManagedDict(self, visit, arg); return 0; } @@ -220,16 +226,49 @@ typevar_repr(PyObject *self) static PyMemberDef typevar_members[] = { {"__name__", T_STRING, offsetof(typevarobject, name), READONLY}, - {"__bound__", T_OBJECT, offsetof(typevarobject, bound), READONLY}, - {"__constraints__", T_OBJECT, offsetof(typevarobject, constraints), READONLY}, {"__covariant__", T_BOOL, offsetof(typevarobject, covariant), READONLY}, {"__contravariant__", T_BOOL, offsetof(typevarobject, contravariant), READONLY}, {"__infer_variance__", T_BOOL, offsetof(typevarobject, infer_variance), READONLY}, {0} }; +static PyObject * +typevar_bound(typevarobject *self, void *unused) +{ + if (self->bound != NULL) { + return Py_NewRef(self->bound); + } + if (self->evaluate_bound == NULL) { + Py_RETURN_NONE; + } + PyObject *bound = PyObject_CallNoArgs(self->evaluate_bound); + self->bound = Py_XNewRef(bound); + return bound; +} + +static PyObject * +typevar_constraints(typevarobject *self, void *unused) +{ + if (self->constraints != NULL) { + return Py_NewRef(self->constraints); + } + if (self->evaluate_constraints == NULL) { + Py_RETURN_NONE; + } + PyObject *constraints = PyObject_CallNoArgs(self->evaluate_constraints); + self->constraints = Py_XNewRef(constraints); + return constraints; +} + +static PyGetSetDef typevar_getset[] = { + {"__bound__", (getter)typevar_bound, NULL, NULL, NULL}, + {"__constraints__", (getter)typevar_constraints, NULL, NULL, NULL}, + {0} +}; + static typevarobject * -typevar_alloc(const char *name, PyObject *bound, PyObject *constraints, +typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, + PyObject *constraints, PyObject *evaluate_constraints, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { @@ -247,7 +286,9 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *constraints, } tv->bound = Py_XNewRef(bound); + tv->evaluate_bound = Py_XNewRef(evaluate_bound); tv->constraints = Py_XNewRef(constraints); + tv->evaluate_constraints = Py_XNewRef(evaluate_constraints); tv->covariant = covariant; tv->contravariant = contravariant; @@ -328,7 +369,8 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, return NULL; } - PyObject *tv = (PyObject *)typevar_alloc(name, bound, constraints, + PyObject *tv = (PyObject *)typevar_alloc(name, bound, NULL, + constraints, NULL, covariant, contravariant, infer_variance, module); Py_XDECREF(bound); @@ -438,6 +480,7 @@ static PyType_Slot typevar_slots[] = { {Py_tp_traverse, typevar_traverse}, {Py_tp_repr, typevar_repr}, {Py_tp_members, typevar_members}, + {Py_tp_getset, typevar_getset}, {0, NULL}, }; @@ -1146,13 +1189,10 @@ PyType_Spec typevartuple_spec = { }; PyObject * -_Py_make_typevar(const char *name, PyObject *bound_or_constraints) +_Py_make_typevar(const char *name, PyObject *evaluate_bound, PyObject *evaluate_constraints) { - if (bound_or_constraints != NULL && PyTuple_CheckExact(bound_or_constraints)) { - return (PyObject *)typevar_alloc(name, NULL, bound_or_constraints, false, false, true, NULL); - } else { - return (PyObject *)typevar_alloc(name, bound_or_constraints, NULL, false, false, true, NULL); - } + return (PyObject *)typevar_alloc(name, NULL, evaluate_bound, NULL, evaluate_constraints, + false, false, true, NULL); } PyObject * diff --git a/Python/compile.c b/Python/compile.c index d48ca438aab5e9..a206a8d3e69a76 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2094,8 +2094,28 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) case TypeVar_kind: ADDOP_LOAD_CONST(c, loc, typeparam->v.TypeVar.name); if (typeparam->v.TypeVar.bound) { - VISIT(c, expr, typeparam->v.TypeVar.bound); - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_TYPEVAR_WITH_BOUND); + expr_ty bound = typeparam->v.TypeVar.bound; + if (compiler_enter_scope(c, typeparam->v.TypeVar.name, COMPILER_SCOPE_TYPEPARAMS, + (void *)typeparam, bound->lineno) == -1) { + return ERROR; + } + VISIT(c, expr, bound); + ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); + PyCodeObject *co = optimize_and_assemble(c, 1); + compiler_exit_scope(c); + if (co == NULL) { + return ERROR; + } + if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + + int intrinsic = bound->kind == Tuple_kind + ? INTRINSIC_TYPEVAR_WITH_CONSTRAINTS + : INTRINSIC_TYPEVAR_WITH_BOUND; + ADDOP_I(c, loc, CALL_INTRINSIC_2, intrinsic); } else { ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEVAR); diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 01ac4b2eeb8737..6d33b23800cb6f 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -204,7 +204,7 @@ static PyObject * make_typevar(PyThreadState* unused, PyObject *v) { assert(PyUnicode_Check(v)); - return _Py_make_typevar(PyUnicode_AsUTF8(v), NULL); + return _Py_make_typevar(PyUnicode_AsUTF8(v), NULL, NULL); } const instrinsic_func1 @@ -235,14 +235,24 @@ prep_reraise_star(PyThreadState* unused, PyObject *orig, PyObject *excs) } static PyObject * -make_typevar_with_bound(PyThreadState* unused, PyObject *name, PyObject *bound) +make_typevar_with_bound(PyThreadState* unused, PyObject *name, + PyObject *evaluate_bound) { assert(PyUnicode_Check(name)); - return _Py_make_typevar(PyUnicode_AsUTF8(name), bound); + return _Py_make_typevar(PyUnicode_AsUTF8(name), evaluate_bound, NULL); } +static PyObject * +make_typevar_with_constraints(PyThreadState* unused, PyObject *name, + PyObject *evaluate_constraints) +{ + assert(PyUnicode_Check(name)); + return _Py_make_typevar(PyUnicode_AsUTF8(name), NULL, + evaluate_constraints); +} const instrinsic_func2 _PyIntrinsics_BinaryFunctions[] = { [INTRINSIC_PREP_RERAISE_STAR] = prep_reraise_star, [INTRINSIC_TYPEVAR_WITH_BOUND] = make_typevar_with_bound, + [INTRINSIC_TYPEVAR_WITH_CONSTRAINTS] = make_typevar_with_constraints, }; diff --git a/Python/symtable.c b/Python/symtable.c index bdc098742a9ba6..2c47f04fce8bf5 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1925,8 +1925,15 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) case TypeVar_kind: if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); - if (tp->v.TypeVar.bound) + if (tp->v.TypeVar.bound) { + if (!symtable_enter_block(st, tp->v.TypeVar.name, + FunctionBlock, (void *)tp, + LOCATION(tp))) + VISIT_QUIT(st, 0); VISIT(st, expr, tp->v.TypeVar.bound); + if (!symtable_exit_block(st)) + VISIT_QUIT(st, 0); + } break; case TypeVarTuple_kind: if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) From 66851e6b63c18ce6420093b4c52e5e04c1df4b3b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 08:43:16 -0600 Subject: [PATCH 084/200] Add NEWS --- .../2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst new file mode 100644 index 00000000000000..db0c4df0335b5f --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst @@ -0,0 +1,2 @@ +Implement :pep:`695`, adding syntactic support for generic classes, generic +functions, and type aliases. Patch by Eric Traut and Jelle Zijlstra. From ac7f72262513b5b7dc57eaa32838a4d1ad177175 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 09:26:23 -0600 Subject: [PATCH 085/200] Disallow yield/yield from/await/walrus --- Include/internal/pycore_symtable.h | 4 ++- Lib/test/test_type_params.py | 20 ++++++++++++++ Python/compile.c | 14 +++++----- Python/symtable.c | 43 +++++++++++++++++++++--------- 4 files changed, 61 insertions(+), 20 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 827c46a1d88b67..5beb4755c113dc 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -10,7 +10,8 @@ extern "C" { struct _mod; // Type defined in pycore_ast.h -typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, AnnotationBlock } +typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, + AnnotationBlock, TypeVarBoundBlock, TypeAliasBlock } _Py_block_ty; typedef enum _comprehension_type { @@ -83,6 +84,7 @@ extern PyTypeObject PySTEntry_Type; extern long _PyST_GetSymbol(PySTEntryObject *, PyObject *); extern int _PyST_GetScope(PySTEntryObject *, PyObject *); +extern int _PyST_IsFunctionLike(PySTEntryObject *); extern struct symtable* _PySymtable_Build( struct _mod *mod, diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index af98bab1365818..b34a8da40cc0a6 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -99,6 +99,26 @@ def inner[X](): ) exec(code, {}) + def test_disallowed_expressions(self): + with self.assertRaises(SyntaxError): + exec("type X = (yield)", {}) + with self.assertRaises(SyntaxError): + exec("type X = (yield from x)", {}) + with self.assertRaises(SyntaxError): + exec("type X = (await 42)", {}) + with self.assertRaises(SyntaxError): + exec("async def f(): type X = (yield)", {}) + with self.assertRaises(SyntaxError): + exec("type X = (y := 3)", {}) + with self.assertRaises(SyntaxError): + exec("class X[T: (yield)]: pass", {}) + with self.assertRaises(SyntaxError): + exec("class X[T: (yield from x)]: pass", {}) + with self.assertRaises(SyntaxError): + exec("class X[T: (await 42)]: pass", {}) + with self.assertRaises(SyntaxError): + exec("class X[T: (y := 3)]: pass", {}) + class TypeParamsAccessTest(unittest.TestCase): def test_class_access_01(self): diff --git a/Python/compile.c b/Python/compile.c index a206a8d3e69a76..a84c754e560193 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2983,7 +2983,7 @@ compiler_return(struct compiler *c, stmt_ty s) location loc = LOC(s); int preserve_tos = ((s->v.Return.value != NULL) && (s->v.Return.value->kind != Constant_kind)); - if (c->u->u_ste->ste_type != FunctionBlock) { + if (!_PyST_IsFunctionLike(c->u->u_ste)) { return compiler_error(c, loc, "'return' outside function"); } if (s->v.Return.value != NULL && @@ -4005,11 +4005,11 @@ compiler_nameop(struct compiler *c, location loc, optype = OP_DEREF; break; case LOCAL: - if (c->u->u_ste->ste_type == FunctionBlock) + if (_PyST_IsFunctionLike(c->u->u_ste)) optype = OP_FAST; break; case GLOBAL_IMPLICIT: - if (c->u->u_ste->ste_type == FunctionBlock) + if (_PyST_IsFunctionLike(c->u->u_ste)) optype = OP_GLOBAL; break; case GLOBAL_EXPLICIT: @@ -5674,7 +5674,7 @@ compiler_visit_expr1(struct compiler *c, expr_ty e) case DictComp_kind: return compiler_dictcomp(c, e); case Yield_kind: - if (c->u->u_ste->ste_type != FunctionBlock) { + if (!_PyST_IsFunctionLike(c->u->u_ste)) { return compiler_error(c, loc, "'yield' outside function"); } if (e->v.Yield.value) { @@ -5686,7 +5686,7 @@ compiler_visit_expr1(struct compiler *c, expr_ty e) ADDOP_YIELD(c, loc); break; case YieldFrom_kind: - if (c->u->u_ste->ste_type != FunctionBlock) { + if (!_PyST_IsFunctionLike(c->u->u_ste)) { return compiler_error(c, loc, "'yield' outside function"); } if (c->u->u_scope_type == COMPILER_SCOPE_ASYNC_FUNCTION) { @@ -5699,7 +5699,7 @@ compiler_visit_expr1(struct compiler *c, expr_ty e) break; case Await_kind: if (!IS_TOP_LEVEL_AWAIT(c)){ - if (c->u->u_ste->ste_type != FunctionBlock){ + if (!_PyST_IsFunctionLike(c->u->u_ste)) { return compiler_error(c, loc, "'await' outside function"); } @@ -6986,7 +6986,7 @@ compute_code_flags(struct compiler *c) { PySTEntryObject *ste = c->u->u_ste; int flags = 0; - if (ste->ste_type == FunctionBlock) { + if (_PyST_IsFunctionLike(c->u->u_ste)) { flags |= CO_NEWLOCALS | CO_OPTIMIZED; if (ste->ste_nested) flags |= CO_NESTED; diff --git a/Python/symtable.c b/Python/symtable.c index 2c47f04fce8bf5..752995be6c7de1 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -47,6 +47,12 @@ #define ANNOTATION_NOT_ALLOWED \ "'%s' can not be used within an annotation" +#define TYPEVAR_BOUND_NOT_ALLOWED \ +"'%s' can not be used within a TypeVar bound" + +#define TYPEALIAS_NOT_ALLOWED \ +"'%s' can not be used within a type alias" + #define DUPLICATE_TYPE_PARAM \ "duplicate type parameter '%U'" @@ -98,7 +104,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, if (st->st_cur != NULL && (st->st_cur->ste_nested || - st->st_cur->ste_type == FunctionBlock)) + _PyST_IsFunctionLike(st->st_cur))) ste->ste_nested = 1; ste->ste_child_free = 0; ste->ste_generator = 0; @@ -407,6 +413,14 @@ _PyST_GetScope(PySTEntryObject *ste, PyObject *name) return (symbol >> SCOPE_OFFSET) & SCOPE_MASK; } +int +_PyST_IsFunctionLike(PySTEntryObject *ste) +{ + return ste->ste_type == FunctionBlock + || ste->ste_type == TypeVarBoundBlock + || ste->ste_type == TypeAliasBlock; +} + static int error_at_directive(PySTEntryObject *ste, PyObject *name) { @@ -818,7 +832,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, /* Populate global and bound sets to be passed to children. */ if (ste->ste_type != ClassBlock) { /* Add function locals to bound set */ - if (ste->ste_type == FunctionBlock) { + if (_PyST_IsFunctionLike(ste)) { if (PyDict_Update(newbound, local) < 0) { goto error; } @@ -876,7 +890,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_DECREF(temp); /* Check if any local variables must be converted to cell variables */ - if (ste->ste_type == FunctionBlock && !analyze_cells(scopes, newfree)) + if (_PyST_IsFunctionLike(ste) && !analyze_cells(scopes, newfree)) goto error; else if (ste->ste_type == ClassBlock && !drop_class_free(ste, newfree)) goto error; @@ -1388,7 +1402,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) } VISIT_SEQ(st, typeparam, s->v.TypeAlias.typeparams); } - if (!symtable_enter_block(st, name, FunctionBlock, + if (!symtable_enter_block(st, name, TypeAliasBlock, (void *)s, LOCATION(s))) VISIT_QUIT(st, 0); VISIT(st, expr, s->v.TypeAlias.value); @@ -1688,7 +1702,7 @@ symtable_extend_namedexpr_scope(struct symtable *st, expr_ty e) } /* If we find a FunctionBlock entry, add as GLOBAL/LOCAL or NONLOCAL/LOCAL */ - if (ste->ste_type == FunctionBlock) { + if (_PyST_IsFunctionLike(ste)) { long target_in_scope = _PyST_GetSymbol(ste, target_name); if (target_in_scope & DEF_GLOBAL) { if (!symtable_add_def(st, target_name, DEF_GLOBAL, LOCATION(e))) @@ -1723,7 +1737,7 @@ symtable_extend_namedexpr_scope(struct symtable *st, expr_ty e) } } - /* We should always find either a FunctionBlock, ModuleBlock or ClassBlock + /* We should always find either a function-like block, ModuleBlock or ClassBlock and should never fall to this case */ Py_UNREACHABLE(); @@ -1896,7 +1910,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e) VISIT_QUIT(st, 0); /* Special-case super: it counts as a use of __class__ */ if (e->v.Name.ctx == Load && - st->st_cur->ste_type == FunctionBlock && + _PyST_IsFunctionLike(st->st_cur) && _PyUnicode_EqualToASCIIString(e->v.Name.id, "super")) { if (!symtable_add_def(st, &_Py_ID(__class__), USE, LOCATION(e))) VISIT_QUIT(st, 0); @@ -1927,8 +1941,8 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) VISIT_QUIT(st, 0); if (tp->v.TypeVar.bound) { if (!symtable_enter_block(st, tp->v.TypeVar.name, - FunctionBlock, (void *)tp, - LOCATION(tp))) + TypeVarBoundBlock, (void *)tp, + LOCATION(tp))) VISIT_QUIT(st, 0); VISIT(st, expr, tp->v.TypeVar.bound); if (!symtable_exit_block(st)) @@ -2318,11 +2332,16 @@ symtable_visit_dictcomp(struct symtable *st, expr_ty e) static int symtable_raise_if_annotation_block(struct symtable *st, const char *name, expr_ty e) { - if (st->st_cur->ste_type != AnnotationBlock) { + enum _block_type type = st->st_cur->ste_type; + if (type == AnnotationBlock) + PyErr_Format(PyExc_SyntaxError, ANNOTATION_NOT_ALLOWED, name); + else if (type == TypeVarBoundBlock) + PyErr_Format(PyExc_SyntaxError, TYPEVAR_BOUND_NOT_ALLOWED, name); + else if (type == TypeAliasBlock) + PyErr_Format(PyExc_SyntaxError, TYPEALIAS_NOT_ALLOWED, name); + else return 1; - } - PyErr_Format(PyExc_SyntaxError, ANNOTATION_NOT_ALLOWED, name); PyErr_RangedSyntaxLocationObject(st->st_filename, e->lineno, e->col_offset + 1, From 0f709251ddcc7ba3496e2ad22debdb1c7429cded Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 09:36:50 -0600 Subject: [PATCH 086/200] fix doctests --- Doc/library/ast.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index 0811b3fa0e7842..eb6a973cac62d2 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -1724,6 +1724,7 @@ Function and class definitions body=[ FunctionDef( name='f', + typeparams=[], args=arguments( posonlyargs=[], args=[ @@ -1847,6 +1848,7 @@ Function and class definitions body=[ ClassDef( name='Foo', + typeparams=[], bases=[ Name(id='base1', ctx=Load()), Name(id='base2', ctx=Load())], @@ -1885,6 +1887,7 @@ Async and await body=[ AsyncFunctionDef( name='f', + typeparams=[], args=arguments( posonlyargs=[], args=[], From e17c3b0edc78650eca277637753ecc24573df88d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 09:49:39 -0600 Subject: [PATCH 087/200] Stop altering the execution environment --- Lib/test/test_type_params.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index b34a8da40cc0a6..eec8922f805c87 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -376,6 +376,7 @@ async def coroutine[B](): co = get_coroutine() + self.addCleanup(asyncio.set_event_loop_policy, None) a, b = asyncio.run(co()) self.assertIsInstance(a, TypeVar) From 45696aeb9c978a6faebec5ee1f46e18fdc74f530 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 10:18:03 -0600 Subject: [PATCH 088/200] Disallow walrus/yield while evaluating generics --- Include/internal/pycore_symtable.h | 3 ++- Lib/test/test_type_params.py | 13 ++++++++++++- Python/symtable.c | 10 ++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 5beb4755c113dc..b95e4c64e104d1 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -11,7 +11,8 @@ extern "C" { struct _mod; // Type defined in pycore_ast.h typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, - AnnotationBlock, TypeVarBoundBlock, TypeAliasBlock } + AnnotationBlock, TypeVarBoundBlock, TypeAliasBlock, + TypeParamBlock } _Py_block_ty; typedef enum _comprehension_type { diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index eec8922f805c87..9c7f40a2166f7f 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -2,7 +2,7 @@ import textwrap import unittest -from typing import TypeVar, TypeVarTuple, ParamSpec +from typing import Sequence, TypeVar, TypeVarTuple, ParamSpec class TypeParamsInvalidTest(unittest.TestCase): @@ -118,6 +118,10 @@ def test_disallowed_expressions(self): exec("class X[T: (await 42)]: pass", {}) with self.assertRaises(SyntaxError): exec("class X[T: (y := 3)]: pass", {}) + with self.assertRaises(SyntaxError): + exec("class X[T](y := Sequence[T]): pass", {}) + with self.assertRaises(SyntaxError): + exec("def f[T](y: (x := Sequence[T])): pass", {}) class TypeParamsAccessTest(unittest.TestCase): @@ -258,6 +262,13 @@ def inner1(): with self.assertRaisesRegex(SyntaxError, "nonlocal binding not allowed for type parameter 'T'"): exec(code, {}) + def test_reference_previous_typevar(self): + def func[S, T: Sequence[S]](): + pass + + S, T = func.__type_params__ + self.assertEqual(T.__bound__, Sequence[S]) + class TypeParamsLazyEvaluationTest(unittest.TestCase): def test_recursive_class(self): diff --git a/Python/symtable.c b/Python/symtable.c index 752995be6c7de1..ed7c7189783cee 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -53,6 +53,9 @@ #define TYPEALIAS_NOT_ALLOWED \ "'%s' can not be used within a type alias" +#define TYPEPARAM_NOT_ALLOWED \ +"'%s' can not be used within the definition of a generic" + #define DUPLICATE_TYPE_PARAM \ "duplicate type parameter '%U'" @@ -418,7 +421,8 @@ _PyST_IsFunctionLike(PySTEntryObject *ste) { return ste->ste_type == FunctionBlock || ste->ste_type == TypeVarBoundBlock - || ste->ste_type == TypeAliasBlock; + || ste->ste_type == TypeAliasBlock + || ste->ste_type == TypeParamBlock; } static int @@ -1162,7 +1166,7 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, int end_lineno, int end_col_offset) { _Py_block_ty current_type = st->st_cur->ste_type; - if(!symtable_enter_block(st, name, FunctionBlock, ast, lineno, + if(!symtable_enter_block(st, name, TypeParamBlock, ast, lineno, col_offset, end_lineno, end_col_offset)) { return 0; } @@ -2339,6 +2343,8 @@ symtable_raise_if_annotation_block(struct symtable *st, const char *name, expr_t PyErr_Format(PyExc_SyntaxError, TYPEVAR_BOUND_NOT_ALLOWED, name); else if (type == TypeAliasBlock) PyErr_Format(PyExc_SyntaxError, TYPEALIAS_NOT_ALLOWED, name); + else if (type == TypeParamBlock) + PyErr_Format(PyExc_SyntaxError, TYPEPARAM_NOT_ALLOWED, name); else return 1; From 71951624f1ec984ef575db9afe9f78ae6eaf5a6e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 12:04:26 -0600 Subject: [PATCH 089/200] regen all, minor quality improvements --- Include/internal/pycore_opcode.h | 14 ++++++-------- Objects/typevarobject.c | 27 ++++++++++++++++++--------- Python/opcode_targets.h | 13 ++++++------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index 387b5a224adf53..b87e157abc780b 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -329,9 +329,8 @@ static const char *const _PyOpcode_OpName[266] = { [LOAD_FAST__LOAD_CONST] = "LOAD_FAST__LOAD_CONST", [SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS", [LOAD_FAST__LOAD_FAST] = "LOAD_FAST__LOAD_FAST", - [LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN", [LOAD_LOCALS] = "LOAD_LOCALS", - [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", + [LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN", [POP_EXCEPT] = "POP_EXCEPT", [STORE_NAME] = "STORE_NAME", [DELETE_NAME] = "DELETE_NAME", @@ -354,9 +353,9 @@ static const char *const _PyOpcode_OpName[266] = { [IMPORT_NAME] = "IMPORT_NAME", [IMPORT_FROM] = "IMPORT_FROM", [JUMP_FORWARD] = "JUMP_FORWARD", + [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", [STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE", [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", - [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", [POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE", [POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE", [LOAD_GLOBAL] = "LOAD_GLOBAL", @@ -386,7 +385,7 @@ static const char *const _PyOpcode_OpName[266] = { [JUMP_BACKWARD] = "JUMP_BACKWARD", [LOAD_SUPER_ATTR] = "LOAD_SUPER_ATTR", [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", - [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", + [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", [EXTENDED_ARG] = "EXTENDED_ARG", [LIST_APPEND] = "LIST_APPEND", [SET_ADD] = "SET_ADD", @@ -396,21 +395,21 @@ static const char *const _PyOpcode_OpName[266] = { [YIELD_VALUE] = "YIELD_VALUE", [RESUME] = "RESUME", [MATCH_CLASS] = "MATCH_CLASS", + [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", - [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [FORMAT_VALUE] = "FORMAT_VALUE", [BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP", [BUILD_STRING] = "BUILD_STRING", + [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", - [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [LIST_EXTEND] = "LIST_EXTEND", [SET_UPDATE] = "SET_UPDATE", [DICT_MERGE] = "DICT_MERGE", [DICT_UPDATE] = "DICT_UPDATE", + [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [SEND_GEN] = "SEND_GEN", - [167] = "<167>", [168] = "<168>", [169] = "<169>", [170] = "<170>", @@ -513,7 +512,6 @@ static const char *const _PyOpcode_OpName[266] = { #endif #define EXTRA_CASES \ - case 167: \ case 168: \ case 169: \ case 170: \ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 213f6483683bf5..d9b6e81f45db1e 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -294,7 +294,10 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, tv->contravariant = contravariant; tv->infer_variance = infer_variance; if (module != NULL) { - PyObject_SetAttrString((PyObject *)tv, "__module__", module); + if (PyObject_SetAttrString((PyObject *)tv, "__module__", module) < 0) { + Py_DECREF(tv); + return NULL; + } } PyObject_GC_Track(tv); @@ -555,7 +558,7 @@ paramspecargs_repr(PyObject *self) { paramspecattrobject *psa = (paramspecattrobject *)self; - PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; if (Py_IS_TYPE(psa->__origin__, tp)) { return PyUnicode_FromFormat("%s.args", ((paramspecobject *)psa->__origin__)->name); @@ -632,7 +635,7 @@ paramspeckwargs_repr(PyObject *self) { paramspecattrobject *psk = (paramspecattrobject *)self; - PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; if (Py_IS_TYPE(psk->__origin__, tp)) { return PyUnicode_FromFormat("%s.kwargs", ((paramspecobject *)psk->__origin__)->name); @@ -775,7 +778,7 @@ static paramspecobject * paramspec_alloc(const char *name, PyObject *bound, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { - PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.paramspec_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; paramspecobject *ps = PyObject_GC_New(paramspecobject, tp); if (ps == NULL) { return NULL; @@ -790,7 +793,10 @@ paramspec_alloc(const char *name, PyObject *bound, bool covariant, ps->contravariant = contravariant; ps->infer_variance = infer_variance; if (module != NULL) { - PyObject_SetAttrString((PyObject *)ps, "__module__", module); + if (PyObject_SetAttrString((PyObject *)ps, "__module__", module) < 0) { + Py_DECREF(ps); + return NULL; + } } _PyObject_GC_TRACK(ps); return ps; @@ -1029,7 +1035,7 @@ static PyMemberDef typevartuple_members[] = { static typevartupleobject * typevartuple_alloc(const char *name, PyObject *module) { - PyTypeObject *tp = _PyInterpreterState_Get()->cached_objects.typevartuple_type; + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, tp); if (tvt == NULL) { return NULL; @@ -1040,7 +1046,10 @@ typevartuple_alloc(const char *name, PyObject *module) return NULL; } if (module != NULL) { - PyObject_SetAttrString((PyObject *)tvt, "__module__", module); + if (PyObject_SetAttrString((PyObject *)tvt, "__module__", module) < 0) { + Py_DECREF(tvt); + return NULL; + } } _PyObject_GC_TRACK(tvt); return tvt; @@ -1511,9 +1520,9 @@ call_typing_args_kwargs(const char *name, PyTypeObject *cls, PyObject *args, PyO PyTuple_SET_ITEM(new_args, i + 1, Py_NewRef(arg)); } PyObject *result = PyObject_Call(func, new_args, kwargs); - Py_DECREF(func); Py_DECREF(typing); - Py_DecRef(new_args); + Py_DECREF(func); + Py_DECREF(new_args); return result; error: Py_XDECREF(typing); diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 52e98531140749..8036bc9eec33c9 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -86,9 +86,8 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_FAST__LOAD_CONST, &&TARGET_SETUP_ANNOTATIONS, &&TARGET_LOAD_FAST__LOAD_FAST, - &&TARGET_LOAD_GLOBAL_BUILTIN, &&TARGET_LOAD_LOCALS, - &&TARGET_LOAD_GLOBAL_MODULE, + &&TARGET_LOAD_GLOBAL_BUILTIN, &&TARGET_POP_EXCEPT, &&TARGET_STORE_NAME, &&TARGET_DELETE_NAME, @@ -111,9 +110,9 @@ static void *opcode_targets[256] = { &&TARGET_IMPORT_NAME, &&TARGET_IMPORT_FROM, &&TARGET_JUMP_FORWARD, + &&TARGET_LOAD_GLOBAL_MODULE, &&TARGET_STORE_ATTR_INSTANCE_VALUE, &&TARGET_STORE_ATTR_SLOT, - &&TARGET_STORE_ATTR_WITH_HINT, &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_LOAD_GLOBAL, @@ -143,7 +142,7 @@ static void *opcode_targets[256] = { &&TARGET_JUMP_BACKWARD, &&TARGET_LOAD_SUPER_ATTR, &&TARGET_CALL_FUNCTION_EX, - &&TARGET_STORE_FAST__LOAD_FAST, + &&TARGET_STORE_ATTR_WITH_HINT, &&TARGET_EXTENDED_ARG, &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, @@ -153,24 +152,24 @@ static void *opcode_targets[256] = { &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, + &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_STORE_FAST__STORE_FAST, - &&TARGET_STORE_SUBSCR_DICT, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, + &&TARGET_STORE_SUBSCR_DICT, &&TARGET_STORE_SUBSCR_LIST_INT, &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_UNPACK_SEQUENCE_TUPLE, - &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, + &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_CALL, &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, From 5fbd4d5c81d24bb25ac0137abdcde1793e250415 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 12:13:44 -0600 Subject: [PATCH 090/200] fix leaked ref to the TypeAlias type --- Objects/typevarobject.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index d9b6e81f45db1e..bf573e8df2e3ce 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1221,6 +1221,7 @@ _Py_make_typevartuple(PyThreadState *unused, PyObject *v) static void typealias_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); _PyObject_GC_UNTRACK(self); typealiasobject *ta = (typealiasobject *)self; free((void *)ta->name); @@ -1228,6 +1229,7 @@ typealias_dealloc(PyObject *self) Py_XDECREF(ta->compute_value); Py_XDECREF(ta->value); Py_TYPE(self)->tp_free(self); + Py_DECREF(tp); } static PyObject * From f86be9c035ab7e21ae93c289e72500e5eee6cfcb Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 12:18:13 -0600 Subject: [PATCH 091/200] Fix another leak --- Objects/typevarobject.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index bf573e8df2e3ce..268e6b90b9283a 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1315,6 +1315,7 @@ typealias_repr(PyObject *self) goto error; } result = PyUnicode_FromFormat("", ta->name, params_repr, value_repr); + Py_DECREF(params_repr); } else { result = PyUnicode_FromFormat("", ta->name, value_repr); From 77b380796a56a4d401557b63453a1a716fb05001 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 13:39:11 -0600 Subject: [PATCH 092/200] Deallocate Generic correctly --- Objects/typevarobject.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 268e6b90b9283a..03e960700fe717 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1576,16 +1576,36 @@ static PyMethodDef generic_methods[] = { {NULL} /* Sentinel */ }; +static void +generic_dealloc(PyObject *self) +{ + PyTypeObject *tp = Py_TYPE(self); + Py_TYPE(self)->tp_free(self); + _PyObject_GC_UNTRACK(self); + Py_DECREF(tp); +} + +static int +generic_traverse(PyObject *self, visitproc visit, void *arg) +{ + Py_VISIT(Py_TYPE(self)); + return 0; +} + static PyType_Slot generic_slots[] = { {Py_tp_doc, (void *)generic_doc}, {Py_tp_methods, generic_methods}, + {Py_tp_dealloc, generic_dealloc}, + {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_free, PyObject_GC_Del}, + {Py_tp_traverse, generic_traverse}, {0, NULL}, }; PyType_Spec generic_spec = { .name = "typing.Generic", .basicsize = sizeof(PyObject), - .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, .slots = generic_slots, }; From f448248a4e9e308cb47c4dc5a111881ec0b90007 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 16:59:36 -0600 Subject: [PATCH 093/200] Avoid a new funcflags --- Include/cpython/funcobject.h | 2 +- Include/internal/pycore_function.h | 2 + Include/internal/pycore_intrinsics.h | 3 +- Objects/funcobject.c | 29 ++++++--- Objects/typevarobject.c | 2 +- Python/bytecodes.c | 5 -- Python/compile.c | 8 ++- Python/generated_cases.c.h | 91 +++++++++++++--------------- Python/intrinsics.c | 1 + Python/opcode_metadata.h | 2 +- Python/symtable.c | 19 +++--- 11 files changed, 91 insertions(+), 73 deletions(-) diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index 84cb40a7f551f6..6f78f5868d0166 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -41,7 +41,7 @@ typedef struct { PyObject *func_weakreflist; /* List of weak references */ PyObject *func_module; /* The __module__ attribute, can be anything */ PyObject *func_annotations; /* Annotations, a dict or NULL */ - PyObject *func_typevars; /* Tuple of active type variables or NULL */ + PyObject *func_typeparams; /* Tuple of active type variables or NULL */ vectorcallfunc vectorcall; /* Version number for use by specializer. * Can set to non-zero when we want to specialize. diff --git a/Include/internal/pycore_function.h b/Include/internal/pycore_function.h index 11988149843fef..ecbb7001e7d840 100644 --- a/Include/internal/pycore_function.h +++ b/Include/internal/pycore_function.h @@ -17,6 +17,8 @@ struct _py_func_state { extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr); extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func); +extern PyObject *_Py_set_function_type_params( + PyThreadState* unused, PyObject *func, PyObject *type_params); #ifdef __cplusplus } diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index 806e61d78dbbda..8298750384027b 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -21,8 +21,9 @@ #define INTRINSIC_PREP_RERAISE_STAR 1 #define INTRINSIC_TYPEVAR_WITH_BOUND 2 #define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3 +#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 4 -#define MAX_INTRINSIC_2 3 +#define MAX_INTRINSIC_2 4 typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value); diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 101155c5a6c753..cd1ee24cd87657 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -127,7 +127,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) PyErr_Clear(); } op->func_annotations = NULL; - op->func_typevars = NULL; + op->func_typeparams = NULL; op->vectorcall = _PyFunction_Vectorcall; op->func_version = 0; _PyObject_GC_TRACK(op); @@ -203,7 +203,7 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname op->func_weakreflist = NULL; op->func_module = module; op->func_annotations = NULL; - op->func_typevars = NULL; + op->func_typeparams = NULL; op->vectorcall = _PyFunction_Vectorcall; op->func_version = 0; _PyObject_GC_TRACK(op); @@ -657,14 +657,29 @@ func_set_annotations(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(igno static PyObject * func_get_type_params(PyFunctionObject *op, void *Py_UNUSED(ignored)) { - if (op->func_typevars == NULL) { + if (op->func_typeparams == NULL) { return PyTuple_New(0); } - assert(PyTuple_Check(op->func_typevars)); - return Py_NewRef(op->func_typevars); + assert(PyTuple_Check(op->func_typeparams)); + return Py_NewRef(op->func_typeparams); } +PyObject * +_Py_set_function_type_params(PyThreadState* unused, PyObject *func, + PyObject *type_params) +{ + PyFunctionObject *f = (PyFunctionObject *)func; + if (!PyTuple_Check(type_params)) { + PyErr_SetString(PyExc_TypeError, + "__type_params__ must be set to a tuple object"); + return NULL; + } + Py_XSETREF(f->func_typeparams, Py_NewRef(type_params)); + return Py_None; +} + + static PyGetSetDef func_getsetlist[] = { {"__code__", (getter)func_get_code, (setter)func_set_code}, {"__defaults__", (getter)func_get_defaults, @@ -797,7 +812,7 @@ func_clear(PyFunctionObject *op) Py_CLEAR(op->func_dict); Py_CLEAR(op->func_closure); Py_CLEAR(op->func_annotations); - Py_CLEAR(op->func_typevars); + Py_CLEAR(op->func_typeparams); // Don't Py_CLEAR(op->func_code), since code is always required // to be non-NULL. Similarly, name and qualname shouldn't be NULL. // However, name and qualname could be str subclasses, so they @@ -852,7 +867,7 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) Py_VISIT(f->func_dict); Py_VISIT(f->func_closure); Py_VISIT(f->func_annotations); - Py_VISIT(f->func_typevars); + Py_VISIT(f->func_typeparams); Py_VISIT(f->func_qualname); return 0; } diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 03e960700fe717..4c23dd9ca2fbea 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1580,8 +1580,8 @@ static void generic_dealloc(PyObject *self) { PyTypeObject *tp = Py_TYPE(self); - Py_TYPE(self)->tp_free(self); _PyObject_GC_UNTRACK(self); + Py_TYPE(self)->tp_free(self); Py_DECREF(tp); } diff --git a/Python/bytecodes.c b/Python/bytecodes.c index c2f21dfdc277aa..ad603f19845cfd 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3185,7 +3185,6 @@ dummy_func( inst(MAKE_FUNCTION, (defaults if (oparg & 0x01), kwdefaults if (oparg & 0x02), - typevars if (oparg & 0x10), annotations if (oparg & 0x04), closure if (oparg & 0x08), codeobj -- func)) { @@ -3198,10 +3197,6 @@ dummy_func( goto error; } - if (oparg & 0x10) { - assert(PyTuple_CheckExact(typevars)); - func_obj->func_typevars = typevars; - } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; diff --git a/Python/compile.c b/Python/compile.c index a84c754e560193..f0d52055419d7f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2214,9 +2214,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } int num_typeparam_args = 0; + _Py_DECLARE_STR(type_params, ".type_params"); if (asdl_seq_LEN(typeparams) > 0) { - funcflags |= 0x10; PyObject *typeparams_name = PyUnicode_FromFormat("", name); if (!typeparams_name) { return ERROR; @@ -2239,6 +2239,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) num_typeparam_args += 1; } RETURN_IF_ERROR(compiler_type_params(c, typeparams)); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Store)); } annotations = compiler_visit_annotations(c, loc, args, returns); @@ -2283,6 +2284,11 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } Py_DECREF(co); if (asdl_seq_LEN(typeparams) > 0) { + ADDOP_I(c, loc, COPY, 1); + RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS); + ADDOP(c, loc, POP_TOP); + if (is_typeparams_in_class) { c->u->u_metadata.u_argcount += 1; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 60f01106044958..5aaaf9a56c4b93 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4400,11 +4400,10 @@ PyObject *codeobj = stack_pointer[-1]; PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0))] : NULL; PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL; - PyObject *typevars = (oparg & 0x10) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0))] : NULL; - PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; - PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; + PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; + PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3192 "Python/bytecodes.c" + #line 3191 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4414,10 +4413,6 @@ goto error; } - if (oparg & 0x10) { - assert(PyTuple_CheckExact(typevars)); - func_obj->func_typevars = typevars; - } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; @@ -4437,14 +4432,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4441 "Python/generated_cases.c.h" - STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); + #line 4436 "Python/generated_cases.c.h" + STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3227 "Python/bytecodes.c" + #line 3222 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4465,7 +4460,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4469 "Python/generated_cases.c.h" + #line 4464 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4473,15 +4468,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3250 "Python/bytecodes.c" + #line 3245 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4479 "Python/generated_cases.c.h" + #line 4474 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3252 "Python/bytecodes.c" + #line 3247 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4485 "Python/generated_cases.c.h" + #line 4480 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4492,7 +4487,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3256 "Python/bytecodes.c" + #line 3251 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4527,7 +4522,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4531 "Python/generated_cases.c.h" + #line 4526 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4536,10 +4531,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3293 "Python/bytecodes.c" + #line 3288 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4543 "Python/generated_cases.c.h" + #line 4538 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4551,7 +4546,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3298 "Python/bytecodes.c" + #line 3293 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4566,12 +4561,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4570 "Python/generated_cases.c.h" + #line 4565 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3313 "Python/bytecodes.c" + #line 3308 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4575 "Python/generated_cases.c.h" + #line 4570 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4581,16 +4576,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3318 "Python/bytecodes.c" + #line 3313 "Python/bytecodes.c" assert(oparg >= 2); - #line 4587 "Python/generated_cases.c.h" + #line 4582 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3322 "Python/bytecodes.c" + #line 3317 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4610,11 +4605,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4614 "Python/generated_cases.c.h" + #line 4609 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3344 "Python/bytecodes.c" + #line 3339 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4626,26 +4621,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4630 "Python/generated_cases.c.h" + #line 4625 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3358 "Python/bytecodes.c" + #line 3353 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4636 "Python/generated_cases.c.h" + #line 4631 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3362 "Python/bytecodes.c" + #line 3357 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4643 "Python/generated_cases.c.h" + #line 4638 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3367 "Python/bytecodes.c" + #line 3362 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4654,12 +4649,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4658 "Python/generated_cases.c.h" + #line 4653 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3378 "Python/bytecodes.c" + #line 3373 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4668,12 +4663,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4672 "Python/generated_cases.c.h" + #line 4667 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3389 "Python/bytecodes.c" + #line 3384 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4686,12 +4681,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4690 "Python/generated_cases.c.h" + #line 4685 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3404 "Python/bytecodes.c" + #line 3399 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4704,30 +4699,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4708 "Python/generated_cases.c.h" + #line 4703 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3419 "Python/bytecodes.c" + #line 3414 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4719 "Python/generated_cases.c.h" + #line 4714 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3427 "Python/bytecodes.c" + #line 3422 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4726 "Python/generated_cases.c.h" + #line 4721 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3432 "Python/bytecodes.c" + #line 3427 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4733 "Python/generated_cases.c.h" + #line 4728 "Python/generated_cases.c.h" } diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 6d33b23800cb6f..85ae3537bc4cbe 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -255,4 +255,5 @@ _PyIntrinsics_BinaryFunctions[] = { [INTRINSIC_PREP_RERAISE_STAR] = prep_reraise_star, [INTRINSIC_TYPEVAR_WITH_BOUND] = make_typevar_with_bound, [INTRINSIC_TYPEVAR_WITH_CONSTRAINTS] = make_typevar_with_constraints, + [INTRINSIC_SET_FUNCTION_TYPE_PARAMS] = _Py_set_function_type_params, }; diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 5547b0f0689826..5358efba6493a0 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -354,7 +354,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case CALL_FUNCTION_EX: return ((oparg & 1) ? 1 : 0) + 3; case MAKE_FUNCTION: - return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x10) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1; + return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1; case RETURN_GENERATOR: return 0; case BUILD_SLICE: diff --git a/Python/symtable.c b/Python/symtable.c index ed7c7189783cee..1a03b406dfbf8f 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1161,7 +1161,7 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag, static int symtable_enter_typeparam_block(struct symtable *st, identifier name, void *ast, int has_defaults, int has_kwdefaults, - int is_class, + enum _stmt_kind kind, int lineno, int col_offset, int end_lineno, int end_col_offset) { @@ -1178,10 +1178,11 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, return 0; } } - if (is_class) { + if (kind == AsyncFunctionDef_kind || kind == FunctionDef_kind || kind == ClassDef_kind) { _Py_DECLARE_STR(type_params, ".type_params"); // It gets "set" when we create the type params tuple and - // "used" when we build up the bases. + // "used" when we build up the bases (for classes) or set the + // type_params attribute (for functions). if (!symtable_add_def(st, &_Py_STR(type_params), DEF_LOCAL, lineno, col_offset, end_lineno, end_col_offset)) { return 0; @@ -1190,6 +1191,8 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, lineno, col_offset, end_lineno, end_col_offset)) { return 0; } + } + if (kind == ClassDef_kind) { // This is used for setting the generic base _Py_DECLARE_STR(generic_base, ".generic_base"); if (!symtable_add_def(st, &_Py_STR(generic_base), DEF_LOCAL, @@ -1319,14 +1322,14 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT_SEQ_WITH_NULL(st, expr, s->v.FunctionDef.args->kw_defaults); if (s->v.FunctionDef.decorator_list) VISIT_SEQ(st, expr, s->v.FunctionDef.decorator_list); - if (asdl_seq_LEN(s->v.AsyncFunctionDef.typeparams) > 0) { + if (asdl_seq_LEN(s->v.FunctionDef.typeparams) > 0) { if (!symtable_enter_typeparam_block( st, s->v.FunctionDef.name, (void *)s->v.FunctionDef.typeparams, s->v.FunctionDef.args->defaults != NULL, has_kwonlydefaults(s->v.FunctionDef.args->kwonlyargs, s->v.FunctionDef.args->kw_defaults), - false, + s->kind, LOCATION(s))) { VISIT_QUIT(st, 0); } @@ -1357,7 +1360,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (asdl_seq_LEN(s->v.ClassDef.typeparams) > 0) { if (!symtable_enter_typeparam_block(st, s->v.ClassDef.name, (void *)s->v.ClassDef.typeparams, - false, false, true, + false, false, s->kind, LOCATION(s))) { VISIT_QUIT(st, 0); } @@ -1400,7 +1403,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (!symtable_enter_typeparam_block( st, name, (void *)s->v.TypeAlias.typeparams, - false, false, false, + false, false, s->kind, LOCATION(s))) { VISIT_QUIT(st, 0); } @@ -1630,9 +1633,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) st, s->v.AsyncFunctionDef.name, (void *)s->v.AsyncFunctionDef.typeparams, s->v.AsyncFunctionDef.args->defaults != NULL, - false, has_kwonlydefaults(s->v.AsyncFunctionDef.args->kwonlyargs, s->v.AsyncFunctionDef.args->kw_defaults), + s->kind, LOCATION(s))) { VISIT_QUIT(st, 0); } From d32bc61c019b1323b090510dc237f23f6719308a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 17:08:58 -0600 Subject: [PATCH 094/200] Fix missing INCREF --- Objects/funcobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/funcobject.c b/Objects/funcobject.c index cd1ee24cd87657..148ef3d4724900 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -666,7 +666,7 @@ func_get_type_params(PyFunctionObject *op, void *Py_UNUSED(ignored)) } PyObject * -_Py_set_function_type_params(PyThreadState* unused, PyObject *func, +_Py_set_function_type_params(PyThreadState *unused, PyObject *func, PyObject *type_params) { PyFunctionObject *f = (PyFunctionObject *)func; @@ -676,7 +676,7 @@ _Py_set_function_type_params(PyThreadState* unused, PyObject *func, return NULL; } Py_XSETREF(f->func_typeparams, Py_NewRef(type_params)); - return Py_None; + Py_RETURN_NONE; } From 27a8a4cc34d243e40d898d4ef93ae0fea351224e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2023 17:34:59 -0600 Subject: [PATCH 095/200] Fix repr() for recursive type aliases --- Lib/test/test_type_aliases.py | 8 ++++++++ Objects/typevarobject.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 87d91f365d8ebf..0e519150057b92 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -127,3 +127,11 @@ def __repr__(self): type Generic[T, *Ts, **P] = int self.assertEqual(repr(Generic), "") + + def test_recursive_repr(self): + type Recursive = Recursive + self.assertEqual(repr(Recursive), "") + + type X = list[Y] + type Y = list[X] + self.assertEqual(repr(X), "]>") diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 4c23dd9ca2fbea..47c4744d8c76a3 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1249,6 +1249,14 @@ typealias_evaluate(typealiasobject *ta) static PyObject * typealias_repr(PyObject *self) { + Py_ssize_t res = Py_ReprEnter(self); + if (res > 0) { + return PyUnicode_FromString("..."); + } + else if (res < 0) { + return NULL; + } + typealiasobject *ta = (typealiasobject *)self; PyObject *value_repr = NULL; PyObject *value = typealias_evaluate(ta); @@ -1271,6 +1279,7 @@ typealias_repr(PyObject *self) } if (value_repr == NULL) { // PyUnicode_FromString failed + Py_ReprLeave(self); return NULL; } PyObject *result = NULL; @@ -1321,6 +1330,7 @@ typealias_repr(PyObject *self) result = PyUnicode_FromFormat("", ta->name, value_repr); } error: + Py_ReprLeave(self); Py_DECREF(value_repr); return result; } From 7fa37b40870b0282e967f6651df06b2570ef002b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 05:47:38 -0600 Subject: [PATCH 096/200] Fix refleak in ParamSpecArgs/Kwargs --- Objects/typevarobject.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 47c4744d8c76a3..8e3a36595308e1 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -503,6 +503,7 @@ typedef struct { static void paramspecattr_dealloc(PyObject *self) { + PyTypeObject *tp = Py_TYPE(self); paramspecattrobject *psa = (paramspecattrobject *)self; _PyObject_GC_UNTRACK(self); @@ -510,6 +511,7 @@ paramspecattr_dealloc(PyObject *self) Py_XDECREF(psa->__origin__); Py_TYPE(self)->tp_free(self); + Py_DECREF(tp); } static int From 880f066c95424ca0d09062511441f4b10dd55466 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 06:53:01 -0600 Subject: [PATCH 097/200] Add tp_clear methods Some of these aren't strictly necessary, but better safe than sorry. --- Objects/typevarobject.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 8e3a36595308e1..6d4c4c2c0fe393 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -211,6 +211,17 @@ typevar_traverse(PyObject *self, visitproc visit, void *arg) return 0; } +static int +typevar_clear(typevarobject *self) +{ + Py_CLEAR(self->bound); + Py_CLEAR(self->evaluate_bound); + Py_CLEAR(self->constraints); + Py_CLEAR(self->evaluate_constraints); + _PyObject_ClearManagedDict((PyObject *)self); + return 0; +} + static PyObject * typevar_repr(PyObject *self) { @@ -481,6 +492,7 @@ static PyType_Slot typevar_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, typevar_traverse}, + {Py_tp_clear, typevar_clear}, {Py_tp_repr, typevar_repr}, {Py_tp_members, typevar_members}, {Py_tp_getset, typevar_getset}, @@ -522,6 +534,13 @@ paramspecattr_traverse(PyObject *self, visitproc visit, void *arg) return 0; } +static int +paramspecattr_clear(paramspecattrobject *self) +{ + Py_CLEAR(self->__origin__); + return 0; +} + static PyObject * paramspecattr_richcompare(PyObject *a, PyObject *b, int op) { @@ -619,6 +638,7 @@ static PyType_Slot paramspecargs_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, paramspecattr_traverse}, + {Py_tp_clear, (inquiry)paramspecattr_clear}, {Py_tp_repr, paramspecargs_repr}, {Py_tp_members, paramspecattr_members}, {Py_tp_richcompare, paramspecattr_richcompare}, @@ -695,6 +715,7 @@ static PyType_Slot paramspeckwargs_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, paramspecattr_traverse}, + {Py_tp_clear, (inquiry)paramspecattr_clear}, {Py_tp_repr, paramspeckwargs_repr}, {Py_tp_members, paramspecattr_members}, {Py_tp_richcompare, paramspecattr_richcompare}, @@ -734,6 +755,14 @@ paramspec_traverse(PyObject *self, visitproc visit, void *arg) return 0; } +static int +paramspec_clear(paramspecobject *self) +{ + Py_CLEAR(self->bound); + _PyObject_ClearManagedDict((PyObject *)self); + return 0; +} + static PyObject * paramspec_repr(PyObject *self) { @@ -977,6 +1006,7 @@ static PyType_Slot paramspec_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, paramspec_traverse}, + {Py_tp_clear, paramspec_clear}, {Py_tp_repr, paramspec_repr}, {0, 0}, }; @@ -1144,6 +1174,13 @@ typevartuple_traverse(PyObject *self, visitproc visit, void *arg) return 0; } +static int +typevartuple_clear(PyObject *self) +{ + _PyObject_ClearManagedDict(self); + return 0; +} + static PyMethodDef typevartuple_methods[] = { TYPEVARTUPLE_TYPING_SUBST_METHODDEF TYPEVARTUPLE_TYPING_PREPARE_SUBST_METHODDEF @@ -1188,6 +1225,7 @@ PyType_Slot typevartuple_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, typevartuple_traverse}, + {Py_tp_clear, typevartuple_clear}, {0, 0}, }; @@ -1405,6 +1443,15 @@ typealias_traverse(typealiasobject *self, visitproc visit, void *arg) return 0; } +static int +typealias_clear(typealiasobject *self) +{ + Py_CLEAR(self->type_params); + Py_CLEAR(self->compute_value); + Py_CLEAR(self->value); + return 0; +} + /*[clinic input] typealias.__reduce__ as typealias_reduce @@ -1451,6 +1498,7 @@ static PyType_Slot typealias_slots[] = { {Py_tp_alloc, PyType_GenericAlloc}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, (traverseproc)typealias_traverse}, + {Py_tp_clear, (inquiry)typealias_clear}, {Py_tp_repr, typealias_repr}, {Py_nb_or, _Py_union_type_or}, {0, 0}, From 3d8e24eb5bae7dae7f07be9e38e69d122732369f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 06:53:29 -0600 Subject: [PATCH 098/200] regen-global-objects --- Include/internal/pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + Include/internal/pycore_runtime_init_generated.h | 1 + Include/internal/pycore_unicodeobject_generated.h | 3 +++ 4 files changed, 6 insertions(+) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index b70c622dd1d370..25477972114cd9 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -1132,6 +1132,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reducer_override)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(registry)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(rel_tol)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(release)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reload)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(repl)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(replace)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 29bf60403c33bf..6fe1167c48af83 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -620,6 +620,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(reducer_override) STRUCT_FOR_ID(registry) STRUCT_FOR_ID(rel_tol) + STRUCT_FOR_ID(release) STRUCT_FOR_ID(reload) STRUCT_FOR_ID(repl) STRUCT_FOR_ID(replace) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 73134816574fae..a814b008317b47 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -1126,6 +1126,7 @@ extern "C" { INIT_ID(reducer_override), \ INIT_ID(registry), \ INIT_ID(rel_tol), \ + INIT_ID(release), \ INIT_ID(reload), \ INIT_ID(repl), \ INIT_ID(replace), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index fd265484eef456..772f31cbda0c1d 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1698,6 +1698,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(rel_tol); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(release); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(reload); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); From 74c1a0d146cdf7a0ac94fe00622f67cbadec9c5d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 07:43:42 -0600 Subject: [PATCH 099/200] Apparently not --- Include/internal/pycore_global_objects_fini_generated.h | 1 - Include/internal/pycore_global_strings.h | 1 - Include/internal/pycore_runtime_init_generated.h | 1 - Include/internal/pycore_unicodeobject_generated.h | 3 --- 4 files changed, 6 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 25477972114cd9..b70c622dd1d370 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -1132,7 +1132,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reducer_override)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(registry)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(rel_tol)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(release)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(reload)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(repl)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(replace)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 6fe1167c48af83..29bf60403c33bf 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -620,7 +620,6 @@ struct _Py_global_strings { STRUCT_FOR_ID(reducer_override) STRUCT_FOR_ID(registry) STRUCT_FOR_ID(rel_tol) - STRUCT_FOR_ID(release) STRUCT_FOR_ID(reload) STRUCT_FOR_ID(repl) STRUCT_FOR_ID(replace) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index a814b008317b47..73134816574fae 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -1126,7 +1126,6 @@ extern "C" { INIT_ID(reducer_override), \ INIT_ID(registry), \ INIT_ID(rel_tol), \ - INIT_ID(release), \ INIT_ID(reload), \ INIT_ID(repl), \ INIT_ID(replace), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 772f31cbda0c1d..fd265484eef456 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1698,9 +1698,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(rel_tol); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); - string = &_Py_ID(release); - assert(_PyUnicode_CheckConsistency(string, 1)); - _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(reload); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); From 3b6098d86402a5062542da33be0e90930e3fda17 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 11:29:30 -0600 Subject: [PATCH 100/200] Add lookahead to grammar --- Grammar/python.gram | 2 +- Parser/parser.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 0851c7c8a8b8ba..7a63135eeb980c 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -112,7 +112,7 @@ simple_stmts[asdl_stmt_seq*]: # will throw a SyntaxError. simple_stmt[stmt_ty] (memo): | assignment - | type_alias + | &"type" type_alias | e=star_expressions { _PyAST_Expr(e, EXTRA) } | &'return' return_stmt | &('import' | 'from') import_stmt diff --git a/Parser/parser.c b/Parser/parser.c index 5c32918859a319..9023b900952a38 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -1696,7 +1696,7 @@ simple_stmts_rule(Parser *p) // simple_stmt: // | assignment -// | type_alias +// | &"type" type_alias // | star_expressions // | &'return' return_stmt // | &('import' | 'from') import_stmt @@ -1754,24 +1754,26 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment")); } - { // type_alias + { // &"type" type_alias if (p->error_indicator) { p->level--; return NULL; } - D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "type_alias")); + D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&\"type\" type_alias")); stmt_ty type_alias_var; if ( + _PyPegen_lookahead_with_string(1, _PyPegen_expect_soft_keyword, p, "type") + && (type_alias_var = type_alias_rule(p)) // type_alias ) { - D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "type_alias")); + D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&\"type\" type_alias")); _res = type_alias_var; goto done; } p->mark = _mark; D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "type_alias")); + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&\"type\" type_alias")); } { // star_expressions if (p->error_indicator) { From 9632c02ce5cff7d34a2a62f381feceab2858b33a Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Wed, 26 Apr 2023 14:53:37 -0600 Subject: [PATCH 101/200] First try! It fails! James Powell rules apply. --- Include/cpython/funcobject.h | 7 + Include/internal/pycore_opcode.h | 14 +- Include/opcode.h | 25 +- Lib/importlib/_bootstrap_external.py | 3 +- Lib/opcode.py | 1 + Objects/frameobject.c | 1 + Objects/funcobject.c | 15 + Python/bltinmodule.c | 7 + Python/bytecodes.c | 15 + Python/ceval.c | 16 +- Python/compile.c | 13 +- Python/generated_cases.c.h | 663 ++++++++++++++------------- Python/opcode_metadata.h | 7 +- Python/opcode_targets.h | 12 +- 14 files changed, 446 insertions(+), 353 deletions(-) diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index c716330cc3fbab..2f327885052217 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -10,6 +10,7 @@ extern "C" { #define COMMON_FIELDS(PREFIX) \ PyObject *PREFIX ## globals; \ + PyObject *PREFIX ## locals; /* "slow" locals, not fast */ \ PyObject *PREFIX ## builtins; \ PyObject *PREFIX ## name; \ PyObject *PREFIX ## qualname; \ @@ -67,6 +68,7 @@ PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetLocals(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); @@ -99,6 +101,11 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) { } #define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func)) +static inline PyObject* PyFunction_GET_LOCALS(PyObject *func) { + return _PyFunction_CAST(func)->func_locals; +} +#define PyFunction_GET_LOCALS(func) PyFunction_GET_LOCALS(_PyObject_CAST(func)) + static inline PyObject* PyFunction_GET_MODULE(PyObject *func) { return _PyFunction_CAST(func)->func_module; } diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index c039d712dc0ba1..51b4239102df0d 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -178,6 +178,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_GLOBAL] = LOAD_GLOBAL, [LOAD_GLOBAL_BUILTIN] = LOAD_GLOBAL, [LOAD_GLOBAL_MODULE] = LOAD_GLOBAL, + [LOAD_LOCALS] = LOAD_LOCALS, [LOAD_NAME] = LOAD_NAME, [MAKE_CELL] = MAKE_CELL, [MAKE_FUNCTION] = MAKE_FUNCTION, @@ -324,8 +325,8 @@ static const char *const _PyOpcode_OpName[263] = { [LOAD_FAST__LOAD_FAST] = "LOAD_FAST__LOAD_FAST", [SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS", [LOAD_GLOBAL_BUILTIN] = "LOAD_GLOBAL_BUILTIN", + [LOAD_LOCALS] = "LOAD_LOCALS", [LOAD_GLOBAL_MODULE] = "LOAD_GLOBAL_MODULE", - [STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE", [POP_EXCEPT] = "POP_EXCEPT", [STORE_NAME] = "STORE_NAME", [DELETE_NAME] = "DELETE_NAME", @@ -348,9 +349,9 @@ static const char *const _PyOpcode_OpName[263] = { [IMPORT_NAME] = "IMPORT_NAME", [IMPORT_FROM] = "IMPORT_FROM", [JUMP_FORWARD] = "JUMP_FORWARD", + [STORE_ATTR_INSTANCE_VALUE] = "STORE_ATTR_INSTANCE_VALUE", [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", - [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE", [POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE", [LOAD_GLOBAL] = "LOAD_GLOBAL", @@ -378,9 +379,9 @@ static const char *const _PyOpcode_OpName[263] = { [STORE_DEREF] = "STORE_DEREF", [DELETE_DEREF] = "DELETE_DEREF", [JUMP_BACKWARD] = "JUMP_BACKWARD", - [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", + [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [CALL_FUNCTION_EX] = "CALL_FUNCTION_EX", - [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", + [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", [EXTENDED_ARG] = "EXTENDED_ARG", [LIST_APPEND] = "LIST_APPEND", [SET_ADD] = "SET_ADD", @@ -390,15 +391,15 @@ static const char *const _PyOpcode_OpName[263] = { [YIELD_VALUE] = "YIELD_VALUE", [RESUME] = "RESUME", [MATCH_CLASS] = "MATCH_CLASS", + [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", - [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [FORMAT_VALUE] = "FORMAT_VALUE", [BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP", [BUILD_STRING] = "BUILD_STRING", + [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [SEND_GEN] = "SEND_GEN", - [161] = "<161>", [LIST_EXTEND] = "LIST_EXTEND", [SET_UPDATE] = "SET_UPDATE", [DICT_MERGE] = "DICT_MERGE", @@ -504,7 +505,6 @@ static const char *const _PyOpcode_OpName[263] = { #endif #define EXTRA_CASES \ - case 161: \ case 166: \ case 167: \ case 168: \ diff --git a/Include/opcode.h b/Include/opcode.h index aa8716ef5b4030..41dec5e76c039e 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -45,6 +45,7 @@ extern "C" { #define RETURN_GENERATOR 75 #define RETURN_VALUE 83 #define SETUP_ANNOTATIONS 85 +#define LOAD_LOCALS 87 #define POP_EXCEPT 89 #define HAVE_ARGUMENT 90 #define STORE_NAME 90 @@ -193,18 +194,18 @@ extern "C" { #define LOAD_FAST__LOAD_CONST 82 #define LOAD_FAST__LOAD_FAST 84 #define LOAD_GLOBAL_BUILTIN 86 -#define LOAD_GLOBAL_MODULE 87 -#define STORE_ATTR_INSTANCE_VALUE 88 -#define STORE_ATTR_SLOT 111 -#define STORE_ATTR_WITH_HINT 112 -#define STORE_FAST__LOAD_FAST 113 -#define STORE_FAST__STORE_FAST 141 -#define STORE_SUBSCR_DICT 143 -#define STORE_SUBSCR_LIST_INT 153 -#define UNPACK_SEQUENCE_LIST 154 -#define UNPACK_SEQUENCE_TUPLE 158 -#define UNPACK_SEQUENCE_TWO_TUPLE 159 -#define SEND_GEN 160 +#define LOAD_GLOBAL_MODULE 88 +#define STORE_ATTR_INSTANCE_VALUE 111 +#define STORE_ATTR_SLOT 112 +#define STORE_ATTR_WITH_HINT 113 +#define STORE_FAST__LOAD_FAST 141 +#define STORE_FAST__STORE_FAST 143 +#define STORE_SUBSCR_DICT 153 +#define STORE_SUBSCR_LIST_INT 154 +#define UNPACK_SEQUENCE_LIST 158 +#define UNPACK_SEQUENCE_TUPLE 159 +#define UNPACK_SEQUENCE_TWO_TUPLE 160 +#define SEND_GEN 161 #define HAS_ARG(op) ((((op) >= HAVE_ARGUMENT) && (!IS_PSEUDO_OPCODE(op)))\ || ((op) == JUMP) \ diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index c0c757d94d8781..dd1426925f8c07 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -440,6 +440,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.12a7 3524 (Shrink the BINARY_SUBSCR caches) # Python 3.12b1 3525 (Shrink the CALL caches) # Python 3.12a7 3526 (Add instrumentation support) +# Python 3.12b1 3527 (Add function.__locals__ with change to MAKE_FUNCTION) # Python 3.13 will start with 3550 @@ -456,7 +457,7 @@ def _write_atomic(path, data, mode=0o666): # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3526).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3527).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c diff --git a/Lib/opcode.py b/Lib/opcode.py index dd739e5dd3f6f8..ecdd3ebbdf6f64 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -131,6 +131,7 @@ def pseudo_op(name, op, real_ops): def_op('RETURN_VALUE', 83) def_op('SETUP_ANNOTATIONS', 85) +def_op('LOAD_LOCALS', 87) def_op('POP_EXCEPT', 89) diff --git a/Objects/frameobject.c b/Objects/frameobject.c index ef0070199ab2c0..01180325376c08 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1071,6 +1071,7 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, } PyFrameConstructor desc = { .fc_globals = globals, + .fc_locals = NULL, .fc_builtins = builtins, .fc_name = code->co_name, .fc_qualname = code->co_name, diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 78c1144afca2eb..8d5315b11df278 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -112,6 +112,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) return NULL; } op->func_globals = Py_NewRef(constr->fc_globals); + op->func_locals = Py_XNewRef(constr->fc_locals); op->func_builtins = Py_NewRef(constr->fc_builtins); op->func_name = Py_NewRef(constr->fc_name); op->func_qualname = Py_NewRef(constr->fc_qualname); @@ -190,6 +191,7 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname expect a partially-created object. */ op->func_globals = globals; + op->func_locals = NULL; op->func_builtins = builtins; op->func_name = name; op->func_qualname = qualname; @@ -262,6 +264,16 @@ PyFunction_GetGlobals(PyObject *op) return ((PyFunctionObject *) op) -> func_globals; } +PyObject * +PyFunction_GetLocals(PyObject *op) +{ + if (!PyFunction_Check(op)) { + PyErr_BadInternalCall(); + return NULL; + } + return ((PyFunctionObject *) op) -> func_locals; +} + PyObject * PyFunction_GetModule(PyObject *op) { @@ -450,6 +462,7 @@ static PyMemberDef func_memberlist[] = { {"__closure__", T_OBJECT, OFF(func_closure), READONLY}, {"__doc__", T_OBJECT, OFF(func_doc), 0}, {"__globals__", T_OBJECT, OFF(func_globals), READONLY}, + {"__locals__", T_OBJECT, OFF(func_locals), 0}, {"__module__", T_OBJECT, OFF(func_module), 0}, {"__builtins__", T_OBJECT, OFF(func_builtins), READONLY}, {NULL} /* Sentinel */ @@ -775,6 +788,7 @@ func_clear(PyFunctionObject *op) { op->func_version = 0; Py_CLEAR(op->func_globals); + Py_CLEAR(op->func_locals); Py_CLEAR(op->func_builtins); Py_CLEAR(op->func_module); Py_CLEAR(op->func_defaults); @@ -828,6 +842,7 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) { Py_VISIT(f->func_code); Py_VISIT(f->func_globals); + Py_VISIT(f->func_locals); Py_VISIT(f->func_builtins); Py_VISIT(f->func_module); Py_VISIT(f->func_defaults); diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index fcb4d7a9a975c6..0d634e526305ac 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -195,6 +195,13 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, Py_TYPE(ns)->tp_name); goto error; } + + if (((PyFunctionObject *)func)->func_locals != NULL) { + const char *msg = + "__locals__ not set on class body function defining %.200R"; + PyErr_Format(PyExc_RuntimeError, msg, cls); + } + PyThreadState *tstate = _PyThreadState_GET(); EVAL_CALL_STAT_INC(EVAL_CALL_BUILD_CLASS); cell = _PyEval_Vector(tstate, (PyFunctionObject *)func, ns, NULL, 0, NULL); diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 7af96b4a5e324e..ad6ac8b1339d7d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -992,6 +992,16 @@ dummy_func( } } + inst(LOAD_LOCALS, ( -- locals)) { + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found when loading locals()"); + ERROR_IF(true, error); + } + Py_INCREF(locals); + } + inst(STORE_NAME, (v -- )) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); @@ -3071,6 +3081,7 @@ dummy_func( kwdefaults if (oparg & 0x02), annotations if (oparg & 0x04), closure if (oparg & 0x08), + locals if (oparg & 0x20), codeobj -- func)) { PyFunctionObject *func_obj = (PyFunctionObject *) @@ -3081,6 +3092,10 @@ dummy_func( goto error; } + if (oparg & 0x20) { + assert(PyDict_CheckExact(locals)); + func_obj->func_locals = locals; + } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; diff --git a/Python/ceval.c b/Python/ceval.c index 358835024fd2d0..69a2b692b7899f 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -537,8 +537,11 @@ PyObject * PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) { PyThreadState *tstate = _PyThreadState_GET(); + PyObject *locals_or_globals; if (locals == NULL) { - locals = globals; + locals_or_globals = globals; + } else { + locals_or_globals = locals; } PyObject *builtins = _PyEval_BuiltinsFromGlobals(tstate, globals); // borrowed ref if (builtins == NULL) { @@ -546,6 +549,7 @@ PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) } PyFrameConstructor desc = { .fc_globals = globals, + .fc_locals = locals, .fc_builtins = builtins, .fc_name = ((PyCodeObject *)co)->co_name, .fc_qualname = ((PyCodeObject *)co)->co_name, @@ -559,7 +563,7 @@ PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) return NULL; } EVAL_CALL_STAT_INC(EVAL_CALL_LEGACY); - PyObject *res = _PyEval_Vector(tstate, func, locals, NULL, 0, NULL); + PyObject *res = _PyEval_Vector(tstate, func, locals_or_globals, NULL, 0, NULL); Py_DECREF(func); return res; } @@ -1547,8 +1551,11 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, Py_DECREF(defaults); return NULL; } + PyObject *locals_or_globals; if (locals == NULL) { - locals = globals; + locals_or_globals = globals; + } else { + locals_or_globals = locals; } PyObject *kwnames = NULL; PyObject *const *allargs; @@ -1577,6 +1584,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, } PyFrameConstructor constr = { .fc_globals = globals, + .fc_locals = locals, .fc_builtins = builtins, .fc_name = ((PyCodeObject *)_co)->co_name, .fc_qualname = ((PyCodeObject *)_co)->co_name, @@ -1590,7 +1598,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, goto fail; } EVAL_CALL_STAT_INC(EVAL_CALL_LEGACY); - res = _PyEval_Vector(tstate, func, locals, + res = _PyEval_Vector(tstate, func, locals_or_globals, allargs, argcount, kwnames); fail: diff --git a/Python/compile.c b/Python/compile.c index d6882c31d6437e..9cc8b4c12ed0cf 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1753,6 +1753,15 @@ compiler_make_closure(struct compiler *c, location loc, flags |= 0x08; ADDOP_I(c, loc, BUILD_TUPLE, co->co_nfreevars); } + + /* If flag 0x20 is set, we want to bind func_locals + to the current locals at runtime. + Push them on the stack in the right spot. + */ + if (flags & 0x20) { + ADDOP(c, loc, LOAD_LOCALS); + } + ADDOP_LOAD_CONST(c, loc, (PyObject*)co); ADDOP_I(c, loc, MAKE_FUNCTION, flags); return SUCCESS; @@ -2232,7 +2241,9 @@ compiler_class(struct compiler *c, stmt_ty s) ADDOP(c, loc, LOAD_BUILD_CLASS); /* 3. load a function (or closure) made from the code object */ - if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_ssize_t funcflags = 0x20; /* locals */ + // Py_ssize_t funcflags = 0; + if (compiler_make_closure(c, loc, co, funcflags) < 0) { Py_DECREF(co); return ERROR; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 0928f8200ae751..b8c50028ea75b4 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1370,35 +1370,51 @@ DISPATCH(); } + TARGET(LOAD_LOCALS) { + PyObject *locals; + #line 996 "Python/bytecodes.c" + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found when loading locals()"); + if (true) goto error; + } + Py_INCREF(locals); + #line 1384 "Python/generated_cases.c.h" + STACK_GROW(1); + stack_pointer[-1] = locals; + DISPATCH(); + } + TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 996 "Python/bytecodes.c" + #line 1006 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); - #line 1383 "Python/generated_cases.c.h" + #line 1399 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1003 "Python/bytecodes.c" + #line 1013 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); - #line 1392 "Python/generated_cases.c.h" + #line 1408 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1010 "Python/bytecodes.c" + #line 1020 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1396 "Python/generated_cases.c.h" + #line 1412 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { - #line 1014 "Python/bytecodes.c" + #line 1024 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1415,7 +1431,7 @@ name); goto error; } - #line 1419 "Python/generated_cases.c.h" + #line 1435 "Python/generated_cases.c.h" DISPATCH(); } @@ -1423,7 +1439,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 1040 "Python/bytecodes.c" + #line 1050 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1436,11 +1452,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); - #line 1440 "Python/generated_cases.c.h" + #line 1456 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1053 "Python/bytecodes.c" + #line 1063 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1444 "Python/generated_cases.c.h" + #line 1460 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1450,14 +1466,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1057 "Python/bytecodes.c" + #line 1067 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); - #line 1461 "Python/generated_cases.c.h" + #line 1477 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1468,7 +1484,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1067 "Python/bytecodes.c" + #line 1077 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1476,7 +1492,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1480 "Python/generated_cases.c.h" + #line 1496 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1487,7 +1503,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1078 "Python/bytecodes.c" + #line 1088 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1495,7 +1511,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1499 "Python/generated_cases.c.h" + #line 1515 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1505,15 +1521,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 1089 "Python/bytecodes.c" + #line 1099 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); - #line 1513 "Python/generated_cases.c.h" + #line 1529 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1093 "Python/bytecodes.c" + #line 1103 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1517 "Python/generated_cases.c.h" + #line 1533 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1524,7 +1540,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 1104 "Python/bytecodes.c" + #line 1114 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1540,12 +1556,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); - #line 1544 "Python/generated_cases.c.h" + #line 1560 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1120 "Python/bytecodes.c" + #line 1130 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 1549 "Python/generated_cases.c.h" + #line 1565 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1553,34 +1569,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1124 "Python/bytecodes.c" + #line 1134 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); - #line 1560 "Python/generated_cases.c.h" + #line 1576 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1127 "Python/bytecodes.c" + #line 1137 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1564 "Python/generated_cases.c.h" + #line 1580 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1131 "Python/bytecodes.c" + #line 1141 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); - #line 1574 "Python/generated_cases.c.h" + #line 1590 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1134 "Python/bytecodes.c" + #line 1144 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1578 "Python/generated_cases.c.h" + #line 1594 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { - #line 1138 "Python/bytecodes.c" + #line 1148 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1592,13 +1608,13 @@ } goto error; } - #line 1596 "Python/generated_cases.c.h" + #line 1612 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_NAME) { PyObject *v; - #line 1152 "Python/bytecodes.c" + #line 1162 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *locals = LOCALS(); if (locals == NULL) { @@ -1657,7 +1673,7 @@ } } } - #line 1661 "Python/generated_cases.c.h" + #line 1677 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1668,7 +1684,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1219 "Python/bytecodes.c" + #line 1229 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1720,7 +1736,7 @@ } } null = NULL; - #line 1724 "Python/generated_cases.c.h" + #line 1740 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1734,7 +1750,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1273 "Python/bytecodes.c" + #line 1283 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1745,7 +1761,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1749 "Python/generated_cases.c.h" + #line 1765 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1760,7 +1776,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1286 "Python/bytecodes.c" + #line 1296 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1775,7 +1791,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1779 "Python/generated_cases.c.h" + #line 1795 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1785,16 +1801,16 @@ } TARGET(DELETE_FAST) { - #line 1303 "Python/bytecodes.c" + #line 1313 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1793 "Python/generated_cases.c.h" + #line 1809 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1309 "Python/bytecodes.c" + #line 1319 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1803,12 +1819,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1807 "Python/generated_cases.c.h" + #line 1823 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1320 "Python/bytecodes.c" + #line 1330 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1819,13 +1835,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1823 "Python/generated_cases.c.h" + #line 1839 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1333 "Python/bytecodes.c" + #line 1343 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1857,7 +1873,7 @@ } Py_INCREF(value); } - #line 1861 "Python/generated_cases.c.h" + #line 1877 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1865,7 +1881,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1367 "Python/bytecodes.c" + #line 1377 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1873,7 +1889,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1877 "Python/generated_cases.c.h" + #line 1893 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1881,18 +1897,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1377 "Python/bytecodes.c" + #line 1387 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 1890 "Python/generated_cases.c.h" + #line 1906 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1384 "Python/bytecodes.c" + #line 1394 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1903,22 +1919,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 1907 "Python/generated_cases.c.h" + #line 1923 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1397 "Python/bytecodes.c" + #line 1407 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 1916 "Python/generated_cases.c.h" + #line 1932 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1399 "Python/bytecodes.c" + #line 1409 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1922 "Python/generated_cases.c.h" + #line 1938 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -1928,10 +1944,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1403 "Python/bytecodes.c" + #line 1413 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1935 "Python/generated_cases.c.h" + #line 1951 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -1941,10 +1957,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1408 "Python/bytecodes.c" + #line 1418 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1948 "Python/generated_cases.c.h" + #line 1964 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -1954,7 +1970,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1413 "Python/bytecodes.c" + #line 1423 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -1965,13 +1981,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 1969 "Python/generated_cases.c.h" + #line 1985 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1424 "Python/bytecodes.c" + #line 1434 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 1975 "Python/generated_cases.c.h" + #line 1991 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -1980,13 +1996,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1431 "Python/bytecodes.c" + #line 1441 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 1986 "Python/generated_cases.c.h" + #line 2002 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1433 "Python/bytecodes.c" + #line 1443 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 1990 "Python/generated_cases.c.h" + #line 2006 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -1994,7 +2010,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1437 "Python/bytecodes.c" + #line 1447 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2009,7 +2025,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2013 "Python/generated_cases.c.h" + #line 2029 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2019,7 +2035,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1454 "Python/bytecodes.c" + #line 1464 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2027,13 +2043,13 @@ if (map == NULL) goto error; - #line 2031 "Python/generated_cases.c.h" + #line 2047 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1462 "Python/bytecodes.c" + #line 1472 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2037 "Python/generated_cases.c.h" + #line 2053 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2041,7 +2057,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1466 "Python/bytecodes.c" + #line 1476 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2081,7 +2097,7 @@ Py_DECREF(ann_dict); } } - #line 2085 "Python/generated_cases.c.h" + #line 2101 "Python/generated_cases.c.h" DISPATCH(); } @@ -2089,7 +2105,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1508 "Python/bytecodes.c" + #line 1518 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2099,14 +2115,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2103 "Python/generated_cases.c.h" + #line 2119 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1518 "Python/bytecodes.c" + #line 1528 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2110 "Python/generated_cases.c.h" + #line 2126 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2114,7 +2130,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1522 "Python/bytecodes.c" + #line 1532 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2122,12 +2138,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2126 "Python/generated_cases.c.h" + #line 2142 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1530 "Python/bytecodes.c" + #line 1540 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2131 "Python/generated_cases.c.h" + #line 2147 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2135,17 +2151,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1536 "Python/bytecodes.c" + #line 1546 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2144 "Python/generated_cases.c.h" + #line 2160 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1541 "Python/bytecodes.c" + #line 1551 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2149 "Python/generated_cases.c.h" + #line 2165 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2155,13 +2171,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1548 "Python/bytecodes.c" + #line 1558 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2165 "Python/generated_cases.c.h" + #line 2181 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2173,7 +2189,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1571 "Python/bytecodes.c" + #line 1581 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2207,9 +2223,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2211 "Python/generated_cases.c.h" + #line 2227 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1605 "Python/bytecodes.c" + #line 1615 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2218,12 +2234,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2222 "Python/generated_cases.c.h" + #line 2238 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1614 "Python/bytecodes.c" + #line 1624 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2227 "Python/generated_cases.c.h" + #line 2243 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2237,7 +2253,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1619 "Python/bytecodes.c" + #line 1629 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2250,7 +2266,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2254 "Python/generated_cases.c.h" + #line 2270 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2265,7 +2281,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1635 "Python/bytecodes.c" + #line 1645 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2278,7 +2294,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2282 "Python/generated_cases.c.h" + #line 2298 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2293,7 +2309,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1651 "Python/bytecodes.c" + #line 1661 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2320,7 +2336,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2324 "Python/generated_cases.c.h" + #line 2340 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2335,7 +2351,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1681 "Python/bytecodes.c" + #line 1691 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2345,7 +2361,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2349 "Python/generated_cases.c.h" + #line 2365 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2360,7 +2376,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1694 "Python/bytecodes.c" + #line 1704 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2372,7 +2388,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2376 "Python/generated_cases.c.h" + #line 2392 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2386,7 +2402,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1709 "Python/bytecodes.c" + #line 1719 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2410,7 +2426,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2414 "Python/generated_cases.c.h" + #line 2430 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2418,7 +2434,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1735 "Python/bytecodes.c" + #line 1745 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2444,7 +2460,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2448 "Python/generated_cases.c.h" + #line 2464 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2452,7 +2468,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1763 "Python/bytecodes.c" + #line 1773 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2470,7 +2486,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2474 "Python/generated_cases.c.h" + #line 2490 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2481,7 +2497,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1783 "Python/bytecodes.c" + #line 1793 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2520,7 +2536,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2524 "Python/generated_cases.c.h" + #line 2540 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2531,7 +2547,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1824 "Python/bytecodes.c" + #line 1834 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2541,7 +2557,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2545 "Python/generated_cases.c.h" + #line 2561 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2553,7 +2569,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1843 "Python/bytecodes.c" + #line 1853 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2566,12 +2582,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2570 "Python/generated_cases.c.h" + #line 2586 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1856 "Python/bytecodes.c" + #line 1866 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2575 "Python/generated_cases.c.h" + #line 2591 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2582,7 +2598,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1860 "Python/bytecodes.c" + #line 1870 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2594,7 +2610,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2598 "Python/generated_cases.c.h" + #line 2614 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2605,7 +2621,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1875 "Python/bytecodes.c" + #line 1885 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2621,7 +2637,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2625 "Python/generated_cases.c.h" + #line 2641 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2632,7 +2648,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1894 "Python/bytecodes.c" + #line 1904 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2645,7 +2661,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2649 "Python/generated_cases.c.h" + #line 2665 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2656,14 +2672,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1909 "Python/bytecodes.c" + #line 1919 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2662 "Python/generated_cases.c.h" + #line 2678 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1911 "Python/bytecodes.c" + #line 1921 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2667 "Python/generated_cases.c.h" + #line 2683 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2673,15 +2689,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1915 "Python/bytecodes.c" + #line 1925 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2679 "Python/generated_cases.c.h" + #line 2695 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1917 "Python/bytecodes.c" + #line 1927 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2685 "Python/generated_cases.c.h" + #line 2701 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2692,12 +2708,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 1922 "Python/bytecodes.c" + #line 1932 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2698 "Python/generated_cases.c.h" + #line 2714 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1924 "Python/bytecodes.c" + #line 1934 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2705,10 +2721,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2709 "Python/generated_cases.c.h" + #line 2725 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1932 "Python/bytecodes.c" + #line 1942 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2717,7 +2733,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2721 "Python/generated_cases.c.h" + #line 2737 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2727,21 +2743,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1943 "Python/bytecodes.c" + #line 1953 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2734 "Python/generated_cases.c.h" + #line 2750 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1946 "Python/bytecodes.c" + #line 1956 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2741 "Python/generated_cases.c.h" + #line 2757 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1951 "Python/bytecodes.c" + #line 1961 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2745 "Python/generated_cases.c.h" + #line 2761 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2750,15 +2766,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 1955 "Python/bytecodes.c" + #line 1965 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2757 "Python/generated_cases.c.h" + #line 2773 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 1958 "Python/bytecodes.c" + #line 1968 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2762 "Python/generated_cases.c.h" + #line 2778 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2767,29 +2783,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 1962 "Python/bytecodes.c" + #line 1972 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2775 "Python/generated_cases.c.h" + #line 2791 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 1968 "Python/bytecodes.c" + #line 1978 "Python/bytecodes.c" JUMPBY(oparg); - #line 2784 "Python/generated_cases.c.h" + #line 2800 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 1972 "Python/bytecodes.c" + #line 1982 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2793 "Python/generated_cases.c.h" + #line 2809 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2797,7 +2813,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 1978 "Python/bytecodes.c" + #line 1988 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2807,9 +2823,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2811 "Python/generated_cases.c.h" + #line 2827 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 1988 "Python/bytecodes.c" + #line 1998 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2817,14 +2833,14 @@ if (err < 0) goto pop_1_error; } } - #line 2821 "Python/generated_cases.c.h" + #line 2837 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 1998 "Python/bytecodes.c" + #line 2008 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2834,9 +2850,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2838 "Python/generated_cases.c.h" + #line 2854 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2008 "Python/bytecodes.c" + #line 2018 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2844,67 +2860,67 @@ if (err < 0) goto pop_1_error; } } - #line 2848 "Python/generated_cases.c.h" + #line 2864 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2018 "Python/bytecodes.c" + #line 2028 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 2857 "Python/generated_cases.c.h" + #line 2873 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2020 "Python/bytecodes.c" + #line 2030 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 2865 "Python/generated_cases.c.h" + #line 2881 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2028 "Python/bytecodes.c" + #line 2038 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 2878 "Python/generated_cases.c.h" + #line 2894 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2034 "Python/bytecodes.c" + #line 2044 "Python/bytecodes.c" } - #line 2882 "Python/generated_cases.c.h" + #line 2898 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2038 "Python/bytecodes.c" + #line 2048 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 2895 "Python/generated_cases.c.h" + #line 2911 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2047 "Python/bytecodes.c" + #line 2057 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 2908 "Python/generated_cases.c.h" + #line 2924 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -2915,16 +2931,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2055 "Python/bytecodes.c" + #line 2065 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 2924 "Python/generated_cases.c.h" + #line 2940 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2060 "Python/bytecodes.c" + #line 2070 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -2932,7 +2948,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 2936 "Python/generated_cases.c.h" + #line 2952 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -2941,10 +2957,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2070 "Python/bytecodes.c" + #line 2080 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 2948 "Python/generated_cases.c.h" + #line 2964 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2954,10 +2970,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2076 "Python/bytecodes.c" + #line 2086 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 2961 "Python/generated_cases.c.h" + #line 2977 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2968,11 +2984,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2082 "Python/bytecodes.c" + #line 2092 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 2976 "Python/generated_cases.c.h" + #line 2992 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -2981,14 +2997,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2088 "Python/bytecodes.c" + #line 2098 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 2988 "Python/generated_cases.c.h" + #line 3004 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2091 "Python/bytecodes.c" + #line 2101 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 2992 "Python/generated_cases.c.h" + #line 3008 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -2996,7 +3012,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2095 "Python/bytecodes.c" + #line 2105 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3019,11 +3035,11 @@ if (iter == NULL) { goto error; } - #line 3023 "Python/generated_cases.c.h" + #line 3039 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2118 "Python/bytecodes.c" + #line 2128 "Python/bytecodes.c" } - #line 3027 "Python/generated_cases.c.h" + #line 3043 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3034,7 +3050,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2137 "Python/bytecodes.c" + #line 2147 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3065,7 +3081,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3069 "Python/generated_cases.c.h" + #line 3085 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3073,7 +3089,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2170 "Python/bytecodes.c" + #line 2180 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3099,14 +3115,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3103 "Python/generated_cases.c.h" + #line 3119 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2198 "Python/bytecodes.c" + #line 2208 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3126,7 +3142,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3130 "Python/generated_cases.c.h" + #line 3146 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3136,7 +3152,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2220 "Python/bytecodes.c" + #line 2230 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3156,7 +3172,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3160 "Python/generated_cases.c.h" + #line 3176 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3166,7 +3182,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2242 "Python/bytecodes.c" + #line 2252 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3184,7 +3200,7 @@ if (next == NULL) { goto error; } - #line 3188 "Python/generated_cases.c.h" + #line 3204 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3193,7 +3209,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2262 "Python/bytecodes.c" + #line 2272 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3208,14 +3224,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3212 "Python/generated_cases.c.h" + #line 3228 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2279 "Python/bytecodes.c" + #line 2289 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3238,16 +3254,16 @@ Py_DECREF(enter); goto error; } - #line 3242 "Python/generated_cases.c.h" + #line 3258 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2302 "Python/bytecodes.c" + #line 2312 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3251 "Python/generated_cases.c.h" + #line 3267 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3259,7 +3275,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2312 "Python/bytecodes.c" + #line 2322 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3285,16 +3301,16 @@ Py_DECREF(enter); goto error; } - #line 3289 "Python/generated_cases.c.h" + #line 3305 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2338 "Python/bytecodes.c" + #line 2348 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3298 "Python/generated_cases.c.h" + #line 3314 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3306,7 +3322,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2347 "Python/bytecodes.c" + #line 2357 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3327,7 +3343,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3331 "Python/generated_cases.c.h" + #line 3347 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3336,7 +3352,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2370 "Python/bytecodes.c" + #line 2380 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3346,7 +3362,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3350 "Python/generated_cases.c.h" + #line 3366 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3360,7 +3376,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2382 "Python/bytecodes.c" + #line 2392 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3377,7 +3393,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3381 "Python/generated_cases.c.h" + #line 3397 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3391,7 +3407,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2401 "Python/bytecodes.c" + #line 2411 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3401,7 +3417,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3405 "Python/generated_cases.c.h" + #line 3421 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3415,7 +3431,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2413 "Python/bytecodes.c" + #line 2423 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3429,7 +3445,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3433 "Python/generated_cases.c.h" + #line 3449 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3438,16 +3454,16 @@ } TARGET(KW_NAMES) { - #line 2429 "Python/bytecodes.c" + #line 2439 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3446 "Python/generated_cases.c.h" + #line 3462 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2435 "Python/bytecodes.c" + #line 2445 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3460,7 +3476,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3464 "Python/generated_cases.c.h" + #line 3480 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3470,7 +3486,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2480 "Python/bytecodes.c" + #line 2490 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3552,7 +3568,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3556 "Python/generated_cases.c.h" + #line 3572 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3564,7 +3580,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2568 "Python/bytecodes.c" + #line 2578 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3574,7 +3590,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3578 "Python/generated_cases.c.h" + #line 3594 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3583,7 +3599,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2580 "Python/bytecodes.c" + #line 2590 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3609,7 +3625,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3613 "Python/generated_cases.c.h" + #line 3629 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3617,7 +3633,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2608 "Python/bytecodes.c" + #line 2618 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3653,7 +3669,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3657 "Python/generated_cases.c.h" + #line 3673 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3661,7 +3677,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2646 "Python/bytecodes.c" + #line 2656 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3671,7 +3687,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3675 "Python/generated_cases.c.h" + #line 3691 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3684,7 +3700,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2658 "Python/bytecodes.c" + #line 2668 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3695,7 +3711,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3699 "Python/generated_cases.c.h" + #line 3715 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3709,7 +3725,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2672 "Python/bytecodes.c" + #line 2682 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3720,7 +3736,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3724 "Python/generated_cases.c.h" + #line 3740 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3734,7 +3750,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2686 "Python/bytecodes.c" + #line 2696 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3756,7 +3772,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3760 "Python/generated_cases.c.h" + #line 3776 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3770,7 +3786,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2711 "Python/bytecodes.c" + #line 2721 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3798,7 +3814,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3802 "Python/generated_cases.c.h" + #line 3818 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3812,7 +3828,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2742 "Python/bytecodes.c" + #line 2752 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3844,7 +3860,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 3848 "Python/generated_cases.c.h" + #line 3864 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3858,7 +3874,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2777 "Python/bytecodes.c" + #line 2787 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -3890,7 +3906,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3894 "Python/generated_cases.c.h" + #line 3910 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3904,7 +3920,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2812 "Python/bytecodes.c" + #line 2822 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -3929,7 +3945,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3933 "Python/generated_cases.c.h" + #line 3949 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3942,7 +3958,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2839 "Python/bytecodes.c" + #line 2849 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -3969,7 +3985,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3973 "Python/generated_cases.c.h" + #line 3989 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3981,7 +3997,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2869 "Python/bytecodes.c" + #line 2879 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -3999,14 +4015,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4003 "Python/generated_cases.c.h" + #line 4019 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2889 "Python/bytecodes.c" + #line 2899 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4037,7 +4053,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4041 "Python/generated_cases.c.h" + #line 4057 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4050,7 +4066,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2923 "Python/bytecodes.c" + #line 2933 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4079,7 +4095,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4083 "Python/generated_cases.c.h" + #line 4099 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4092,7 +4108,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2955 "Python/bytecodes.c" + #line 2965 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4121,7 +4137,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4125 "Python/generated_cases.c.h" + #line 4141 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4134,7 +4150,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2987 "Python/bytecodes.c" + #line 2997 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4162,7 +4178,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4166 "Python/generated_cases.c.h" + #line 4182 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4172,9 +4188,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3018 "Python/bytecodes.c" + #line 3028 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4178 "Python/generated_cases.c.h" + #line 4194 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4183,7 +4199,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3022 "Python/bytecodes.c" + #line 3032 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4226,14 +4242,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4230 "Python/generated_cases.c.h" + #line 4246 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3065 "Python/bytecodes.c" + #line 3075 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4237 "Python/generated_cases.c.h" + #line 4253 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4243,12 +4259,13 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; - PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0))] : NULL; - PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL; - PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; - PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; + PyObject *locals = (oparg & 0x20) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0))] : NULL; + PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0))] : NULL; + PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL; + PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; + PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3075 "Python/bytecodes.c" + #line 3086 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4258,6 +4275,10 @@ goto error; } + if (oparg & 0x20) { + assert(PyDict_CheckExact(locals)); + func_obj->func_locals = locals; + } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; @@ -4277,14 +4298,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4281 "Python/generated_cases.c.h" - STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); + #line 4302 "Python/generated_cases.c.h" + STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x20) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3106 "Python/bytecodes.c" + #line 3121 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4305,7 +4326,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4309 "Python/generated_cases.c.h" + #line 4330 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4313,15 +4334,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3129 "Python/bytecodes.c" + #line 3144 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4319 "Python/generated_cases.c.h" + #line 4340 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3131 "Python/bytecodes.c" + #line 3146 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4325 "Python/generated_cases.c.h" + #line 4346 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4332,7 +4353,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3135 "Python/bytecodes.c" + #line 3150 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4367,7 +4388,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4371 "Python/generated_cases.c.h" + #line 4392 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4376,10 +4397,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3172 "Python/bytecodes.c" + #line 3187 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4383 "Python/generated_cases.c.h" + #line 4404 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4391,7 +4412,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3177 "Python/bytecodes.c" + #line 3192 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4406,12 +4427,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4410 "Python/generated_cases.c.h" + #line 4431 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3192 "Python/bytecodes.c" + #line 3207 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4415 "Python/generated_cases.c.h" + #line 4436 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4421,16 +4442,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3197 "Python/bytecodes.c" + #line 3212 "Python/bytecodes.c" assert(oparg >= 2); - #line 4427 "Python/generated_cases.c.h" + #line 4448 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3201 "Python/bytecodes.c" + #line 3216 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4450,11 +4471,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4454 "Python/generated_cases.c.h" + #line 4475 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3223 "Python/bytecodes.c" + #line 3238 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4466,26 +4487,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4470 "Python/generated_cases.c.h" + #line 4491 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3237 "Python/bytecodes.c" + #line 3252 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4476 "Python/generated_cases.c.h" + #line 4497 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3241 "Python/bytecodes.c" + #line 3256 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4483 "Python/generated_cases.c.h" + #line 4504 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3246 "Python/bytecodes.c" + #line 3261 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4494,12 +4515,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4498 "Python/generated_cases.c.h" + #line 4519 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3257 "Python/bytecodes.c" + #line 3272 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4508,12 +4529,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4512 "Python/generated_cases.c.h" + #line 4533 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3268 "Python/bytecodes.c" + #line 3283 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4526,12 +4547,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4530 "Python/generated_cases.c.h" + #line 4551 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3283 "Python/bytecodes.c" + #line 3298 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4544,30 +4565,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4548 "Python/generated_cases.c.h" + #line 4569 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3298 "Python/bytecodes.c" + #line 3313 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4559 "Python/generated_cases.c.h" + #line 4580 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3306 "Python/bytecodes.c" + #line 3321 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4566 "Python/generated_cases.c.h" + #line 4587 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3311 "Python/bytecodes.c" + #line 3326 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4573 "Python/generated_cases.c.h" + #line 4594 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 4681ed03aff582..84dc7ac6b15d89 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -137,6 +137,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 0; case LOAD_BUILD_CLASS: return 0; + case LOAD_LOCALS: + return 0; case STORE_NAME: return 1; case DELETE_NAME: @@ -346,7 +348,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case CALL_FUNCTION_EX: return ((oparg & 1) ? 1 : 0) + 3; case MAKE_FUNCTION: - return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1; + return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x20) ? 1 : 0) + 1; case RETURN_GENERATOR: return 0; case BUILD_SLICE: @@ -521,6 +523,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case LOAD_BUILD_CLASS: return 1; + case LOAD_LOCALS: + return 1; case STORE_NAME: return 0; case DELETE_NAME: @@ -845,6 +849,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [CLEANUP_THROW] = { true, INSTR_FMT_IX }, [LOAD_ASSERTION_ERROR] = { true, INSTR_FMT_IX }, [LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX }, + [LOAD_LOCALS] = { true, INSTR_FMT_IX }, [STORE_NAME] = { true, INSTR_FMT_IB }, [DELETE_NAME] = { true, INSTR_FMT_IB }, [UNPACK_SEQUENCE] = { true, INSTR_FMT_IBC }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 9d6616666f7ac1..302a74262286a5 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -86,8 +86,8 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_FAST__LOAD_FAST, &&TARGET_SETUP_ANNOTATIONS, &&TARGET_LOAD_GLOBAL_BUILTIN, + &&TARGET_LOAD_LOCALS, &&TARGET_LOAD_GLOBAL_MODULE, - &&TARGET_STORE_ATTR_INSTANCE_VALUE, &&TARGET_POP_EXCEPT, &&TARGET_STORE_NAME, &&TARGET_DELETE_NAME, @@ -110,9 +110,9 @@ static void *opcode_targets[256] = { &&TARGET_IMPORT_NAME, &&TARGET_IMPORT_FROM, &&TARGET_JUMP_FORWARD, + &&TARGET_STORE_ATTR_INSTANCE_VALUE, &&TARGET_STORE_ATTR_SLOT, &&TARGET_STORE_ATTR_WITH_HINT, - &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_LOAD_GLOBAL, @@ -140,9 +140,9 @@ static void *opcode_targets[256] = { &&TARGET_STORE_DEREF, &&TARGET_DELETE_DEREF, &&TARGET_JUMP_BACKWARD, - &&TARGET_STORE_FAST__STORE_FAST, + &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_CALL_FUNCTION_EX, - &&TARGET_STORE_SUBSCR_DICT, + &&TARGET_STORE_FAST__STORE_FAST, &&TARGET_EXTENDED_ARG, &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, @@ -152,15 +152,15 @@ static void *opcode_targets[256] = { &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, + &&TARGET_STORE_SUBSCR_DICT, &&TARGET_STORE_SUBSCR_LIST_INT, - &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, + &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_UNPACK_SEQUENCE_TUPLE, &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, - &&_unknown_opcode, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, From 8a0ecb75b95799b785b00401fb17e1b8deaab725 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 15:17:19 -0600 Subject: [PATCH 102/200] simplify the intrinsic --- Objects/funcobject.c | 2 +- Python/compile.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 148ef3d4724900..5b85045215cb0c 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -676,7 +676,7 @@ _Py_set_function_type_params(PyThreadState *unused, PyObject *func, return NULL; } Py_XSETREF(f->func_typeparams, Py_NewRef(type_params)); - Py_RETURN_NONE; + return Py_NewRef(func); } diff --git a/Python/compile.c b/Python/compile.c index f0d52055419d7f..c07e383a618f94 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2284,10 +2284,8 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } Py_DECREF(co); if (asdl_seq_LEN(typeparams) > 0) { - ADDOP_I(c, loc, COPY, 1); RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS); - ADDOP(c, loc, POP_TOP); if (is_typeparams_in_class) { c->u->u_metadata.u_argcount += 1; From 0bb175abff6b87b2cd50cd6f446a99c304466a8c Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Wed, 26 Apr 2023 16:25:42 -0600 Subject: [PATCH 103/200] Changed strategy, func_class_dict and *_CLASS_DICT. Rather than changing a bunch of stuff (and confusing the runtime by having __annotate__ functions have *both* fast *and* slow locals) we're changing the approach. For delayed-evaluation expressions (e.g. __annotate__ in PEP 649) we're going to change the LOAD_NAME opcodes we generate into LOAD_CLASS_DICT opcodes. Then when we bind that function (e.g. an __annotate__ inside a class body) we're going to use the new INTRINSIC2 SET_CLASS_DICT opcode to set the new func_class_dict field. LOAD_CLASS_DICT does its lookup in frame->f_funcobj->func_class_dict, so, we didn't make the frame larger! --- Include/cpython/funcobject.h | 10 +- Include/internal/pycore_intrinsics.h | 3 +- Include/internal/pycore_opcode.h | 4 +- Include/opcode.h | 1 + Lib/opcode.py | 2 + Objects/frameobject.c | 1 - Objects/funcobject.c | 14 +- Python/bltinmodule.c | 6 - Python/bytecodes.c | 34 +- Python/ceval.c | 2 - Python/compile.c | 8 - Python/generated_cases.c.h | 606 ++++++++++++++------------- Python/intrinsics.c | 11 + Python/opcode_metadata.h | 7 +- Python/opcode_targets.h | 2 +- 15 files changed, 384 insertions(+), 327 deletions(-) diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index 2f327885052217..eea3768d8d227c 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -10,7 +10,6 @@ extern "C" { #define COMMON_FIELDS(PREFIX) \ PyObject *PREFIX ## globals; \ - PyObject *PREFIX ## locals; /* "slow" locals, not fast */ \ PyObject *PREFIX ## builtins; \ PyObject *PREFIX ## name; \ PyObject *PREFIX ## qualname; \ @@ -42,6 +41,7 @@ typedef struct { PyObject *func_weakreflist; /* List of weak references */ PyObject *func_module; /* The __module__ attribute, can be anything */ PyObject *func_annotations; /* Annotations, a dict or NULL */ + PyObject *func_class_dict; /* Class dict, a dict or NULL */ vectorcallfunc vectorcall; /* Version number for use by specializer. * Can set to non-zero when we want to specialize. @@ -68,7 +68,7 @@ PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetLocals(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetClassDict(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); @@ -101,10 +101,10 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) { } #define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func)) -static inline PyObject* PyFunction_GET_LOCALS(PyObject *func) { - return _PyFunction_CAST(func)->func_locals; +static inline PyObject* PyFunction_GET_CLASS_DICT(PyObject *func) { + return _PyFunction_CAST(func)->func_class_dict; } -#define PyFunction_GET_LOCALS(func) PyFunction_GET_LOCALS(_PyObject_CAST(func)) +#define PyFunction_GET_CLASS_DICT(func) PyFunction_GET_CLASS_DICT(_PyObject_CAST(func)) static inline PyObject* PyFunction_GET_MODULE(PyObject *func) { return _PyFunction_CAST(func)->func_module; diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index 46a52740eb8a0c..3f971a21952f26 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -14,8 +14,9 @@ /* Binary Functions: */ #define INTRINSIC_PREP_RERAISE_STAR 1 +#define INTRINSIC_SET_CLASS_DICT 2 -#define MAX_INTRINSIC_2 1 +#define MAX_INTRINSIC_2 2 typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value); diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index 51b4239102df0d..940596214e9631 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -167,6 +167,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, [LOAD_CLASSDEREF] = LOAD_CLASSDEREF, + [LOAD_CLASS_DICT] = LOAD_CLASS_DICT, [LOAD_CLOSURE] = LOAD_CLOSURE, [LOAD_CONST] = LOAD_CONST, [LOAD_CONST__LOAD_FAST] = LOAD_CONST, @@ -413,7 +414,7 @@ static const char *const _PyOpcode_OpName[263] = { [KW_NAMES] = "KW_NAMES", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", - [175] = "<175>", + [LOAD_CLASS_DICT] = "LOAD_CLASS_DICT", [176] = "<176>", [177] = "<177>", [178] = "<178>", @@ -510,7 +511,6 @@ static const char *const _PyOpcode_OpName[263] = { case 168: \ case 169: \ case 170: \ - case 175: \ case 176: \ case 177: \ case 178: \ diff --git a/Include/opcode.h b/Include/opcode.h index 41dec5e76c039e..d54530574b7b76 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -117,6 +117,7 @@ extern "C" { #define KW_NAMES 172 #define CALL_INTRINSIC_1 173 #define CALL_INTRINSIC_2 174 +#define LOAD_CLASS_DICT 175 #define MIN_INSTRUMENTED_OPCODE 238 #define INSTRUMENTED_POP_JUMP_IF_NONE 238 #define INSTRUMENTED_POP_JUMP_IF_NOT_NONE 239 diff --git a/Lib/opcode.py b/Lib/opcode.py index ecdd3ebbdf6f64..b1e97ce39fd022 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -227,6 +227,8 @@ def pseudo_op(name, op, real_ops): def_op('CALL_INTRINSIC_1', 173) def_op('CALL_INTRINSIC_2', 174) +def_op('LOAD_CLASS_DICT', 175) + # Instrumented instructions MIN_INSTRUMENTED_OPCODE = 238 diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 01180325376c08..ef0070199ab2c0 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1071,7 +1071,6 @@ PyFrame_New(PyThreadState *tstate, PyCodeObject *code, } PyFrameConstructor desc = { .fc_globals = globals, - .fc_locals = NULL, .fc_builtins = builtins, .fc_name = code->co_name, .fc_qualname = code->co_name, diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 8d5315b11df278..2bff971d069a6e 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -112,7 +112,6 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) return NULL; } op->func_globals = Py_NewRef(constr->fc_globals); - op->func_locals = Py_XNewRef(constr->fc_locals); op->func_builtins = Py_NewRef(constr->fc_builtins); op->func_name = Py_NewRef(constr->fc_name); op->func_qualname = Py_NewRef(constr->fc_qualname); @@ -120,6 +119,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) op->func_defaults = Py_XNewRef(constr->fc_defaults); op->func_kwdefaults = Py_XNewRef(constr->fc_kwdefaults); op->func_closure = Py_XNewRef(constr->fc_closure); + op->func_class_dict = NULL; op->func_doc = Py_NewRef(Py_None); op->func_dict = NULL; op->func_weakreflist = NULL; @@ -191,7 +191,6 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname expect a partially-created object. */ op->func_globals = globals; - op->func_locals = NULL; op->func_builtins = builtins; op->func_name = name; op->func_qualname = qualname; @@ -204,6 +203,7 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname op->func_weakreflist = NULL; op->func_module = module; op->func_annotations = NULL; + op->func_class_dict = NULL; op->vectorcall = _PyFunction_Vectorcall; op->func_version = 0; _PyObject_GC_TRACK(op); @@ -265,13 +265,13 @@ PyFunction_GetGlobals(PyObject *op) } PyObject * -PyFunction_GetLocals(PyObject *op) +PyFunction_GetClassDict(PyObject *op) { if (!PyFunction_Check(op)) { PyErr_BadInternalCall(); return NULL; } - return ((PyFunctionObject *) op) -> func_locals; + return ((PyFunctionObject *) op) -> func_class_dict; } PyObject * @@ -462,9 +462,9 @@ static PyMemberDef func_memberlist[] = { {"__closure__", T_OBJECT, OFF(func_closure), READONLY}, {"__doc__", T_OBJECT, OFF(func_doc), 0}, {"__globals__", T_OBJECT, OFF(func_globals), READONLY}, - {"__locals__", T_OBJECT, OFF(func_locals), 0}, {"__module__", T_OBJECT, OFF(func_module), 0}, {"__builtins__", T_OBJECT, OFF(func_builtins), READONLY}, + {"__class_dict__",T_OBJECT, OFF(func_class_dict), READONLY}, {NULL} /* Sentinel */ }; @@ -788,7 +788,6 @@ func_clear(PyFunctionObject *op) { op->func_version = 0; Py_CLEAR(op->func_globals); - Py_CLEAR(op->func_locals); Py_CLEAR(op->func_builtins); Py_CLEAR(op->func_module); Py_CLEAR(op->func_defaults); @@ -797,6 +796,7 @@ func_clear(PyFunctionObject *op) Py_CLEAR(op->func_dict); Py_CLEAR(op->func_closure); Py_CLEAR(op->func_annotations); + Py_CLEAR(op->func_class_dict); // Don't Py_CLEAR(op->func_code), since code is always required // to be non-NULL. Similarly, name and qualname shouldn't be NULL. // However, name and qualname could be str subclasses, so they @@ -842,7 +842,6 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) { Py_VISIT(f->func_code); Py_VISIT(f->func_globals); - Py_VISIT(f->func_locals); Py_VISIT(f->func_builtins); Py_VISIT(f->func_module); Py_VISIT(f->func_defaults); @@ -852,6 +851,7 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) Py_VISIT(f->func_dict); Py_VISIT(f->func_closure); Py_VISIT(f->func_annotations); + Py_VISIT(f->func_class_dict); Py_VISIT(f->func_qualname); return 0; } diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 0d634e526305ac..08107ea2c7dc64 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -196,12 +196,6 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, goto error; } - if (((PyFunctionObject *)func)->func_locals != NULL) { - const char *msg = - "__locals__ not set on class body function defining %.200R"; - PyErr_Format(PyExc_RuntimeError, msg, cls); - } - PyThreadState *tstate = _PyThreadState_GET(); EVAL_CALL_STAT_INC(EVAL_CALL_BUILD_CLASS); cell = _PyEval_Vector(tstate, (PyFunctionObject *)func, ns, NULL, 0, NULL); diff --git a/Python/bytecodes.c b/Python/bytecodes.c index ad6ac8b1339d7d..4649e971b9821c 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1219,6 +1219,35 @@ dummy_func( } } + inst(LOAD_CLASS_DICT, ( -- v)) { + PyObject *name = GETITEM(frame->f_code->co_names, oparg); + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no function defined when loading %R from class dict", name); + goto error; + } + PyObject *class_dict = func->func_class_dict; + if (class_dict == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no class dict set when loading %R", name); + goto error; + } + if (PyDict_CheckExact(class_dict)) { + v = PyDict_GetItemWithError(class_dict, name); + if (v != NULL) { + Py_INCREF(v); + } + } + else { + v = PyObject_GetItem(class_dict, name); + } + if (_PyErr_Occurred(tstate)) { + goto error; + } + assert(v != NULL); + } + family(load_global, INLINE_CACHE_ENTRIES_LOAD_GLOBAL) = { LOAD_GLOBAL, LOAD_GLOBAL_MODULE, @@ -3081,7 +3110,6 @@ dummy_func( kwdefaults if (oparg & 0x02), annotations if (oparg & 0x04), closure if (oparg & 0x08), - locals if (oparg & 0x20), codeobj -- func)) { PyFunctionObject *func_obj = (PyFunctionObject *) @@ -3092,10 +3120,6 @@ dummy_func( goto error; } - if (oparg & 0x20) { - assert(PyDict_CheckExact(locals)); - func_obj->func_locals = locals; - } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; diff --git a/Python/ceval.c b/Python/ceval.c index 69a2b692b7899f..153e3023a4f2b2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -549,7 +549,6 @@ PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) } PyFrameConstructor desc = { .fc_globals = globals, - .fc_locals = locals, .fc_builtins = builtins, .fc_name = ((PyCodeObject *)co)->co_name, .fc_qualname = ((PyCodeObject *)co)->co_name, @@ -1584,7 +1583,6 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, } PyFrameConstructor constr = { .fc_globals = globals, - .fc_locals = locals, .fc_builtins = builtins, .fc_name = ((PyCodeObject *)_co)->co_name, .fc_qualname = ((PyCodeObject *)_co)->co_name, diff --git a/Python/compile.c b/Python/compile.c index 9cc8b4c12ed0cf..00ad8861661f4f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1754,14 +1754,6 @@ compiler_make_closure(struct compiler *c, location loc, ADDOP_I(c, loc, BUILD_TUPLE, co->co_nfreevars); } - /* If flag 0x20 is set, we want to bind func_locals - to the current locals at runtime. - Push them on the stack in the right spot. - */ - if (flags & 0x20) { - ADDOP(c, loc, LOAD_LOCALS); - } - ADDOP_LOAD_CONST(c, loc, (PyObject*)co); ADDOP_I(c, loc, MAKE_FUNCTION, flags); return SUCCESS; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index b8c50028ea75b4..284ff06a9a90f8 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1679,12 +1679,47 @@ DISPATCH(); } + TARGET(LOAD_CLASS_DICT) { + PyObject *v; + #line 1223 "Python/bytecodes.c" + PyObject *name = GETITEM(frame->f_code->co_names, oparg); + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no function defined when loading %R from class dict", name); + goto error; + } + PyObject *class_dict = func->func_class_dict; + if (class_dict == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no class dict set when loading %R", name); + goto error; + } + if (PyDict_CheckExact(class_dict)) { + v = PyDict_GetItemWithError(class_dict, name); + if (v != NULL) { + Py_INCREF(v); + } + } + else { + v = PyObject_GetItem(class_dict, name); + } + if (_PyErr_Occurred(tstate)) { + goto error; + } + assert(v != NULL); + #line 1712 "Python/generated_cases.c.h" + STACK_GROW(1); + stack_pointer[-1] = v; + DISPATCH(); + } + TARGET(LOAD_GLOBAL) { PREDICTED(LOAD_GLOBAL); static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1229 "Python/bytecodes.c" + #line 1258 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1736,7 +1771,7 @@ } } null = NULL; - #line 1740 "Python/generated_cases.c.h" + #line 1775 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1750,7 +1785,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1283 "Python/bytecodes.c" + #line 1312 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1761,7 +1796,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1765 "Python/generated_cases.c.h" + #line 1800 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1776,7 +1811,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1296 "Python/bytecodes.c" + #line 1325 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1791,7 +1826,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1795 "Python/generated_cases.c.h" + #line 1830 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1801,16 +1836,16 @@ } TARGET(DELETE_FAST) { - #line 1313 "Python/bytecodes.c" + #line 1342 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1809 "Python/generated_cases.c.h" + #line 1844 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1319 "Python/bytecodes.c" + #line 1348 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1819,12 +1854,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1823 "Python/generated_cases.c.h" + #line 1858 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1330 "Python/bytecodes.c" + #line 1359 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1835,13 +1870,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1839 "Python/generated_cases.c.h" + #line 1874 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1343 "Python/bytecodes.c" + #line 1372 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1873,7 +1908,7 @@ } Py_INCREF(value); } - #line 1877 "Python/generated_cases.c.h" + #line 1912 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1881,7 +1916,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1377 "Python/bytecodes.c" + #line 1406 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1889,7 +1924,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1893 "Python/generated_cases.c.h" + #line 1928 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1897,18 +1932,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1387 "Python/bytecodes.c" + #line 1416 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 1906 "Python/generated_cases.c.h" + #line 1941 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1394 "Python/bytecodes.c" + #line 1423 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1919,22 +1954,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 1923 "Python/generated_cases.c.h" + #line 1958 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1407 "Python/bytecodes.c" + #line 1436 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 1932 "Python/generated_cases.c.h" + #line 1967 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1409 "Python/bytecodes.c" + #line 1438 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1938 "Python/generated_cases.c.h" + #line 1973 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -1944,10 +1979,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1413 "Python/bytecodes.c" + #line 1442 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1951 "Python/generated_cases.c.h" + #line 1986 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -1957,10 +1992,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1418 "Python/bytecodes.c" + #line 1447 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1964 "Python/generated_cases.c.h" + #line 1999 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -1970,7 +2005,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1423 "Python/bytecodes.c" + #line 1452 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -1981,13 +2016,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 1985 "Python/generated_cases.c.h" + #line 2020 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1434 "Python/bytecodes.c" + #line 1463 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 1991 "Python/generated_cases.c.h" + #line 2026 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -1996,13 +2031,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1441 "Python/bytecodes.c" + #line 1470 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2002 "Python/generated_cases.c.h" + #line 2037 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1443 "Python/bytecodes.c" + #line 1472 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2006 "Python/generated_cases.c.h" + #line 2041 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2010,7 +2045,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1447 "Python/bytecodes.c" + #line 1476 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2025,7 +2060,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2029 "Python/generated_cases.c.h" + #line 2064 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2035,7 +2070,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1464 "Python/bytecodes.c" + #line 1493 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2043,13 +2078,13 @@ if (map == NULL) goto error; - #line 2047 "Python/generated_cases.c.h" + #line 2082 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1472 "Python/bytecodes.c" + #line 1501 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2053 "Python/generated_cases.c.h" + #line 2088 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2057,7 +2092,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1476 "Python/bytecodes.c" + #line 1505 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2097,7 +2132,7 @@ Py_DECREF(ann_dict); } } - #line 2101 "Python/generated_cases.c.h" + #line 2136 "Python/generated_cases.c.h" DISPATCH(); } @@ -2105,7 +2140,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1518 "Python/bytecodes.c" + #line 1547 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2115,14 +2150,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2119 "Python/generated_cases.c.h" + #line 2154 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1528 "Python/bytecodes.c" + #line 1557 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2126 "Python/generated_cases.c.h" + #line 2161 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2130,7 +2165,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1532 "Python/bytecodes.c" + #line 1561 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2138,12 +2173,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2142 "Python/generated_cases.c.h" + #line 2177 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1540 "Python/bytecodes.c" + #line 1569 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2147 "Python/generated_cases.c.h" + #line 2182 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2151,17 +2186,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1546 "Python/bytecodes.c" + #line 1575 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2160 "Python/generated_cases.c.h" + #line 2195 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1551 "Python/bytecodes.c" + #line 1580 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2165 "Python/generated_cases.c.h" + #line 2200 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2171,13 +2206,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1558 "Python/bytecodes.c" + #line 1587 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2181 "Python/generated_cases.c.h" + #line 2216 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2189,7 +2224,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1581 "Python/bytecodes.c" + #line 1610 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2223,9 +2258,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2227 "Python/generated_cases.c.h" + #line 2262 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1615 "Python/bytecodes.c" + #line 1644 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2234,12 +2269,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2238 "Python/generated_cases.c.h" + #line 2273 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1624 "Python/bytecodes.c" + #line 1653 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2243 "Python/generated_cases.c.h" + #line 2278 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2253,7 +2288,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1629 "Python/bytecodes.c" + #line 1658 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2266,7 +2301,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2270 "Python/generated_cases.c.h" + #line 2305 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2281,7 +2316,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1645 "Python/bytecodes.c" + #line 1674 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2294,7 +2329,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2298 "Python/generated_cases.c.h" + #line 2333 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2309,7 +2344,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1661 "Python/bytecodes.c" + #line 1690 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2336,7 +2371,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2340 "Python/generated_cases.c.h" + #line 2375 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2351,7 +2386,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1691 "Python/bytecodes.c" + #line 1720 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2361,7 +2396,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2365 "Python/generated_cases.c.h" + #line 2400 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2376,7 +2411,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1704 "Python/bytecodes.c" + #line 1733 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2388,7 +2423,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2392 "Python/generated_cases.c.h" + #line 2427 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2402,7 +2437,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1719 "Python/bytecodes.c" + #line 1748 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2426,7 +2461,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2430 "Python/generated_cases.c.h" + #line 2465 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2434,7 +2469,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1745 "Python/bytecodes.c" + #line 1774 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2460,7 +2495,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2464 "Python/generated_cases.c.h" + #line 2499 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2468,7 +2503,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1773 "Python/bytecodes.c" + #line 1802 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2486,7 +2521,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2490 "Python/generated_cases.c.h" + #line 2525 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2497,7 +2532,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1793 "Python/bytecodes.c" + #line 1822 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2536,7 +2571,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2540 "Python/generated_cases.c.h" + #line 2575 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2547,7 +2582,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1834 "Python/bytecodes.c" + #line 1863 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2557,7 +2592,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2561 "Python/generated_cases.c.h" + #line 2596 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2569,7 +2604,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1853 "Python/bytecodes.c" + #line 1882 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2582,12 +2617,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2586 "Python/generated_cases.c.h" + #line 2621 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1866 "Python/bytecodes.c" + #line 1895 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2591 "Python/generated_cases.c.h" + #line 2626 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2598,7 +2633,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1870 "Python/bytecodes.c" + #line 1899 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2610,7 +2645,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2614 "Python/generated_cases.c.h" + #line 2649 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2621,7 +2656,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1885 "Python/bytecodes.c" + #line 1914 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2637,7 +2672,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2641 "Python/generated_cases.c.h" + #line 2676 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2648,7 +2683,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1904 "Python/bytecodes.c" + #line 1933 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2661,7 +2696,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2665 "Python/generated_cases.c.h" + #line 2700 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2672,14 +2707,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1919 "Python/bytecodes.c" + #line 1948 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2678 "Python/generated_cases.c.h" + #line 2713 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1921 "Python/bytecodes.c" + #line 1950 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2683 "Python/generated_cases.c.h" + #line 2718 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2689,15 +2724,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1925 "Python/bytecodes.c" + #line 1954 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2695 "Python/generated_cases.c.h" + #line 2730 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1927 "Python/bytecodes.c" + #line 1956 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2701 "Python/generated_cases.c.h" + #line 2736 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2708,12 +2743,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 1932 "Python/bytecodes.c" + #line 1961 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2714 "Python/generated_cases.c.h" + #line 2749 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1934 "Python/bytecodes.c" + #line 1963 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2721,10 +2756,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2725 "Python/generated_cases.c.h" + #line 2760 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1942 "Python/bytecodes.c" + #line 1971 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2733,7 +2768,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2737 "Python/generated_cases.c.h" + #line 2772 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2743,21 +2778,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1953 "Python/bytecodes.c" + #line 1982 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2750 "Python/generated_cases.c.h" + #line 2785 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1956 "Python/bytecodes.c" + #line 1985 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2757 "Python/generated_cases.c.h" + #line 2792 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1961 "Python/bytecodes.c" + #line 1990 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2761 "Python/generated_cases.c.h" + #line 2796 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2766,15 +2801,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 1965 "Python/bytecodes.c" + #line 1994 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2773 "Python/generated_cases.c.h" + #line 2808 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 1968 "Python/bytecodes.c" + #line 1997 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2778 "Python/generated_cases.c.h" + #line 2813 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2783,29 +2818,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 1972 "Python/bytecodes.c" + #line 2001 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2791 "Python/generated_cases.c.h" + #line 2826 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 1978 "Python/bytecodes.c" + #line 2007 "Python/bytecodes.c" JUMPBY(oparg); - #line 2800 "Python/generated_cases.c.h" + #line 2835 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 1982 "Python/bytecodes.c" + #line 2011 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2809 "Python/generated_cases.c.h" + #line 2844 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2813,7 +2848,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 1988 "Python/bytecodes.c" + #line 2017 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2823,9 +2858,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2827 "Python/generated_cases.c.h" + #line 2862 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 1998 "Python/bytecodes.c" + #line 2027 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2833,14 +2868,14 @@ if (err < 0) goto pop_1_error; } } - #line 2837 "Python/generated_cases.c.h" + #line 2872 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2008 "Python/bytecodes.c" + #line 2037 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2850,9 +2885,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2854 "Python/generated_cases.c.h" + #line 2889 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2018 "Python/bytecodes.c" + #line 2047 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2860,67 +2895,67 @@ if (err < 0) goto pop_1_error; } } - #line 2864 "Python/generated_cases.c.h" + #line 2899 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2028 "Python/bytecodes.c" + #line 2057 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 2873 "Python/generated_cases.c.h" + #line 2908 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2030 "Python/bytecodes.c" + #line 2059 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 2881 "Python/generated_cases.c.h" + #line 2916 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2038 "Python/bytecodes.c" + #line 2067 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 2894 "Python/generated_cases.c.h" + #line 2929 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2044 "Python/bytecodes.c" + #line 2073 "Python/bytecodes.c" } - #line 2898 "Python/generated_cases.c.h" + #line 2933 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2048 "Python/bytecodes.c" + #line 2077 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 2911 "Python/generated_cases.c.h" + #line 2946 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2057 "Python/bytecodes.c" + #line 2086 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 2924 "Python/generated_cases.c.h" + #line 2959 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -2931,16 +2966,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2065 "Python/bytecodes.c" + #line 2094 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 2940 "Python/generated_cases.c.h" + #line 2975 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2070 "Python/bytecodes.c" + #line 2099 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -2948,7 +2983,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 2952 "Python/generated_cases.c.h" + #line 2987 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -2957,10 +2992,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2080 "Python/bytecodes.c" + #line 2109 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 2964 "Python/generated_cases.c.h" + #line 2999 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2970,10 +3005,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2086 "Python/bytecodes.c" + #line 2115 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 2977 "Python/generated_cases.c.h" + #line 3012 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -2984,11 +3019,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2092 "Python/bytecodes.c" + #line 2121 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 2992 "Python/generated_cases.c.h" + #line 3027 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -2997,14 +3032,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2098 "Python/bytecodes.c" + #line 2127 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3004 "Python/generated_cases.c.h" + #line 3039 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2101 "Python/bytecodes.c" + #line 2130 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3008 "Python/generated_cases.c.h" + #line 3043 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3012,7 +3047,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2105 "Python/bytecodes.c" + #line 2134 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3035,11 +3070,11 @@ if (iter == NULL) { goto error; } - #line 3039 "Python/generated_cases.c.h" + #line 3074 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2128 "Python/bytecodes.c" + #line 2157 "Python/bytecodes.c" } - #line 3043 "Python/generated_cases.c.h" + #line 3078 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3050,7 +3085,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2147 "Python/bytecodes.c" + #line 2176 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3081,7 +3116,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3085 "Python/generated_cases.c.h" + #line 3120 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3089,7 +3124,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2180 "Python/bytecodes.c" + #line 2209 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3115,14 +3150,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3119 "Python/generated_cases.c.h" + #line 3154 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2208 "Python/bytecodes.c" + #line 2237 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3142,7 +3177,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3146 "Python/generated_cases.c.h" + #line 3181 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3152,7 +3187,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2230 "Python/bytecodes.c" + #line 2259 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3172,7 +3207,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3176 "Python/generated_cases.c.h" + #line 3211 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3182,7 +3217,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2252 "Python/bytecodes.c" + #line 2281 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3200,7 +3235,7 @@ if (next == NULL) { goto error; } - #line 3204 "Python/generated_cases.c.h" + #line 3239 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3209,7 +3244,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2272 "Python/bytecodes.c" + #line 2301 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3224,14 +3259,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3228 "Python/generated_cases.c.h" + #line 3263 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2289 "Python/bytecodes.c" + #line 2318 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3254,16 +3289,16 @@ Py_DECREF(enter); goto error; } - #line 3258 "Python/generated_cases.c.h" + #line 3293 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2312 "Python/bytecodes.c" + #line 2341 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3267 "Python/generated_cases.c.h" + #line 3302 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3275,7 +3310,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2322 "Python/bytecodes.c" + #line 2351 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3301,16 +3336,16 @@ Py_DECREF(enter); goto error; } - #line 3305 "Python/generated_cases.c.h" + #line 3340 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2348 "Python/bytecodes.c" + #line 2377 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3314 "Python/generated_cases.c.h" + #line 3349 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3322,7 +3357,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2357 "Python/bytecodes.c" + #line 2386 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3343,7 +3378,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3347 "Python/generated_cases.c.h" + #line 3382 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3352,7 +3387,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2380 "Python/bytecodes.c" + #line 2409 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3362,7 +3397,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3366 "Python/generated_cases.c.h" + #line 3401 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3376,7 +3411,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2392 "Python/bytecodes.c" + #line 2421 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3393,7 +3428,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3397 "Python/generated_cases.c.h" + #line 3432 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3407,7 +3442,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2411 "Python/bytecodes.c" + #line 2440 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3417,7 +3452,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3421 "Python/generated_cases.c.h" + #line 3456 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3431,7 +3466,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2423 "Python/bytecodes.c" + #line 2452 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3445,7 +3480,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3449 "Python/generated_cases.c.h" + #line 3484 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3454,16 +3489,16 @@ } TARGET(KW_NAMES) { - #line 2439 "Python/bytecodes.c" + #line 2468 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3462 "Python/generated_cases.c.h" + #line 3497 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2445 "Python/bytecodes.c" + #line 2474 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3476,7 +3511,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3480 "Python/generated_cases.c.h" + #line 3515 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3486,7 +3521,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2490 "Python/bytecodes.c" + #line 2519 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3568,7 +3603,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3572 "Python/generated_cases.c.h" + #line 3607 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3580,7 +3615,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2578 "Python/bytecodes.c" + #line 2607 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3590,7 +3625,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3594 "Python/generated_cases.c.h" + #line 3629 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3599,7 +3634,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2590 "Python/bytecodes.c" + #line 2619 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3625,7 +3660,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3629 "Python/generated_cases.c.h" + #line 3664 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3633,7 +3668,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2618 "Python/bytecodes.c" + #line 2647 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3669,7 +3704,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3673 "Python/generated_cases.c.h" + #line 3708 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3677,7 +3712,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2656 "Python/bytecodes.c" + #line 2685 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3687,7 +3722,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3691 "Python/generated_cases.c.h" + #line 3726 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3700,7 +3735,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2668 "Python/bytecodes.c" + #line 2697 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3711,7 +3746,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3715 "Python/generated_cases.c.h" + #line 3750 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3725,7 +3760,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2682 "Python/bytecodes.c" + #line 2711 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3736,7 +3771,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3740 "Python/generated_cases.c.h" + #line 3775 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3750,7 +3785,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2696 "Python/bytecodes.c" + #line 2725 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3772,7 +3807,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3776 "Python/generated_cases.c.h" + #line 3811 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3786,7 +3821,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2721 "Python/bytecodes.c" + #line 2750 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3814,7 +3849,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3818 "Python/generated_cases.c.h" + #line 3853 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3828,7 +3863,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2752 "Python/bytecodes.c" + #line 2781 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3860,7 +3895,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 3864 "Python/generated_cases.c.h" + #line 3899 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3874,7 +3909,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2787 "Python/bytecodes.c" + #line 2816 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -3906,7 +3941,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3910 "Python/generated_cases.c.h" + #line 3945 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3920,7 +3955,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2822 "Python/bytecodes.c" + #line 2851 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -3945,7 +3980,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3949 "Python/generated_cases.c.h" + #line 3984 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3958,7 +3993,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2849 "Python/bytecodes.c" + #line 2878 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -3985,7 +4020,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3989 "Python/generated_cases.c.h" + #line 4024 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3997,7 +4032,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2879 "Python/bytecodes.c" + #line 2908 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4015,14 +4050,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4019 "Python/generated_cases.c.h" + #line 4054 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2899 "Python/bytecodes.c" + #line 2928 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4053,7 +4088,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4057 "Python/generated_cases.c.h" + #line 4092 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4066,7 +4101,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2933 "Python/bytecodes.c" + #line 2962 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4095,7 +4130,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4099 "Python/generated_cases.c.h" + #line 4134 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4108,7 +4143,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2965 "Python/bytecodes.c" + #line 2994 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4137,7 +4172,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4141 "Python/generated_cases.c.h" + #line 4176 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4150,7 +4185,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2997 "Python/bytecodes.c" + #line 3026 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4178,7 +4213,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4182 "Python/generated_cases.c.h" + #line 4217 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4188,9 +4223,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3028 "Python/bytecodes.c" + #line 3057 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4194 "Python/generated_cases.c.h" + #line 4229 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4199,7 +4234,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3032 "Python/bytecodes.c" + #line 3061 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4242,14 +4277,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4246 "Python/generated_cases.c.h" + #line 4281 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3075 "Python/bytecodes.c" + #line 3104 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4253 "Python/generated_cases.c.h" + #line 4288 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4259,13 +4294,12 @@ TARGET(MAKE_FUNCTION) { PyObject *codeobj = stack_pointer[-1]; - PyObject *locals = (oparg & 0x20) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0))] : NULL; - PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0))] : NULL; - PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL; - PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; - PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x20) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; + PyObject *closure = (oparg & 0x08) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0))] : NULL; + PyObject *annotations = (oparg & 0x04) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0))] : NULL; + PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; + PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3086 "Python/bytecodes.c" + #line 3114 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4275,10 +4309,6 @@ goto error; } - if (oparg & 0x20) { - assert(PyDict_CheckExact(locals)); - func_obj->func_locals = locals; - } if (oparg & 0x08) { assert(PyTuple_CheckExact(closure)); func_obj->func_closure = closure; @@ -4298,14 +4328,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4302 "Python/generated_cases.c.h" - STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x20) ? 1 : 0)); + #line 4332 "Python/generated_cases.c.h" + STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3121 "Python/bytecodes.c" + #line 3145 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4326,7 +4356,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4330 "Python/generated_cases.c.h" + #line 4360 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4334,15 +4364,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3144 "Python/bytecodes.c" + #line 3168 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4340 "Python/generated_cases.c.h" + #line 4370 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3146 "Python/bytecodes.c" + #line 3170 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4346 "Python/generated_cases.c.h" + #line 4376 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4353,7 +4383,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3150 "Python/bytecodes.c" + #line 3174 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4388,7 +4418,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4392 "Python/generated_cases.c.h" + #line 4422 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4397,10 +4427,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3187 "Python/bytecodes.c" + #line 3211 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4404 "Python/generated_cases.c.h" + #line 4434 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4412,7 +4442,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3192 "Python/bytecodes.c" + #line 3216 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4427,12 +4457,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4431 "Python/generated_cases.c.h" + #line 4461 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3207 "Python/bytecodes.c" + #line 3231 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4436 "Python/generated_cases.c.h" + #line 4466 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4442,16 +4472,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3212 "Python/bytecodes.c" + #line 3236 "Python/bytecodes.c" assert(oparg >= 2); - #line 4448 "Python/generated_cases.c.h" + #line 4478 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3216 "Python/bytecodes.c" + #line 3240 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4471,11 +4501,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4475 "Python/generated_cases.c.h" + #line 4505 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3238 "Python/bytecodes.c" + #line 3262 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4487,26 +4517,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4491 "Python/generated_cases.c.h" + #line 4521 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3252 "Python/bytecodes.c" + #line 3276 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4497 "Python/generated_cases.c.h" + #line 4527 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3256 "Python/bytecodes.c" + #line 3280 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4504 "Python/generated_cases.c.h" + #line 4534 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3261 "Python/bytecodes.c" + #line 3285 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4515,12 +4545,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4519 "Python/generated_cases.c.h" + #line 4549 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3272 "Python/bytecodes.c" + #line 3296 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4529,12 +4559,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4533 "Python/generated_cases.c.h" + #line 4563 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3283 "Python/bytecodes.c" + #line 3307 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4547,12 +4577,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4551 "Python/generated_cases.c.h" + #line 4581 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3298 "Python/bytecodes.c" + #line 3322 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4565,30 +4595,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4569 "Python/generated_cases.c.h" + #line 4599 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3313 "Python/bytecodes.c" + #line 3337 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4580 "Python/generated_cases.c.h" + #line 4610 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3321 "Python/bytecodes.c" + #line 3345 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4587 "Python/generated_cases.c.h" + #line 4617 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3326 "Python/bytecodes.c" + #line 3350 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4594 "Python/generated_cases.c.h" + #line 4624 "Python/generated_cases.c.h" } diff --git a/Python/intrinsics.c b/Python/intrinsics.c index cca29d859902a4..7968445c757e4f 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -221,8 +221,19 @@ prep_reraise_star(PyThreadState* unused, PyObject *orig, PyObject *excs) return _PyExc_PrepReraiseStar(orig, excs); } +static PyObject * +set_class_dict(PyThreadState* unused, PyObject *fn, PyObject *class_dict) +{ + assert(PyFunction_Check(fn)); + assert(PyDict_Check(class_dict)); + PyFunctionObject *func = (PyFunctionObject *)fn; + func->func_class_dict = class_dict; + return (PyObject *)func; +} + const instrinsic_func2 _PyIntrinsics_BinaryFunctions[] = { [INTRINSIC_PREP_RERAISE_STAR] = prep_reraise_star, + [INTRINSIC_SET_CLASS_DICT] = set_class_dict, }; diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 84dc7ac6b15d89..1ececd24cfadbf 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -163,6 +163,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 0; case LOAD_NAME: return 0; + case LOAD_CLASS_DICT: + return 0; case LOAD_GLOBAL: return 0; case LOAD_GLOBAL_MODULE: @@ -348,7 +350,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case CALL_FUNCTION_EX: return ((oparg & 1) ? 1 : 0) + 3; case MAKE_FUNCTION: - return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x20) ? 1 : 0) + 1; + return ((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0) + 1; case RETURN_GENERATOR: return 0; case BUILD_SLICE: @@ -549,6 +551,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case LOAD_NAME: return 1; + case LOAD_CLASS_DICT: + return 1; case LOAD_GLOBAL: return ((oparg & 1) ? 1 : 0) + 1; case LOAD_GLOBAL_MODULE: @@ -862,6 +866,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [STORE_GLOBAL] = { true, INSTR_FMT_IB }, [DELETE_GLOBAL] = { true, INSTR_FMT_IB }, [LOAD_NAME] = { true, INSTR_FMT_IB }, + [LOAD_CLASS_DICT] = { true, INSTR_FMT_IB }, [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 302a74262286a5..441e8766e11ac7 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -174,7 +174,7 @@ static void *opcode_targets[256] = { &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, - &&_unknown_opcode, + &&TARGET_LOAD_CLASS_DICT, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 5e4ec0e617b96286dad82aeabdef9d5ca7fd01a6 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Wed, 26 Apr 2023 16:35:30 -0600 Subject: [PATCH 104/200] Update comment on new magic number. --- Lib/importlib/_bootstrap_external.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index dd1426925f8c07..1f942c08871a80 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -440,7 +440,7 @@ def _write_atomic(path, data, mode=0o666): # Python 3.12a7 3524 (Shrink the BINARY_SUBSCR caches) # Python 3.12b1 3525 (Shrink the CALL caches) # Python 3.12a7 3526 (Add instrumentation support) -# Python 3.12b1 3527 (Add function.__locals__ with change to MAKE_FUNCTION) +# Python 3.12b1 3527 (Add function.__class_dict__, LOAD_CLASS_DICT, SET_CLASS_DICT) # Python 3.13 will start with 3550 From 12d3004fd60edcb388405bf7532604acaa248ae5 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Wed, 26 Apr 2023 16:39:28 -0600 Subject: [PATCH 105/200] Cleanup leftover gunk from previous approach. --- Python/bltinmodule.c | 1 - Python/ceval.c | 14 ++++---------- Python/compile.c | 5 +---- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 08107ea2c7dc64..fcb4d7a9a975c6 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -195,7 +195,6 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, Py_TYPE(ns)->tp_name); goto error; } - PyThreadState *tstate = _PyThreadState_GET(); EVAL_CALL_STAT_INC(EVAL_CALL_BUILD_CLASS); cell = _PyEval_Vector(tstate, (PyFunctionObject *)func, ns, NULL, 0, NULL); diff --git a/Python/ceval.c b/Python/ceval.c index 153e3023a4f2b2..358835024fd2d0 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -537,11 +537,8 @@ PyObject * PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) { PyThreadState *tstate = _PyThreadState_GET(); - PyObject *locals_or_globals; if (locals == NULL) { - locals_or_globals = globals; - } else { - locals_or_globals = locals; + locals = globals; } PyObject *builtins = _PyEval_BuiltinsFromGlobals(tstate, globals); // borrowed ref if (builtins == NULL) { @@ -562,7 +559,7 @@ PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) return NULL; } EVAL_CALL_STAT_INC(EVAL_CALL_LEGACY); - PyObject *res = _PyEval_Vector(tstate, func, locals_or_globals, NULL, 0, NULL); + PyObject *res = _PyEval_Vector(tstate, func, locals, NULL, 0, NULL); Py_DECREF(func); return res; } @@ -1550,11 +1547,8 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, Py_DECREF(defaults); return NULL; } - PyObject *locals_or_globals; if (locals == NULL) { - locals_or_globals = globals; - } else { - locals_or_globals = locals; + locals = globals; } PyObject *kwnames = NULL; PyObject *const *allargs; @@ -1596,7 +1590,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals, goto fail; } EVAL_CALL_STAT_INC(EVAL_CALL_LEGACY); - res = _PyEval_Vector(tstate, func, locals_or_globals, + res = _PyEval_Vector(tstate, func, locals, allargs, argcount, kwnames); fail: diff --git a/Python/compile.c b/Python/compile.c index 00ad8861661f4f..d6882c31d6437e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1753,7 +1753,6 @@ compiler_make_closure(struct compiler *c, location loc, flags |= 0x08; ADDOP_I(c, loc, BUILD_TUPLE, co->co_nfreevars); } - ADDOP_LOAD_CONST(c, loc, (PyObject*)co); ADDOP_I(c, loc, MAKE_FUNCTION, flags); return SUCCESS; @@ -2233,9 +2232,7 @@ compiler_class(struct compiler *c, stmt_ty s) ADDOP(c, loc, LOAD_BUILD_CLASS); /* 3. load a function (or closure) made from the code object */ - Py_ssize_t funcflags = 0x20; /* locals */ - // Py_ssize_t funcflags = 0; - if (compiler_make_closure(c, loc, co, funcflags) < 0) { + if (compiler_make_closure(c, loc, co, 0) < 0) { Py_DECREF(co); return ERROR; } From 6c3f65ad0d7d0e97c3286bb424357fba630456e2 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Wed, 26 Apr 2023 16:52:19 -0600 Subject: [PATCH 106/200] Add class.__globals__, fix refcnt bugs. Thx Jelle! --- Include/internal/pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + Include/internal/pycore_runtime_init_generated.h | 1 + Include/internal/pycore_unicodeobject_generated.h | 3 +++ Objects/typeobject.c | 3 +++ Python/bltinmodule.c | 5 +++++ Python/intrinsics.c | 4 ++-- 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index fdfa80bd7d424a..bc5f034d2488ef 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -631,6 +631,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getnewargs__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getnewargs_ex__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getstate__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__globals__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__gt__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__hash__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__iadd__)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 6f430bb25eb8d3..9eccc174f1d618 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -119,6 +119,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(__getnewargs__) STRUCT_FOR_ID(__getnewargs_ex__) STRUCT_FOR_ID(__getstate__) + STRUCT_FOR_ID(__globals__) STRUCT_FOR_ID(__gt__) STRUCT_FOR_ID(__hash__) STRUCT_FOR_ID(__iadd__) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 0452c4c61551de..a990356789ea61 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -625,6 +625,7 @@ extern "C" { INIT_ID(__getnewargs__), \ INIT_ID(__getnewargs_ex__), \ INIT_ID(__getstate__), \ + INIT_ID(__globals__), \ INIT_ID(__gt__), \ INIT_ID(__hash__), \ INIT_ID(__iadd__), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 7114a5416f2515..e430697dab0908 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -210,6 +210,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(__getstate__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(__globals__); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(__gt__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index d2b77a0aecfc5a..f5ef16ca7f1b15 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3002,6 +3002,9 @@ type_new_set_module(PyTypeObject *type) if (PyDict_SetItem(type->tp_dict, &_Py_ID(__module__), module) < 0) { return -1; } + if (PyDict_SetItem(type->tp_dict, &_Py_ID(__globals__), globals) < 0) { + return -1; + } return 0; } diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index fcb4d7a9a975c6..5544b3b9586459 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -195,6 +195,11 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, Py_TYPE(ns)->tp_name); goto error; } + PyObject *globals = PyEval_GetGlobals(); + if ((globals == NULL) + || (PyMapping_SetItemString(ns, "__globals__", globals) < 0)) { + goto error; + } PyThreadState *tstate = _PyThreadState_GET(); EVAL_CALL_STAT_INC(EVAL_CALL_BUILD_CLASS); cell = _PyEval_Vector(tstate, (PyFunctionObject *)func, ns, NULL, 0, NULL); diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 7968445c757e4f..a1ead02e1df3f3 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -227,8 +227,8 @@ set_class_dict(PyThreadState* unused, PyObject *fn, PyObject *class_dict) assert(PyFunction_Check(fn)); assert(PyDict_Check(class_dict)); PyFunctionObject *func = (PyFunctionObject *)fn; - func->func_class_dict = class_dict; - return (PyObject *)func; + Py_XSETREF(func->func_class_dict, Py_NewRef(class_dict)); + return Py_NewRef(fn); } const instrinsic_func2 From 84a00cef1f3950e7d7be1b240465d63f9132d4ca Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Wed, 26 Apr 2023 16:56:18 -0600 Subject: [PATCH 107/200] LOAD_CLASS_DICT also checks globals. Thx Jelle! --- Python/bytecodes.c | 44 ++- Python/generated_cases.c.h | 602 ++++++++++++++++++++----------------- 2 files changed, 361 insertions(+), 285 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 4649e971b9821c..115660c06cd5d6 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1238,14 +1238,52 @@ dummy_func( if (v != NULL) { Py_INCREF(v); } + else if (_PyErr_Occurred(tstate)) { + goto error; + } } else { v = PyObject_GetItem(class_dict, name); + if (v == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + goto error; + _PyErr_Clear(tstate); + } } - if (_PyErr_Occurred(tstate)) { - goto error; + if (v == NULL) { + v = PyDict_GetItemWithError(GLOBALS(), name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + else { + if (PyDict_CheckExact(BUILTINS())) { + v = PyDict_GetItemWithError(BUILTINS(), name); + if (v == NULL) { + if (!_PyErr_Occurred(tstate)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + Py_INCREF(v); + } + else { + v = PyObject_GetItem(BUILTINS(), name); + if (v == NULL) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + } + } } - assert(v != NULL); } family(load_global, INLINE_CACHE_ENTRIES_LOAD_GLOBAL) = { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 284ff06a9a90f8..854b4b5a9be8ed 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1700,15 +1700,53 @@ if (v != NULL) { Py_INCREF(v); } + else if (_PyErr_Occurred(tstate)) { + goto error; + } } else { v = PyObject_GetItem(class_dict, name); + if (v == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + goto error; + _PyErr_Clear(tstate); + } } - if (_PyErr_Occurred(tstate)) { - goto error; + if (v == NULL) { + v = PyDict_GetItemWithError(GLOBALS(), name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + else { + if (PyDict_CheckExact(BUILTINS())) { + v = PyDict_GetItemWithError(BUILTINS(), name); + if (v == NULL) { + if (!_PyErr_Occurred(tstate)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + Py_INCREF(v); + } + else { + v = PyObject_GetItem(BUILTINS(), name); + if (v == NULL) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; + } + } + } } - assert(v != NULL); - #line 1712 "Python/generated_cases.c.h" + #line 1750 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = v; DISPATCH(); @@ -1719,7 +1757,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1258 "Python/bytecodes.c" + #line 1296 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1771,7 +1809,7 @@ } } null = NULL; - #line 1775 "Python/generated_cases.c.h" + #line 1813 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1785,7 +1823,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1312 "Python/bytecodes.c" + #line 1350 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1796,7 +1834,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1800 "Python/generated_cases.c.h" + #line 1838 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1811,7 +1849,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1325 "Python/bytecodes.c" + #line 1363 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1826,7 +1864,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1830 "Python/generated_cases.c.h" + #line 1868 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1836,16 +1874,16 @@ } TARGET(DELETE_FAST) { - #line 1342 "Python/bytecodes.c" + #line 1380 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1844 "Python/generated_cases.c.h" + #line 1882 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1348 "Python/bytecodes.c" + #line 1386 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1854,12 +1892,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1858 "Python/generated_cases.c.h" + #line 1896 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1359 "Python/bytecodes.c" + #line 1397 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1870,13 +1908,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1874 "Python/generated_cases.c.h" + #line 1912 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1372 "Python/bytecodes.c" + #line 1410 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1908,7 +1946,7 @@ } Py_INCREF(value); } - #line 1912 "Python/generated_cases.c.h" + #line 1950 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1916,7 +1954,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1406 "Python/bytecodes.c" + #line 1444 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1924,7 +1962,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1928 "Python/generated_cases.c.h" + #line 1966 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1932,18 +1970,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1416 "Python/bytecodes.c" + #line 1454 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 1941 "Python/generated_cases.c.h" + #line 1979 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1423 "Python/bytecodes.c" + #line 1461 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1954,22 +1992,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 1958 "Python/generated_cases.c.h" + #line 1996 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1436 "Python/bytecodes.c" + #line 1474 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 1967 "Python/generated_cases.c.h" + #line 2005 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1438 "Python/bytecodes.c" + #line 1476 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1973 "Python/generated_cases.c.h" + #line 2011 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -1979,10 +2017,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1442 "Python/bytecodes.c" + #line 1480 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1986 "Python/generated_cases.c.h" + #line 2024 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -1992,10 +2030,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1447 "Python/bytecodes.c" + #line 1485 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 1999 "Python/generated_cases.c.h" + #line 2037 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2005,7 +2043,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1452 "Python/bytecodes.c" + #line 1490 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2016,13 +2054,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2020 "Python/generated_cases.c.h" + #line 2058 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1463 "Python/bytecodes.c" + #line 1501 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2026 "Python/generated_cases.c.h" + #line 2064 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2031,13 +2069,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1470 "Python/bytecodes.c" + #line 1508 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2037 "Python/generated_cases.c.h" + #line 2075 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1472 "Python/bytecodes.c" + #line 1510 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2041 "Python/generated_cases.c.h" + #line 2079 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2045,7 +2083,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1476 "Python/bytecodes.c" + #line 1514 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2060,7 +2098,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2064 "Python/generated_cases.c.h" + #line 2102 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2070,7 +2108,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1493 "Python/bytecodes.c" + #line 1531 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2078,13 +2116,13 @@ if (map == NULL) goto error; - #line 2082 "Python/generated_cases.c.h" + #line 2120 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1501 "Python/bytecodes.c" + #line 1539 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2088 "Python/generated_cases.c.h" + #line 2126 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2092,7 +2130,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1505 "Python/bytecodes.c" + #line 1543 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2132,7 +2170,7 @@ Py_DECREF(ann_dict); } } - #line 2136 "Python/generated_cases.c.h" + #line 2174 "Python/generated_cases.c.h" DISPATCH(); } @@ -2140,7 +2178,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1547 "Python/bytecodes.c" + #line 1585 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2150,14 +2188,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2154 "Python/generated_cases.c.h" + #line 2192 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1557 "Python/bytecodes.c" + #line 1595 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2161 "Python/generated_cases.c.h" + #line 2199 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2165,7 +2203,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1561 "Python/bytecodes.c" + #line 1599 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2173,12 +2211,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2177 "Python/generated_cases.c.h" + #line 2215 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1569 "Python/bytecodes.c" + #line 1607 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2182 "Python/generated_cases.c.h" + #line 2220 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2186,17 +2224,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1575 "Python/bytecodes.c" + #line 1613 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2195 "Python/generated_cases.c.h" + #line 2233 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1580 "Python/bytecodes.c" + #line 1618 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2200 "Python/generated_cases.c.h" + #line 2238 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2206,13 +2244,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1587 "Python/bytecodes.c" + #line 1625 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2216 "Python/generated_cases.c.h" + #line 2254 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2224,7 +2262,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1610 "Python/bytecodes.c" + #line 1648 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2258,9 +2296,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2262 "Python/generated_cases.c.h" + #line 2300 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1644 "Python/bytecodes.c" + #line 1682 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2269,12 +2307,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2273 "Python/generated_cases.c.h" + #line 2311 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1653 "Python/bytecodes.c" + #line 1691 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2278 "Python/generated_cases.c.h" + #line 2316 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2288,7 +2326,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1658 "Python/bytecodes.c" + #line 1696 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2301,7 +2339,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2305 "Python/generated_cases.c.h" + #line 2343 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2316,7 +2354,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1674 "Python/bytecodes.c" + #line 1712 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2329,7 +2367,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2333 "Python/generated_cases.c.h" + #line 2371 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2344,7 +2382,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1690 "Python/bytecodes.c" + #line 1728 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2371,7 +2409,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2375 "Python/generated_cases.c.h" + #line 2413 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2386,7 +2424,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1720 "Python/bytecodes.c" + #line 1758 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2396,7 +2434,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2400 "Python/generated_cases.c.h" + #line 2438 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2411,7 +2449,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1733 "Python/bytecodes.c" + #line 1771 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2423,7 +2461,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2427 "Python/generated_cases.c.h" + #line 2465 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2437,7 +2475,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1748 "Python/bytecodes.c" + #line 1786 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2461,7 +2499,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2465 "Python/generated_cases.c.h" + #line 2503 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2469,7 +2507,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1774 "Python/bytecodes.c" + #line 1812 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2495,7 +2533,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2499 "Python/generated_cases.c.h" + #line 2537 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2503,7 +2541,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1802 "Python/bytecodes.c" + #line 1840 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2521,7 +2559,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2525 "Python/generated_cases.c.h" + #line 2563 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2532,7 +2570,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1822 "Python/bytecodes.c" + #line 1860 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2571,7 +2609,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2575 "Python/generated_cases.c.h" + #line 2613 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2582,7 +2620,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1863 "Python/bytecodes.c" + #line 1901 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2592,7 +2630,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2596 "Python/generated_cases.c.h" + #line 2634 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2604,7 +2642,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1882 "Python/bytecodes.c" + #line 1920 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2617,12 +2655,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2621 "Python/generated_cases.c.h" + #line 2659 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1895 "Python/bytecodes.c" + #line 1933 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2626 "Python/generated_cases.c.h" + #line 2664 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2633,7 +2671,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1899 "Python/bytecodes.c" + #line 1937 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2645,7 +2683,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2649 "Python/generated_cases.c.h" + #line 2687 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2656,7 +2694,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1914 "Python/bytecodes.c" + #line 1952 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2672,7 +2710,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2676 "Python/generated_cases.c.h" + #line 2714 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2683,7 +2721,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1933 "Python/bytecodes.c" + #line 1971 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2696,7 +2734,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2700 "Python/generated_cases.c.h" + #line 2738 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2707,14 +2745,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1948 "Python/bytecodes.c" + #line 1986 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2713 "Python/generated_cases.c.h" + #line 2751 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1950 "Python/bytecodes.c" + #line 1988 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2718 "Python/generated_cases.c.h" + #line 2756 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2724,15 +2762,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1954 "Python/bytecodes.c" + #line 1992 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2730 "Python/generated_cases.c.h" + #line 2768 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1956 "Python/bytecodes.c" + #line 1994 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2736 "Python/generated_cases.c.h" + #line 2774 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2743,12 +2781,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 1961 "Python/bytecodes.c" + #line 1999 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2749 "Python/generated_cases.c.h" + #line 2787 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1963 "Python/bytecodes.c" + #line 2001 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2756,10 +2794,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2760 "Python/generated_cases.c.h" + #line 2798 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 1971 "Python/bytecodes.c" + #line 2009 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2768,7 +2806,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2772 "Python/generated_cases.c.h" + #line 2810 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2778,21 +2816,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1982 "Python/bytecodes.c" + #line 2020 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2785 "Python/generated_cases.c.h" + #line 2823 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1985 "Python/bytecodes.c" + #line 2023 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2792 "Python/generated_cases.c.h" + #line 2830 "Python/generated_cases.c.h" Py_DECREF(right); - #line 1990 "Python/bytecodes.c" + #line 2028 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2796 "Python/generated_cases.c.h" + #line 2834 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2801,15 +2839,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 1994 "Python/bytecodes.c" + #line 2032 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2808 "Python/generated_cases.c.h" + #line 2846 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 1997 "Python/bytecodes.c" + #line 2035 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2813 "Python/generated_cases.c.h" + #line 2851 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2818,29 +2856,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2001 "Python/bytecodes.c" + #line 2039 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2826 "Python/generated_cases.c.h" + #line 2864 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2007 "Python/bytecodes.c" + #line 2045 "Python/bytecodes.c" JUMPBY(oparg); - #line 2835 "Python/generated_cases.c.h" + #line 2873 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2011 "Python/bytecodes.c" + #line 2049 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2844 "Python/generated_cases.c.h" + #line 2882 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2848,7 +2886,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2017 "Python/bytecodes.c" + #line 2055 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2858,9 +2896,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2862 "Python/generated_cases.c.h" + #line 2900 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2027 "Python/bytecodes.c" + #line 2065 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2868,14 +2906,14 @@ if (err < 0) goto pop_1_error; } } - #line 2872 "Python/generated_cases.c.h" + #line 2910 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2037 "Python/bytecodes.c" + #line 2075 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2885,9 +2923,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2889 "Python/generated_cases.c.h" + #line 2927 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2047 "Python/bytecodes.c" + #line 2085 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2895,67 +2933,67 @@ if (err < 0) goto pop_1_error; } } - #line 2899 "Python/generated_cases.c.h" + #line 2937 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2057 "Python/bytecodes.c" + #line 2095 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 2908 "Python/generated_cases.c.h" + #line 2946 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2059 "Python/bytecodes.c" + #line 2097 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 2916 "Python/generated_cases.c.h" + #line 2954 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2067 "Python/bytecodes.c" + #line 2105 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 2929 "Python/generated_cases.c.h" + #line 2967 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2073 "Python/bytecodes.c" + #line 2111 "Python/bytecodes.c" } - #line 2933 "Python/generated_cases.c.h" + #line 2971 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2077 "Python/bytecodes.c" + #line 2115 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 2946 "Python/generated_cases.c.h" + #line 2984 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2086 "Python/bytecodes.c" + #line 2124 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 2959 "Python/generated_cases.c.h" + #line 2997 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -2966,16 +3004,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2094 "Python/bytecodes.c" + #line 2132 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 2975 "Python/generated_cases.c.h" + #line 3013 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2099 "Python/bytecodes.c" + #line 2137 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -2983,7 +3021,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 2987 "Python/generated_cases.c.h" + #line 3025 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -2992,10 +3030,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2109 "Python/bytecodes.c" + #line 2147 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 2999 "Python/generated_cases.c.h" + #line 3037 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3005,10 +3043,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2115 "Python/bytecodes.c" + #line 2153 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3012 "Python/generated_cases.c.h" + #line 3050 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3019,11 +3057,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2121 "Python/bytecodes.c" + #line 2159 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3027 "Python/generated_cases.c.h" + #line 3065 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3032,14 +3070,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2127 "Python/bytecodes.c" + #line 2165 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3039 "Python/generated_cases.c.h" + #line 3077 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2130 "Python/bytecodes.c" + #line 2168 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3043 "Python/generated_cases.c.h" + #line 3081 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3047,7 +3085,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2134 "Python/bytecodes.c" + #line 2172 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3070,11 +3108,11 @@ if (iter == NULL) { goto error; } - #line 3074 "Python/generated_cases.c.h" + #line 3112 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2157 "Python/bytecodes.c" + #line 2195 "Python/bytecodes.c" } - #line 3078 "Python/generated_cases.c.h" + #line 3116 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3085,7 +3123,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2176 "Python/bytecodes.c" + #line 2214 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3116,7 +3154,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3120 "Python/generated_cases.c.h" + #line 3158 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3124,7 +3162,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2209 "Python/bytecodes.c" + #line 2247 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3150,14 +3188,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3154 "Python/generated_cases.c.h" + #line 3192 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2237 "Python/bytecodes.c" + #line 2275 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3177,7 +3215,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3181 "Python/generated_cases.c.h" + #line 3219 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3187,7 +3225,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2259 "Python/bytecodes.c" + #line 2297 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3207,7 +3245,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3211 "Python/generated_cases.c.h" + #line 3249 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3217,7 +3255,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2281 "Python/bytecodes.c" + #line 2319 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3235,7 +3273,7 @@ if (next == NULL) { goto error; } - #line 3239 "Python/generated_cases.c.h" + #line 3277 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3244,7 +3282,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2301 "Python/bytecodes.c" + #line 2339 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3259,14 +3297,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3263 "Python/generated_cases.c.h" + #line 3301 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2318 "Python/bytecodes.c" + #line 2356 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3289,16 +3327,16 @@ Py_DECREF(enter); goto error; } - #line 3293 "Python/generated_cases.c.h" + #line 3331 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2341 "Python/bytecodes.c" + #line 2379 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3302 "Python/generated_cases.c.h" + #line 3340 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3310,7 +3348,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2351 "Python/bytecodes.c" + #line 2389 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3336,16 +3374,16 @@ Py_DECREF(enter); goto error; } - #line 3340 "Python/generated_cases.c.h" + #line 3378 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2377 "Python/bytecodes.c" + #line 2415 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3349 "Python/generated_cases.c.h" + #line 3387 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3357,7 +3395,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2386 "Python/bytecodes.c" + #line 2424 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3378,7 +3416,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3382 "Python/generated_cases.c.h" + #line 3420 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3387,7 +3425,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2409 "Python/bytecodes.c" + #line 2447 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3397,7 +3435,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3401 "Python/generated_cases.c.h" + #line 3439 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3411,7 +3449,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2421 "Python/bytecodes.c" + #line 2459 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3428,7 +3466,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3432 "Python/generated_cases.c.h" + #line 3470 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3442,7 +3480,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2440 "Python/bytecodes.c" + #line 2478 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3452,7 +3490,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3456 "Python/generated_cases.c.h" + #line 3494 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3466,7 +3504,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2452 "Python/bytecodes.c" + #line 2490 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3480,7 +3518,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3484 "Python/generated_cases.c.h" + #line 3522 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3489,16 +3527,16 @@ } TARGET(KW_NAMES) { - #line 2468 "Python/bytecodes.c" + #line 2506 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3497 "Python/generated_cases.c.h" + #line 3535 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2474 "Python/bytecodes.c" + #line 2512 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3511,7 +3549,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3515 "Python/generated_cases.c.h" + #line 3553 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3521,7 +3559,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2519 "Python/bytecodes.c" + #line 2557 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3603,7 +3641,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3607 "Python/generated_cases.c.h" + #line 3645 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3615,7 +3653,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2607 "Python/bytecodes.c" + #line 2645 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3625,7 +3663,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3629 "Python/generated_cases.c.h" + #line 3667 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3634,7 +3672,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2619 "Python/bytecodes.c" + #line 2657 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3660,7 +3698,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3664 "Python/generated_cases.c.h" + #line 3702 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3668,7 +3706,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2647 "Python/bytecodes.c" + #line 2685 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3704,7 +3742,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3708 "Python/generated_cases.c.h" + #line 3746 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3712,7 +3750,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2685 "Python/bytecodes.c" + #line 2723 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3722,7 +3760,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3726 "Python/generated_cases.c.h" + #line 3764 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3735,7 +3773,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2697 "Python/bytecodes.c" + #line 2735 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3746,7 +3784,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3750 "Python/generated_cases.c.h" + #line 3788 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3760,7 +3798,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2711 "Python/bytecodes.c" + #line 2749 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3771,7 +3809,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3775 "Python/generated_cases.c.h" + #line 3813 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3785,7 +3823,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2725 "Python/bytecodes.c" + #line 2763 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3807,7 +3845,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3811 "Python/generated_cases.c.h" + #line 3849 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3821,7 +3859,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2750 "Python/bytecodes.c" + #line 2788 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3849,7 +3887,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3853 "Python/generated_cases.c.h" + #line 3891 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3863,7 +3901,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2781 "Python/bytecodes.c" + #line 2819 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3895,7 +3933,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 3899 "Python/generated_cases.c.h" + #line 3937 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3909,7 +3947,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2816 "Python/bytecodes.c" + #line 2854 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -3941,7 +3979,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3945 "Python/generated_cases.c.h" + #line 3983 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3955,7 +3993,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2851 "Python/bytecodes.c" + #line 2889 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -3980,7 +4018,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3984 "Python/generated_cases.c.h" + #line 4022 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3993,7 +4031,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2878 "Python/bytecodes.c" + #line 2916 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4020,7 +4058,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4024 "Python/generated_cases.c.h" + #line 4062 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4032,7 +4070,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2908 "Python/bytecodes.c" + #line 2946 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4050,14 +4088,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4054 "Python/generated_cases.c.h" + #line 4092 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2928 "Python/bytecodes.c" + #line 2966 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4088,7 +4126,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4092 "Python/generated_cases.c.h" + #line 4130 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4101,7 +4139,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2962 "Python/bytecodes.c" + #line 3000 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4130,7 +4168,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4134 "Python/generated_cases.c.h" + #line 4172 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4143,7 +4181,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2994 "Python/bytecodes.c" + #line 3032 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4172,7 +4210,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4176 "Python/generated_cases.c.h" + #line 4214 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4185,7 +4223,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3026 "Python/bytecodes.c" + #line 3064 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4213,7 +4251,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4217 "Python/generated_cases.c.h" + #line 4255 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4223,9 +4261,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3057 "Python/bytecodes.c" + #line 3095 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4229 "Python/generated_cases.c.h" + #line 4267 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4234,7 +4272,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3061 "Python/bytecodes.c" + #line 3099 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4277,14 +4315,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4281 "Python/generated_cases.c.h" + #line 4319 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3104 "Python/bytecodes.c" + #line 3142 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4288 "Python/generated_cases.c.h" + #line 4326 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4299,7 +4337,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3114 "Python/bytecodes.c" + #line 3152 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4328,14 +4366,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4332 "Python/generated_cases.c.h" + #line 4370 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3145 "Python/bytecodes.c" + #line 3183 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4356,7 +4394,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4360 "Python/generated_cases.c.h" + #line 4398 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4364,15 +4402,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3168 "Python/bytecodes.c" + #line 3206 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4370 "Python/generated_cases.c.h" + #line 4408 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3170 "Python/bytecodes.c" + #line 3208 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4376 "Python/generated_cases.c.h" + #line 4414 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4383,7 +4421,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3174 "Python/bytecodes.c" + #line 3212 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4418,7 +4456,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4422 "Python/generated_cases.c.h" + #line 4460 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4427,10 +4465,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3211 "Python/bytecodes.c" + #line 3249 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4434 "Python/generated_cases.c.h" + #line 4472 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4442,7 +4480,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3216 "Python/bytecodes.c" + #line 3254 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4457,12 +4495,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4461 "Python/generated_cases.c.h" + #line 4499 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3231 "Python/bytecodes.c" + #line 3269 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4466 "Python/generated_cases.c.h" + #line 4504 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4472,16 +4510,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3236 "Python/bytecodes.c" + #line 3274 "Python/bytecodes.c" assert(oparg >= 2); - #line 4478 "Python/generated_cases.c.h" + #line 4516 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3240 "Python/bytecodes.c" + #line 3278 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4501,11 +4539,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4505 "Python/generated_cases.c.h" + #line 4543 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3262 "Python/bytecodes.c" + #line 3300 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4517,26 +4555,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4521 "Python/generated_cases.c.h" + #line 4559 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3276 "Python/bytecodes.c" + #line 3314 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4527 "Python/generated_cases.c.h" + #line 4565 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3280 "Python/bytecodes.c" + #line 3318 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4534 "Python/generated_cases.c.h" + #line 4572 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3285 "Python/bytecodes.c" + #line 3323 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4545,12 +4583,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4549 "Python/generated_cases.c.h" + #line 4587 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3296 "Python/bytecodes.c" + #line 3334 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4559,12 +4597,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4563 "Python/generated_cases.c.h" + #line 4601 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3307 "Python/bytecodes.c" + #line 3345 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4577,12 +4615,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4581 "Python/generated_cases.c.h" + #line 4619 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3322 "Python/bytecodes.c" + #line 3360 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4595,30 +4633,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4599 "Python/generated_cases.c.h" + #line 4637 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3337 "Python/bytecodes.c" + #line 3375 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4610 "Python/generated_cases.c.h" + #line 4648 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3345 "Python/bytecodes.c" + #line 3383 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4617 "Python/generated_cases.c.h" + #line 4655 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3350 "Python/bytecodes.c" + #line 3388 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4624 "Python/generated_cases.c.h" + #line 4662 "Python/generated_cases.c.h" } From e0acb87199187c9ce9a85967b60cf64dfc2e8bab Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 17:48:14 -0600 Subject: [PATCH 108/200] Make LOAD_CLASS_DICT also look in the global namespace and rename it to LOAD_CLASS_OR_GLOBAL --- Include/internal/pycore_opcode.h | 4 +- Include/opcode.h | 2 +- Lib/opcode.py | 2 +- Python/bytecodes.c | 72 +-- Python/generated_cases.c.h | 778 ++++++++++++++++--------------- Python/opcode_metadata.h | 14 +- Python/opcode_targets.h | 2 +- 7 files changed, 430 insertions(+), 444 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index 940596214e9631..1c9c744877582a 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -167,7 +167,7 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, [LOAD_CLASSDEREF] = LOAD_CLASSDEREF, - [LOAD_CLASS_DICT] = LOAD_CLASS_DICT, + [LOAD_CLASS_OR_GLOBAL] = LOAD_CLASS_OR_GLOBAL, [LOAD_CLOSURE] = LOAD_CLOSURE, [LOAD_CONST] = LOAD_CONST, [LOAD_CONST__LOAD_FAST] = LOAD_CONST, @@ -414,7 +414,7 @@ static const char *const _PyOpcode_OpName[263] = { [KW_NAMES] = "KW_NAMES", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", - [LOAD_CLASS_DICT] = "LOAD_CLASS_DICT", + [LOAD_CLASS_OR_GLOBAL] = "LOAD_CLASS_OR_GLOBAL", [176] = "<176>", [177] = "<177>", [178] = "<178>", diff --git a/Include/opcode.h b/Include/opcode.h index d54530574b7b76..e8297ce5b9c399 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -117,7 +117,7 @@ extern "C" { #define KW_NAMES 172 #define CALL_INTRINSIC_1 173 #define CALL_INTRINSIC_2 174 -#define LOAD_CLASS_DICT 175 +#define LOAD_CLASS_OR_GLOBAL 175 #define MIN_INSTRUMENTED_OPCODE 238 #define INSTRUMENTED_POP_JUMP_IF_NONE 238 #define INSTRUMENTED_POP_JUMP_IF_NOT_NONE 239 diff --git a/Lib/opcode.py b/Lib/opcode.py index b1e97ce39fd022..a32e3d135ea921 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -227,7 +227,7 @@ def pseudo_op(name, op, real_ops): def_op('CALL_INTRINSIC_1', 173) def_op('CALL_INTRINSIC_2', 174) -def_op('LOAD_CLASS_DICT', 175) +def_op('LOAD_CLASS_OR_GLOBAL', 175) # Instrumented instructions MIN_INSTRUMENTED_OPCODE = 238 diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 115660c06cd5d6..a15a67d8cbe8d9 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1158,81 +1158,33 @@ dummy_func( } } - inst(LOAD_NAME, ( -- v)) { - PyObject *name = GETITEM(frame->f_code->co_names, oparg); - PyObject *locals = LOCALS(); - if (locals == NULL) { + op(_LOAD_NAME_INTRO, (-- class_dict, name)) { + name = GETITEM(frame->f_code->co_names, oparg); + class_dict = LOCALS(); + if (class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals when loading %R", name); goto error; } - if (PyDict_CheckExact(locals)) { - v = PyDict_GetItemWithError(locals, name); - if (v != NULL) { - Py_INCREF(v); - } - else if (_PyErr_Occurred(tstate)) { - goto error; - } - } - else { - v = PyObject_GetItem(locals, name); - if (v == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) - goto error; - _PyErr_Clear(tstate); - } - } - if (v == NULL) { - v = PyDict_GetItemWithError(GLOBALS(), name); - if (v != NULL) { - Py_INCREF(v); - } - else if (_PyErr_Occurred(tstate)) { - goto error; - } - else { - if (PyDict_CheckExact(BUILTINS())) { - v = PyDict_GetItemWithError(BUILTINS(), name); - if (v == NULL) { - if (!_PyErr_Occurred(tstate)) { - format_exc_check_arg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - } - goto error; - } - Py_INCREF(v); - } - else { - v = PyObject_GetItem(BUILTINS(), name); - if (v == NULL) { - if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { - format_exc_check_arg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - } - goto error; - } - } - } - } } - inst(LOAD_CLASS_DICT, ( -- v)) { - PyObject *name = GETITEM(frame->f_code->co_names, oparg); + op(_LOAD_CLASS_OR_GLOBAL_INTRO, (-- class_dict, name)) { + name = GETITEM(frame->f_code->co_names, oparg); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; if (func == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no function defined when loading %R from class dict", name); goto error; } - PyObject *class_dict = func->func_class_dict; + class_dict = func->func_class_dict; if (class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no class dict set when loading %R", name); goto error; } + } + + op(_LOAD_NAME_COMMON, (class_dict, name -- v)) { if (PyDict_CheckExact(class_dict)) { v = PyDict_GetItemWithError(class_dict, name); if (v != NULL) { @@ -1286,6 +1238,10 @@ dummy_func( } } + macro(LOAD_NAME) = _LOAD_NAME_INTRO + _LOAD_NAME_COMMON; + + macro(LOAD_CLASS_OR_GLOBAL) = _LOAD_CLASS_OR_GLOBAL_INTRO + _LOAD_NAME_COMMON; + family(load_global, INLINE_CACHE_ENTRIES_LOAD_GLOBAL) = { LOAD_GLOBAL, LOAD_GLOBAL_MODULE, diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 854b4b5a9be8ed..b5dd626889bedb 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1613,142 +1613,172 @@ } TARGET(LOAD_NAME) { - PyObject *v; - #line 1162 "Python/bytecodes.c" - PyObject *name = GETITEM(frame->f_code->co_names, oparg); - PyObject *locals = LOCALS(); - if (locals == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no locals when loading %R", name); - goto error; - } - if (PyDict_CheckExact(locals)) { - v = PyDict_GetItemWithError(locals, name); - if (v != NULL) { - Py_INCREF(v); - } - else if (_PyErr_Occurred(tstate)) { + PyObject *_tmp_1; + PyObject *_tmp_2; + { + PyObject *class_dict; + PyObject *name; + #line 1162 "Python/bytecodes.c" + name = GETITEM(frame->f_code->co_names, oparg); + class_dict = LOCALS(); + if (class_dict == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no locals when loading %R", name); goto error; } + #line 1630 "Python/generated_cases.c.h" + _tmp_2 = class_dict; + _tmp_1 = name; } - else { - v = PyObject_GetItem(locals, name); - if (v == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + { + PyObject *name = _tmp_1; + PyObject *class_dict = _tmp_2; + PyObject *v; + #line 1188 "Python/bytecodes.c" + if (PyDict_CheckExact(class_dict)) { + v = PyDict_GetItemWithError(class_dict, name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { goto error; - _PyErr_Clear(tstate); - } - } - if (v == NULL) { - v = PyDict_GetItemWithError(GLOBALS(), name); - if (v != NULL) { - Py_INCREF(v); - } - else if (_PyErr_Occurred(tstate)) { - goto error; + } } else { - if (PyDict_CheckExact(BUILTINS())) { - v = PyDict_GetItemWithError(BUILTINS(), name); - if (v == NULL) { - if (!_PyErr_Occurred(tstate)) { - format_exc_check_arg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - } + v = PyObject_GetItem(class_dict, name); + if (v == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; - } + _PyErr_Clear(tstate); + } + } + if (v == NULL) { + v = PyDict_GetItemWithError(GLOBALS(), name); + if (v != NULL) { Py_INCREF(v); } + else if (_PyErr_Occurred(tstate)) { + goto error; + } else { - v = PyObject_GetItem(BUILTINS(), name); - if (v == NULL) { - if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { - format_exc_check_arg( + if (PyDict_CheckExact(BUILTINS())) { + v = PyDict_GetItemWithError(BUILTINS(), name); + if (v == NULL) { + if (!_PyErr_Occurred(tstate)) { + format_exc_check_arg( tstate, PyExc_NameError, NAME_ERROR_MSG, name); + } + goto error; + } + Py_INCREF(v); + } + else { + v = PyObject_GetItem(BUILTINS(), name); + if (v == NULL) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; } - goto error; } } } + #line 1690 "Python/generated_cases.c.h" + _tmp_2 = v; } - #line 1677 "Python/generated_cases.c.h" STACK_GROW(1); - stack_pointer[-1] = v; + stack_pointer[-1] = _tmp_2; DISPATCH(); } - TARGET(LOAD_CLASS_DICT) { - PyObject *v; - #line 1223 "Python/bytecodes.c" - PyObject *name = GETITEM(frame->f_code->co_names, oparg); - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no function defined when loading %R from class dict", name); - goto error; - } - PyObject *class_dict = func->func_class_dict; - if (class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no class dict set when loading %R", name); - goto error; - } - if (PyDict_CheckExact(class_dict)) { - v = PyDict_GetItemWithError(class_dict, name); - if (v != NULL) { - Py_INCREF(v); + TARGET(LOAD_CLASS_OR_GLOBAL) { + PyObject *_tmp_1; + PyObject *_tmp_2; + { + PyObject *class_dict; + PyObject *name; + #line 1172 "Python/bytecodes.c" + name = GETITEM(frame->f_code->co_names, oparg); + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no function defined when loading %R from class dict", name); + goto error; } - else if (_PyErr_Occurred(tstate)) { + class_dict = func->func_class_dict; + if (class_dict == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no class dict set when loading %R", name); goto error; } + #line 1718 "Python/generated_cases.c.h" + _tmp_2 = class_dict; + _tmp_1 = name; } - else { - v = PyObject_GetItem(class_dict, name); - if (v == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + { + PyObject *name = _tmp_1; + PyObject *class_dict = _tmp_2; + PyObject *v; + #line 1188 "Python/bytecodes.c" + if (PyDict_CheckExact(class_dict)) { + v = PyDict_GetItemWithError(class_dict, name); + if (v != NULL) { + Py_INCREF(v); + } + else if (_PyErr_Occurred(tstate)) { goto error; - _PyErr_Clear(tstate); - } - } - if (v == NULL) { - v = PyDict_GetItemWithError(GLOBALS(), name); - if (v != NULL) { - Py_INCREF(v); - } - else if (_PyErr_Occurred(tstate)) { - goto error; + } } else { - if (PyDict_CheckExact(BUILTINS())) { - v = PyDict_GetItemWithError(BUILTINS(), name); - if (v == NULL) { - if (!_PyErr_Occurred(tstate)) { - format_exc_check_arg( - tstate, PyExc_NameError, - NAME_ERROR_MSG, name); - } + v = PyObject_GetItem(class_dict, name); + if (v == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; - } + _PyErr_Clear(tstate); + } + } + if (v == NULL) { + v = PyDict_GetItemWithError(GLOBALS(), name); + if (v != NULL) { Py_INCREF(v); } + else if (_PyErr_Occurred(tstate)) { + goto error; + } else { - v = PyObject_GetItem(BUILTINS(), name); - if (v == NULL) { - if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { - format_exc_check_arg( + if (PyDict_CheckExact(BUILTINS())) { + v = PyDict_GetItemWithError(BUILTINS(), name); + if (v == NULL) { + if (!_PyErr_Occurred(tstate)) { + format_exc_check_arg( tstate, PyExc_NameError, NAME_ERROR_MSG, name); + } + goto error; + } + Py_INCREF(v); + } + else { + v = PyObject_GetItem(BUILTINS(), name); + if (v == NULL) { + if (_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + format_exc_check_arg( + tstate, PyExc_NameError, + NAME_ERROR_MSG, name); + } + goto error; } - goto error; } } } + #line 1778 "Python/generated_cases.c.h" + _tmp_2 = v; } - #line 1750 "Python/generated_cases.c.h" STACK_GROW(1); - stack_pointer[-1] = v; + stack_pointer[-1] = _tmp_2; DISPATCH(); } @@ -1757,7 +1787,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1296 "Python/bytecodes.c" + #line 1252 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1809,7 +1839,7 @@ } } null = NULL; - #line 1813 "Python/generated_cases.c.h" + #line 1843 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1823,7 +1853,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1350 "Python/bytecodes.c" + #line 1306 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1834,7 +1864,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1838 "Python/generated_cases.c.h" + #line 1868 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1849,7 +1879,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1363 "Python/bytecodes.c" + #line 1319 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1864,7 +1894,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1868 "Python/generated_cases.c.h" + #line 1898 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1874,16 +1904,16 @@ } TARGET(DELETE_FAST) { - #line 1380 "Python/bytecodes.c" + #line 1336 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1882 "Python/generated_cases.c.h" + #line 1912 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1386 "Python/bytecodes.c" + #line 1342 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1892,12 +1922,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1896 "Python/generated_cases.c.h" + #line 1926 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1397 "Python/bytecodes.c" + #line 1353 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1908,13 +1938,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1912 "Python/generated_cases.c.h" + #line 1942 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1410 "Python/bytecodes.c" + #line 1366 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1946,7 +1976,7 @@ } Py_INCREF(value); } - #line 1950 "Python/generated_cases.c.h" + #line 1980 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1954,7 +1984,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1444 "Python/bytecodes.c" + #line 1400 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1962,7 +1992,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1966 "Python/generated_cases.c.h" + #line 1996 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1970,18 +2000,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1454 "Python/bytecodes.c" + #line 1410 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 1979 "Python/generated_cases.c.h" + #line 2009 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1461 "Python/bytecodes.c" + #line 1417 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -1992,22 +2022,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 1996 "Python/generated_cases.c.h" + #line 2026 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1474 "Python/bytecodes.c" + #line 1430 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2005 "Python/generated_cases.c.h" + #line 2035 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1476 "Python/bytecodes.c" + #line 1432 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2011 "Python/generated_cases.c.h" + #line 2041 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2017,10 +2047,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1480 "Python/bytecodes.c" + #line 1436 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2024 "Python/generated_cases.c.h" + #line 2054 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2030,10 +2060,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1485 "Python/bytecodes.c" + #line 1441 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2037 "Python/generated_cases.c.h" + #line 2067 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2043,7 +2073,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1490 "Python/bytecodes.c" + #line 1446 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2054,13 +2084,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2058 "Python/generated_cases.c.h" + #line 2088 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1501 "Python/bytecodes.c" + #line 1457 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2064 "Python/generated_cases.c.h" + #line 2094 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2069,13 +2099,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1508 "Python/bytecodes.c" + #line 1464 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2075 "Python/generated_cases.c.h" + #line 2105 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1510 "Python/bytecodes.c" + #line 1466 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2079 "Python/generated_cases.c.h" + #line 2109 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2083,7 +2113,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1514 "Python/bytecodes.c" + #line 1470 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2098,7 +2128,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2102 "Python/generated_cases.c.h" + #line 2132 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2108,7 +2138,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1531 "Python/bytecodes.c" + #line 1487 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2116,13 +2146,13 @@ if (map == NULL) goto error; - #line 2120 "Python/generated_cases.c.h" + #line 2150 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1539 "Python/bytecodes.c" + #line 1495 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2126 "Python/generated_cases.c.h" + #line 2156 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2130,7 +2160,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1543 "Python/bytecodes.c" + #line 1499 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2170,7 +2200,7 @@ Py_DECREF(ann_dict); } } - #line 2174 "Python/generated_cases.c.h" + #line 2204 "Python/generated_cases.c.h" DISPATCH(); } @@ -2178,7 +2208,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1585 "Python/bytecodes.c" + #line 1541 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2188,14 +2218,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2192 "Python/generated_cases.c.h" + #line 2222 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1595 "Python/bytecodes.c" + #line 1551 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2199 "Python/generated_cases.c.h" + #line 2229 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2203,7 +2233,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1599 "Python/bytecodes.c" + #line 1555 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2211,12 +2241,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2215 "Python/generated_cases.c.h" + #line 2245 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1607 "Python/bytecodes.c" + #line 1563 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2220 "Python/generated_cases.c.h" + #line 2250 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2224,17 +2254,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1613 "Python/bytecodes.c" + #line 1569 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2233 "Python/generated_cases.c.h" + #line 2263 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1618 "Python/bytecodes.c" + #line 1574 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2238 "Python/generated_cases.c.h" + #line 2268 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2244,13 +2274,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1625 "Python/bytecodes.c" + #line 1581 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2254 "Python/generated_cases.c.h" + #line 2284 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2262,7 +2292,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1648 "Python/bytecodes.c" + #line 1604 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2296,9 +2326,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2300 "Python/generated_cases.c.h" + #line 2330 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1682 "Python/bytecodes.c" + #line 1638 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2307,12 +2337,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2311 "Python/generated_cases.c.h" + #line 2341 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1691 "Python/bytecodes.c" + #line 1647 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2316 "Python/generated_cases.c.h" + #line 2346 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2326,7 +2356,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1696 "Python/bytecodes.c" + #line 1652 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2339,7 +2369,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2343 "Python/generated_cases.c.h" + #line 2373 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2354,7 +2384,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1712 "Python/bytecodes.c" + #line 1668 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2367,7 +2397,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2371 "Python/generated_cases.c.h" + #line 2401 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2382,7 +2412,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1728 "Python/bytecodes.c" + #line 1684 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2409,7 +2439,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2413 "Python/generated_cases.c.h" + #line 2443 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2424,7 +2454,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1758 "Python/bytecodes.c" + #line 1714 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2434,7 +2464,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2438 "Python/generated_cases.c.h" + #line 2468 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2449,7 +2479,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1771 "Python/bytecodes.c" + #line 1727 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2461,7 +2491,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2465 "Python/generated_cases.c.h" + #line 2495 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2475,7 +2505,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1786 "Python/bytecodes.c" + #line 1742 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2499,7 +2529,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2503 "Python/generated_cases.c.h" + #line 2533 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2507,7 +2537,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1812 "Python/bytecodes.c" + #line 1768 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2533,7 +2563,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2537 "Python/generated_cases.c.h" + #line 2567 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2541,7 +2571,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1840 "Python/bytecodes.c" + #line 1796 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2559,7 +2589,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2563 "Python/generated_cases.c.h" + #line 2593 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2570,7 +2600,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1860 "Python/bytecodes.c" + #line 1816 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2609,7 +2639,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2613 "Python/generated_cases.c.h" + #line 2643 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2620,7 +2650,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1901 "Python/bytecodes.c" + #line 1857 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2630,7 +2660,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2634 "Python/generated_cases.c.h" + #line 2664 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2642,7 +2672,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1920 "Python/bytecodes.c" + #line 1876 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2655,12 +2685,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2659 "Python/generated_cases.c.h" + #line 2689 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1933 "Python/bytecodes.c" + #line 1889 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2664 "Python/generated_cases.c.h" + #line 2694 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2671,7 +2701,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1937 "Python/bytecodes.c" + #line 1893 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2683,7 +2713,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2687 "Python/generated_cases.c.h" + #line 2717 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2694,7 +2724,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1952 "Python/bytecodes.c" + #line 1908 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2710,7 +2740,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2714 "Python/generated_cases.c.h" + #line 2744 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2721,7 +2751,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1971 "Python/bytecodes.c" + #line 1927 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2734,7 +2764,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2738 "Python/generated_cases.c.h" + #line 2768 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2745,14 +2775,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1986 "Python/bytecodes.c" + #line 1942 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2751 "Python/generated_cases.c.h" + #line 2781 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1988 "Python/bytecodes.c" + #line 1944 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2756 "Python/generated_cases.c.h" + #line 2786 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2762,15 +2792,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1992 "Python/bytecodes.c" + #line 1948 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2768 "Python/generated_cases.c.h" + #line 2798 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1994 "Python/bytecodes.c" + #line 1950 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2774 "Python/generated_cases.c.h" + #line 2804 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2781,12 +2811,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 1999 "Python/bytecodes.c" + #line 1955 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2787 "Python/generated_cases.c.h" + #line 2817 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2001 "Python/bytecodes.c" + #line 1957 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2794,10 +2824,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2798 "Python/generated_cases.c.h" + #line 2828 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2009 "Python/bytecodes.c" + #line 1965 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2806,7 +2836,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2810 "Python/generated_cases.c.h" + #line 2840 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2816,21 +2846,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2020 "Python/bytecodes.c" + #line 1976 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2823 "Python/generated_cases.c.h" + #line 2853 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2023 "Python/bytecodes.c" + #line 1979 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2830 "Python/generated_cases.c.h" + #line 2860 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2028 "Python/bytecodes.c" + #line 1984 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2834 "Python/generated_cases.c.h" + #line 2864 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2839,15 +2869,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2032 "Python/bytecodes.c" + #line 1988 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2846 "Python/generated_cases.c.h" + #line 2876 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2035 "Python/bytecodes.c" + #line 1991 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2851 "Python/generated_cases.c.h" + #line 2881 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2856,29 +2886,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2039 "Python/bytecodes.c" + #line 1995 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2864 "Python/generated_cases.c.h" + #line 2894 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2045 "Python/bytecodes.c" + #line 2001 "Python/bytecodes.c" JUMPBY(oparg); - #line 2873 "Python/generated_cases.c.h" + #line 2903 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2049 "Python/bytecodes.c" + #line 2005 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2882 "Python/generated_cases.c.h" + #line 2912 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2886,7 +2916,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2055 "Python/bytecodes.c" + #line 2011 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2896,9 +2926,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2900 "Python/generated_cases.c.h" + #line 2930 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2065 "Python/bytecodes.c" + #line 2021 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -2906,14 +2936,14 @@ if (err < 0) goto pop_1_error; } } - #line 2910 "Python/generated_cases.c.h" + #line 2940 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2075 "Python/bytecodes.c" + #line 2031 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2923,9 +2953,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 2927 "Python/generated_cases.c.h" + #line 2957 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2085 "Python/bytecodes.c" + #line 2041 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -2933,67 +2963,67 @@ if (err < 0) goto pop_1_error; } } - #line 2937 "Python/generated_cases.c.h" + #line 2967 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2095 "Python/bytecodes.c" + #line 2051 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 2946 "Python/generated_cases.c.h" + #line 2976 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2097 "Python/bytecodes.c" + #line 2053 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 2954 "Python/generated_cases.c.h" + #line 2984 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2105 "Python/bytecodes.c" + #line 2061 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 2967 "Python/generated_cases.c.h" + #line 2997 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2111 "Python/bytecodes.c" + #line 2067 "Python/bytecodes.c" } - #line 2971 "Python/generated_cases.c.h" + #line 3001 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2115 "Python/bytecodes.c" + #line 2071 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 2984 "Python/generated_cases.c.h" + #line 3014 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2124 "Python/bytecodes.c" + #line 2080 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 2997 "Python/generated_cases.c.h" + #line 3027 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3004,16 +3034,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2132 "Python/bytecodes.c" + #line 2088 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3013 "Python/generated_cases.c.h" + #line 3043 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2137 "Python/bytecodes.c" + #line 2093 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3021,7 +3051,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3025 "Python/generated_cases.c.h" + #line 3055 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3030,10 +3060,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2147 "Python/bytecodes.c" + #line 2103 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3037 "Python/generated_cases.c.h" + #line 3067 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3043,10 +3073,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2153 "Python/bytecodes.c" + #line 2109 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3050 "Python/generated_cases.c.h" + #line 3080 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3057,11 +3087,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2159 "Python/bytecodes.c" + #line 2115 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3065 "Python/generated_cases.c.h" + #line 3095 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3070,14 +3100,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2165 "Python/bytecodes.c" + #line 2121 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3077 "Python/generated_cases.c.h" + #line 3107 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2168 "Python/bytecodes.c" + #line 2124 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3081 "Python/generated_cases.c.h" + #line 3111 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3085,7 +3115,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2172 "Python/bytecodes.c" + #line 2128 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3108,11 +3138,11 @@ if (iter == NULL) { goto error; } - #line 3112 "Python/generated_cases.c.h" + #line 3142 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2195 "Python/bytecodes.c" + #line 2151 "Python/bytecodes.c" } - #line 3116 "Python/generated_cases.c.h" + #line 3146 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3123,7 +3153,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2214 "Python/bytecodes.c" + #line 2170 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3154,7 +3184,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3158 "Python/generated_cases.c.h" + #line 3188 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3162,7 +3192,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2247 "Python/bytecodes.c" + #line 2203 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3188,14 +3218,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3192 "Python/generated_cases.c.h" + #line 3222 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2275 "Python/bytecodes.c" + #line 2231 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3215,7 +3245,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3219 "Python/generated_cases.c.h" + #line 3249 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3225,7 +3255,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2297 "Python/bytecodes.c" + #line 2253 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3245,7 +3275,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3249 "Python/generated_cases.c.h" + #line 3279 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3255,7 +3285,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2319 "Python/bytecodes.c" + #line 2275 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3273,7 +3303,7 @@ if (next == NULL) { goto error; } - #line 3277 "Python/generated_cases.c.h" + #line 3307 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3282,7 +3312,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2339 "Python/bytecodes.c" + #line 2295 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3297,14 +3327,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3301 "Python/generated_cases.c.h" + #line 3331 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2356 "Python/bytecodes.c" + #line 2312 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3327,16 +3357,16 @@ Py_DECREF(enter); goto error; } - #line 3331 "Python/generated_cases.c.h" + #line 3361 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2379 "Python/bytecodes.c" + #line 2335 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3340 "Python/generated_cases.c.h" + #line 3370 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3348,7 +3378,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2389 "Python/bytecodes.c" + #line 2345 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3374,16 +3404,16 @@ Py_DECREF(enter); goto error; } - #line 3378 "Python/generated_cases.c.h" + #line 3408 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2415 "Python/bytecodes.c" + #line 2371 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3387 "Python/generated_cases.c.h" + #line 3417 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3395,7 +3425,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2424 "Python/bytecodes.c" + #line 2380 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3416,7 +3446,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3420 "Python/generated_cases.c.h" + #line 3450 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3425,7 +3455,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2447 "Python/bytecodes.c" + #line 2403 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3435,7 +3465,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3439 "Python/generated_cases.c.h" + #line 3469 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3449,7 +3479,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2459 "Python/bytecodes.c" + #line 2415 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3466,7 +3496,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3470 "Python/generated_cases.c.h" + #line 3500 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3480,7 +3510,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2478 "Python/bytecodes.c" + #line 2434 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3490,7 +3520,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3494 "Python/generated_cases.c.h" + #line 3524 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3504,7 +3534,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2490 "Python/bytecodes.c" + #line 2446 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3518,7 +3548,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3522 "Python/generated_cases.c.h" + #line 3552 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3527,16 +3557,16 @@ } TARGET(KW_NAMES) { - #line 2506 "Python/bytecodes.c" + #line 2462 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3535 "Python/generated_cases.c.h" + #line 3565 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2512 "Python/bytecodes.c" + #line 2468 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3549,7 +3579,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3553 "Python/generated_cases.c.h" + #line 3583 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3559,7 +3589,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2557 "Python/bytecodes.c" + #line 2513 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3641,7 +3671,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3645 "Python/generated_cases.c.h" + #line 3675 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3653,7 +3683,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2645 "Python/bytecodes.c" + #line 2601 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3663,7 +3693,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3667 "Python/generated_cases.c.h" + #line 3697 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3672,7 +3702,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2657 "Python/bytecodes.c" + #line 2613 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3698,7 +3728,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3702 "Python/generated_cases.c.h" + #line 3732 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3706,7 +3736,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2685 "Python/bytecodes.c" + #line 2641 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3742,7 +3772,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3746 "Python/generated_cases.c.h" + #line 3776 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3750,7 +3780,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2723 "Python/bytecodes.c" + #line 2679 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3760,7 +3790,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3764 "Python/generated_cases.c.h" + #line 3794 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3773,7 +3803,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2735 "Python/bytecodes.c" + #line 2691 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3784,7 +3814,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3788 "Python/generated_cases.c.h" + #line 3818 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3798,7 +3828,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2749 "Python/bytecodes.c" + #line 2705 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3809,7 +3839,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3813 "Python/generated_cases.c.h" + #line 3843 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3823,7 +3853,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2763 "Python/bytecodes.c" + #line 2719 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3845,7 +3875,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3849 "Python/generated_cases.c.h" + #line 3879 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3859,7 +3889,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2788 "Python/bytecodes.c" + #line 2744 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3887,7 +3917,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3891 "Python/generated_cases.c.h" + #line 3921 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3901,7 +3931,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2819 "Python/bytecodes.c" + #line 2775 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3933,7 +3963,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 3937 "Python/generated_cases.c.h" + #line 3967 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3947,7 +3977,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2854 "Python/bytecodes.c" + #line 2810 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -3979,7 +4009,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3983 "Python/generated_cases.c.h" + #line 4013 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3993,7 +4023,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2889 "Python/bytecodes.c" + #line 2845 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4018,7 +4048,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4022 "Python/generated_cases.c.h" + #line 4052 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4031,7 +4061,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2916 "Python/bytecodes.c" + #line 2872 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4058,7 +4088,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4062 "Python/generated_cases.c.h" + #line 4092 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4070,7 +4100,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2946 "Python/bytecodes.c" + #line 2902 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4088,14 +4118,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4092 "Python/generated_cases.c.h" + #line 4122 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2966 "Python/bytecodes.c" + #line 2922 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4126,7 +4156,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4130 "Python/generated_cases.c.h" + #line 4160 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4139,7 +4169,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3000 "Python/bytecodes.c" + #line 2956 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4168,7 +4198,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4172 "Python/generated_cases.c.h" + #line 4202 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4181,7 +4211,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3032 "Python/bytecodes.c" + #line 2988 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4210,7 +4240,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4214 "Python/generated_cases.c.h" + #line 4244 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4223,7 +4253,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3064 "Python/bytecodes.c" + #line 3020 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4251,7 +4281,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4255 "Python/generated_cases.c.h" + #line 4285 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4261,9 +4291,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3095 "Python/bytecodes.c" + #line 3051 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4267 "Python/generated_cases.c.h" + #line 4297 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4272,7 +4302,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3099 "Python/bytecodes.c" + #line 3055 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4315,14 +4345,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4319 "Python/generated_cases.c.h" + #line 4349 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3142 "Python/bytecodes.c" + #line 3098 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4326 "Python/generated_cases.c.h" + #line 4356 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4337,7 +4367,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3152 "Python/bytecodes.c" + #line 3108 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4366,14 +4396,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4370 "Python/generated_cases.c.h" + #line 4400 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3183 "Python/bytecodes.c" + #line 3139 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4394,7 +4424,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4398 "Python/generated_cases.c.h" + #line 4428 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4402,15 +4432,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3206 "Python/bytecodes.c" + #line 3162 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4408 "Python/generated_cases.c.h" + #line 4438 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3208 "Python/bytecodes.c" + #line 3164 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4414 "Python/generated_cases.c.h" + #line 4444 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4421,7 +4451,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3212 "Python/bytecodes.c" + #line 3168 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4456,7 +4486,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4460 "Python/generated_cases.c.h" + #line 4490 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4465,10 +4495,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3249 "Python/bytecodes.c" + #line 3205 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4472 "Python/generated_cases.c.h" + #line 4502 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4480,7 +4510,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3254 "Python/bytecodes.c" + #line 3210 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4495,12 +4525,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4499 "Python/generated_cases.c.h" + #line 4529 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3269 "Python/bytecodes.c" + #line 3225 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4504 "Python/generated_cases.c.h" + #line 4534 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4510,16 +4540,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3274 "Python/bytecodes.c" + #line 3230 "Python/bytecodes.c" assert(oparg >= 2); - #line 4516 "Python/generated_cases.c.h" + #line 4546 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3278 "Python/bytecodes.c" + #line 3234 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4539,11 +4569,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4543 "Python/generated_cases.c.h" + #line 4573 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3300 "Python/bytecodes.c" + #line 3256 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4555,26 +4585,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4559 "Python/generated_cases.c.h" + #line 4589 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3314 "Python/bytecodes.c" + #line 3270 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4565 "Python/generated_cases.c.h" + #line 4595 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3318 "Python/bytecodes.c" + #line 3274 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4572 "Python/generated_cases.c.h" + #line 4602 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3323 "Python/bytecodes.c" + #line 3279 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4583,12 +4613,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4587 "Python/generated_cases.c.h" + #line 4617 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3334 "Python/bytecodes.c" + #line 3290 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4597,12 +4627,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4601 "Python/generated_cases.c.h" + #line 4631 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3345 "Python/bytecodes.c" + #line 3301 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4615,12 +4645,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4619 "Python/generated_cases.c.h" + #line 4649 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3360 "Python/bytecodes.c" + #line 3316 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4633,30 +4663,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4637 "Python/generated_cases.c.h" + #line 4667 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3375 "Python/bytecodes.c" + #line 3331 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4648 "Python/generated_cases.c.h" + #line 4678 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3383 "Python/bytecodes.c" + #line 3339 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4655 "Python/generated_cases.c.h" + #line 4685 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3388 "Python/bytecodes.c" + #line 3344 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4662 "Python/generated_cases.c.h" + #line 4692 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 1ececd24cfadbf..d3ef76b3adff0c 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -162,9 +162,9 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case DELETE_GLOBAL: return 0; case LOAD_NAME: - return 0; - case LOAD_CLASS_DICT: - return 0; + return 0+2; + case LOAD_CLASS_OR_GLOBAL: + return 0+2; case LOAD_GLOBAL: return 0; case LOAD_GLOBAL_MODULE: @@ -550,9 +550,9 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { case DELETE_GLOBAL: return 0; case LOAD_NAME: - return 1; - case LOAD_CLASS_DICT: - return 1; + return 2+1; + case LOAD_CLASS_OR_GLOBAL: + return 2+1; case LOAD_GLOBAL: return ((oparg & 1) ? 1 : 0) + 1; case LOAD_GLOBAL_MODULE: @@ -866,7 +866,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [STORE_GLOBAL] = { true, INSTR_FMT_IB }, [DELETE_GLOBAL] = { true, INSTR_FMT_IB }, [LOAD_NAME] = { true, INSTR_FMT_IB }, - [LOAD_CLASS_DICT] = { true, INSTR_FMT_IB }, + [LOAD_CLASS_OR_GLOBAL] = { true, INSTR_FMT_IB }, [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 441e8766e11ac7..1e52afd99f9a2b 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -174,7 +174,7 @@ static void *opcode_targets[256] = { &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, - &&TARGET_LOAD_CLASS_DICT, + &&TARGET_LOAD_CLASS_OR_GLOBAL, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From ea66c7c1cfc8e6cbc9c918aa9661cfb2d4d20d8c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 18:08:59 -0600 Subject: [PATCH 109/200] Use INTRINSIC_SET_CLASS_DICT --- Python/compile.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index c07e383a618f94..6bd061a7fe5df4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2197,15 +2197,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) ADDOP(c, loc, PUSH_NULL); // We'll swap in the callable here later. ADDOP_LOAD_CONST(c, loc, Py_None); - PySTEntryObject *ste = PySymtable_Lookup(c->c_st, (void *)typeparams); - if (ste == NULL) { - return ERROR; - } - is_typeparams_in_class = ste->ste_type_params_in_class; - if (is_typeparams_in_class) { - ADDOP(c, loc, LOAD_LOCALS); - } - Py_DECREF(ste); } funcflags = compiler_default_arguments(c, loc, args); @@ -2287,15 +2278,14 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS); - if (is_typeparams_in_class) { - c->u->u_metadata.u_argcount += 1; - } if (funcflags & 0x02) { c->u->u_metadata.u_argcount += 1; } if (funcflags & 0x01) { c->u->u_metadata.u_argcount += 1; } + // Must be before we exit the scope + int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2306,6 +2296,10 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); + if (is_typeparams_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); + } ADDOP_I(c, loc, SWAP, num_typeparam_args + 2); ADDOP(c, loc, POP_TOP); ADDOP_I(c, loc, CALL, num_typeparam_args); @@ -2478,8 +2472,8 @@ compiler_class(struct compiler *c, stmt_ty s) bases, s->v.ClassDef.keywords)); - int is_in_class = c->u->u_ste->ste_type_params_in_class; - c->u->u_metadata.u_argcount = is_in_class; + // Must be before we exit the scope + int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2490,10 +2484,11 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); - if (is_in_class) { + if (is_typeparams_in_class) { ADDOP(c, loc, LOAD_LOCALS); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); } - ADDOP_I(c, loc, CALL, is_in_class); + ADDOP_I(c, loc, CALL, 0); } else { RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, s->v.ClassDef.bases, @@ -2554,8 +2549,8 @@ compiler_typealias(struct compiler *c, stmt_ty s) ADDOP_I(c, loc, BUILD_TUPLE, 3); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); if (asdl_seq_LEN(typeparams) > 0) { - int is_in_class = c->u->u_ste->ste_type_params_in_class; - c->u->u_metadata.u_argcount = is_in_class; + // Must be before we exit the scope + int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2566,10 +2561,11 @@ compiler_typealias(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); - if (is_in_class) { + if (is_typeparams_in_class) { ADDOP(c, loc, LOAD_LOCALS); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); } - ADDOP_I(c, loc, CALL, is_in_class); + ADDOP_I(c, loc, CALL, 0); } RETURN_IF_ERROR(compiler_nameop(c, loc, name, Store)); return SUCCESS; From b314a3f9d6aa54e88080bcf0db971a1cebfad5d5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 18:26:22 -0600 Subject: [PATCH 110/200] Correctly handle class namespaces in TV bounds --- Python/bytecodes.c | 15 +- Python/compile.c | 4 + Python/generated_cases.c.h | 673 +++++++++++++++++++------------------ Python/symtable.c | 4 +- 4 files changed, 360 insertions(+), 336 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 7d63957ed3a92b..241564a51dae5d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -997,9 +997,18 @@ dummy_func( inst(LOAD_LOCALS, ( -- locals)) { locals = LOCALS(); if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found when loading locals()"); - ERROR_IF(true, error); + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + ERROR_IF(true, error); + } + locals = func->func_class_dict; + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no class dict set when loading locals"); + ERROR_IF(true, error); + } } Py_INCREF(locals); } diff --git a/Python/compile.c b/Python/compile.c index 6bd061a7fe5df4..cac5dd2e8624a0 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2111,6 +2111,10 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) return ERROR; } Py_DECREF(co); + if (c->u->u_ste->ste_type_params_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); + } int intrinsic = bound->kind == Tuple_kind ? INTRINSIC_TYPEVAR_WITH_CONSTRAINTS diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 5bbcf6b965e863..45cd6e31d0a52e 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1375,12 +1375,21 @@ #line 998 "Python/bytecodes.c" locals = LOCALS(); if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found when loading locals()"); - if (true) goto error; + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + if (true) goto error; + } + locals = func->func_class_dict; + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no class dict set when loading locals"); + if (true) goto error; + } } Py_INCREF(locals); - #line 1384 "Python/generated_cases.c.h" + #line 1393 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = locals; DISPATCH(); @@ -1388,33 +1397,33 @@ TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 1008 "Python/bytecodes.c" + #line 1017 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); - #line 1399 "Python/generated_cases.c.h" + #line 1408 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1015 "Python/bytecodes.c" + #line 1024 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); - #line 1408 "Python/generated_cases.c.h" + #line 1417 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1022 "Python/bytecodes.c" + #line 1031 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1412 "Python/generated_cases.c.h" + #line 1421 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { - #line 1026 "Python/bytecodes.c" + #line 1035 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1431,7 +1440,7 @@ name); goto error; } - #line 1435 "Python/generated_cases.c.h" + #line 1444 "Python/generated_cases.c.h" DISPATCH(); } @@ -1439,7 +1448,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 1052 "Python/bytecodes.c" + #line 1061 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1452,11 +1461,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); - #line 1456 "Python/generated_cases.c.h" + #line 1465 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1065 "Python/bytecodes.c" + #line 1074 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1460 "Python/generated_cases.c.h" + #line 1469 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1466,14 +1475,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1069 "Python/bytecodes.c" + #line 1078 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); - #line 1477 "Python/generated_cases.c.h" + #line 1486 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1484,7 +1493,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1079 "Python/bytecodes.c" + #line 1088 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1492,7 +1501,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1496 "Python/generated_cases.c.h" + #line 1505 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1503,7 +1512,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1090 "Python/bytecodes.c" + #line 1099 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1511,7 +1520,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1515 "Python/generated_cases.c.h" + #line 1524 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1521,15 +1530,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 1101 "Python/bytecodes.c" + #line 1110 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); - #line 1529 "Python/generated_cases.c.h" + #line 1538 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1105 "Python/bytecodes.c" + #line 1114 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1533 "Python/generated_cases.c.h" + #line 1542 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1540,7 +1549,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 1116 "Python/bytecodes.c" + #line 1125 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1556,12 +1565,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); - #line 1560 "Python/generated_cases.c.h" + #line 1569 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1132 "Python/bytecodes.c" + #line 1141 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 1565 "Python/generated_cases.c.h" + #line 1574 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1569,34 +1578,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1136 "Python/bytecodes.c" + #line 1145 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); - #line 1576 "Python/generated_cases.c.h" + #line 1585 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1139 "Python/bytecodes.c" + #line 1148 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1580 "Python/generated_cases.c.h" + #line 1589 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1143 "Python/bytecodes.c" + #line 1152 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); - #line 1590 "Python/generated_cases.c.h" + #line 1599 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1146 "Python/bytecodes.c" + #line 1155 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1594 "Python/generated_cases.c.h" + #line 1603 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { - #line 1150 "Python/bytecodes.c" + #line 1159 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1608,7 +1617,7 @@ } goto error; } - #line 1612 "Python/generated_cases.c.h" + #line 1621 "Python/generated_cases.c.h" DISPATCH(); } @@ -1618,7 +1627,7 @@ { PyObject *class_dict; PyObject *name; - #line 1164 "Python/bytecodes.c" + #line 1173 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); class_dict = LOCALS(); if (class_dict == NULL) { @@ -1626,7 +1635,7 @@ "no locals when loading %R", name); goto error; } - #line 1630 "Python/generated_cases.c.h" + #line 1639 "Python/generated_cases.c.h" _tmp_2 = class_dict; _tmp_1 = name; } @@ -1634,7 +1643,7 @@ PyObject *name = _tmp_1; PyObject *class_dict = _tmp_2; PyObject *v; - #line 1190 "Python/bytecodes.c" + #line 1199 "Python/bytecodes.c" if (PyDict_CheckExact(class_dict)) { v = PyDict_GetItemWithError(class_dict, name); if (v != NULL) { @@ -1686,7 +1695,7 @@ } } } - #line 1690 "Python/generated_cases.c.h" + #line 1699 "Python/generated_cases.c.h" _tmp_2 = v; } STACK_GROW(1); @@ -1700,7 +1709,7 @@ { PyObject *class_dict; PyObject *name; - #line 1174 "Python/bytecodes.c" + #line 1183 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; if (func == NULL) { @@ -1714,7 +1723,7 @@ "no class dict set when loading %R", name); goto error; } - #line 1718 "Python/generated_cases.c.h" + #line 1727 "Python/generated_cases.c.h" _tmp_2 = class_dict; _tmp_1 = name; } @@ -1722,7 +1731,7 @@ PyObject *name = _tmp_1; PyObject *class_dict = _tmp_2; PyObject *v; - #line 1190 "Python/bytecodes.c" + #line 1199 "Python/bytecodes.c" if (PyDict_CheckExact(class_dict)) { v = PyDict_GetItemWithError(class_dict, name); if (v != NULL) { @@ -1774,7 +1783,7 @@ } } } - #line 1778 "Python/generated_cases.c.h" + #line 1787 "Python/generated_cases.c.h" _tmp_2 = v; } STACK_GROW(1); @@ -1787,7 +1796,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1254 "Python/bytecodes.c" + #line 1263 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1839,7 +1848,7 @@ } } null = NULL; - #line 1843 "Python/generated_cases.c.h" + #line 1852 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1853,7 +1862,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1308 "Python/bytecodes.c" + #line 1317 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1864,7 +1873,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1868 "Python/generated_cases.c.h" + #line 1877 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1879,7 +1888,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1321 "Python/bytecodes.c" + #line 1330 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1894,7 +1903,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1898 "Python/generated_cases.c.h" + #line 1907 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1904,16 +1913,16 @@ } TARGET(DELETE_FAST) { - #line 1338 "Python/bytecodes.c" + #line 1347 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1912 "Python/generated_cases.c.h" + #line 1921 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1344 "Python/bytecodes.c" + #line 1353 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1922,12 +1931,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1926 "Python/generated_cases.c.h" + #line 1935 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1355 "Python/bytecodes.c" + #line 1364 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1938,13 +1947,13 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1942 "Python/generated_cases.c.h" + #line 1951 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_CLASSDEREF) { PyObject *value; - #line 1368 "Python/bytecodes.c" + #line 1377 "Python/bytecodes.c" PyObject *name, *locals = LOCALS(); assert(locals); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1976,7 +1985,7 @@ } Py_INCREF(value); } - #line 1980 "Python/generated_cases.c.h" + #line 1989 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1984,7 +1993,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1402 "Python/bytecodes.c" + #line 1411 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1992,7 +2001,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1996 "Python/generated_cases.c.h" + #line 2005 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -2000,18 +2009,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1412 "Python/bytecodes.c" + #line 1421 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2009 "Python/generated_cases.c.h" + #line 2018 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1419 "Python/bytecodes.c" + #line 1428 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2022,22 +2031,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2026 "Python/generated_cases.c.h" + #line 2035 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1432 "Python/bytecodes.c" + #line 1441 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2035 "Python/generated_cases.c.h" + #line 2044 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1434 "Python/bytecodes.c" + #line 1443 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2041 "Python/generated_cases.c.h" + #line 2050 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2047,10 +2056,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1438 "Python/bytecodes.c" + #line 1447 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2054 "Python/generated_cases.c.h" + #line 2063 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2060,10 +2069,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1443 "Python/bytecodes.c" + #line 1452 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2067 "Python/generated_cases.c.h" + #line 2076 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2073,7 +2082,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1448 "Python/bytecodes.c" + #line 1457 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2084,13 +2093,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2088 "Python/generated_cases.c.h" + #line 2097 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1459 "Python/bytecodes.c" + #line 1468 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2094 "Python/generated_cases.c.h" + #line 2103 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2099,13 +2108,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1466 "Python/bytecodes.c" + #line 1475 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2105 "Python/generated_cases.c.h" + #line 2114 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1468 "Python/bytecodes.c" + #line 1477 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2109 "Python/generated_cases.c.h" + #line 2118 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2113,7 +2122,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1472 "Python/bytecodes.c" + #line 1481 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2128,7 +2137,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2132 "Python/generated_cases.c.h" + #line 2141 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2138,7 +2147,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1489 "Python/bytecodes.c" + #line 1498 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2146,13 +2155,13 @@ if (map == NULL) goto error; - #line 2150 "Python/generated_cases.c.h" + #line 2159 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1497 "Python/bytecodes.c" + #line 1506 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2156 "Python/generated_cases.c.h" + #line 2165 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2160,7 +2169,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1501 "Python/bytecodes.c" + #line 1510 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2200,7 +2209,7 @@ Py_DECREF(ann_dict); } } - #line 2204 "Python/generated_cases.c.h" + #line 2213 "Python/generated_cases.c.h" DISPATCH(); } @@ -2208,7 +2217,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1543 "Python/bytecodes.c" + #line 1552 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2218,14 +2227,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2222 "Python/generated_cases.c.h" + #line 2231 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1553 "Python/bytecodes.c" + #line 1562 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2229 "Python/generated_cases.c.h" + #line 2238 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2233,7 +2242,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1557 "Python/bytecodes.c" + #line 1566 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2241,12 +2250,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2245 "Python/generated_cases.c.h" + #line 2254 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1565 "Python/bytecodes.c" + #line 1574 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2250 "Python/generated_cases.c.h" + #line 2259 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2254,17 +2263,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1571 "Python/bytecodes.c" + #line 1580 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2263 "Python/generated_cases.c.h" + #line 2272 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1576 "Python/bytecodes.c" + #line 1585 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2268 "Python/generated_cases.c.h" + #line 2277 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2274,13 +2283,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1583 "Python/bytecodes.c" + #line 1592 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2284 "Python/generated_cases.c.h" + #line 2293 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2294,7 +2303,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1597 "Python/bytecodes.c" + #line 1606 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2312,16 +2321,16 @@ // handle any case whose performance we care about PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2316 "Python/generated_cases.c.h" + #line 2325 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1615 "Python/bytecodes.c" + #line 1624 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2325 "Python/generated_cases.c.h" + #line 2334 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2339,7 +2348,7 @@ uint32_t class_version = read_u32(&next_instr[1].cache); uint32_t self_type_version = read_u32(&next_instr[3].cache); PyObject *method = read_obj(&next_instr[5].cache); - #line 1622 "Python/bytecodes.c" + #line 1631 "Python/bytecodes.c" DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); DEOPT_IF(((PyTypeObject *)class)->tp_version_tag != class_version, LOAD_SUPER_ATTR); @@ -2350,7 +2359,7 @@ Py_INCREF(res2); Py_DECREF(global_super); Py_DECREF(class); - #line 2354 "Python/generated_cases.c.h" + #line 2363 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2364,7 +2373,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1649 "Python/bytecodes.c" + #line 1658 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2398,9 +2407,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2402 "Python/generated_cases.c.h" + #line 2411 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1683 "Python/bytecodes.c" + #line 1692 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2409,12 +2418,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2413 "Python/generated_cases.c.h" + #line 2422 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1692 "Python/bytecodes.c" + #line 1701 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2418 "Python/generated_cases.c.h" + #line 2427 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2428,7 +2437,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1697 "Python/bytecodes.c" + #line 1706 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2441,7 +2450,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2445 "Python/generated_cases.c.h" + #line 2454 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2456,7 +2465,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1713 "Python/bytecodes.c" + #line 1722 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2469,7 +2478,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2473 "Python/generated_cases.c.h" + #line 2482 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2484,7 +2493,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1729 "Python/bytecodes.c" + #line 1738 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2511,7 +2520,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2515 "Python/generated_cases.c.h" + #line 2524 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2526,7 +2535,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1759 "Python/bytecodes.c" + #line 1768 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2536,7 +2545,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2540 "Python/generated_cases.c.h" + #line 2549 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2551,7 +2560,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1772 "Python/bytecodes.c" + #line 1781 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2563,7 +2572,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2567 "Python/generated_cases.c.h" + #line 2576 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2577,7 +2586,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1787 "Python/bytecodes.c" + #line 1796 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2601,7 +2610,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2605 "Python/generated_cases.c.h" + #line 2614 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2609,7 +2618,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1813 "Python/bytecodes.c" + #line 1822 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2635,7 +2644,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2639 "Python/generated_cases.c.h" + #line 2648 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2643,7 +2652,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1841 "Python/bytecodes.c" + #line 1850 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2661,7 +2670,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2665 "Python/generated_cases.c.h" + #line 2674 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2672,7 +2681,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1861 "Python/bytecodes.c" + #line 1870 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2711,7 +2720,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2715 "Python/generated_cases.c.h" + #line 2724 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2722,7 +2731,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1902 "Python/bytecodes.c" + #line 1911 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2732,7 +2741,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2736 "Python/generated_cases.c.h" + #line 2745 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2744,7 +2753,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1921 "Python/bytecodes.c" + #line 1930 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2757,12 +2766,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2761 "Python/generated_cases.c.h" + #line 2770 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1934 "Python/bytecodes.c" + #line 1943 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2766 "Python/generated_cases.c.h" + #line 2775 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2773,7 +2782,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1938 "Python/bytecodes.c" + #line 1947 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2785,7 +2794,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2789 "Python/generated_cases.c.h" + #line 2798 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2796,7 +2805,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1953 "Python/bytecodes.c" + #line 1962 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2812,7 +2821,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2816 "Python/generated_cases.c.h" + #line 2825 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2823,7 +2832,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1972 "Python/bytecodes.c" + #line 1981 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2836,7 +2845,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2840 "Python/generated_cases.c.h" + #line 2849 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2847,14 +2856,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1987 "Python/bytecodes.c" + #line 1996 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2853 "Python/generated_cases.c.h" + #line 2862 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1989 "Python/bytecodes.c" + #line 1998 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2858 "Python/generated_cases.c.h" + #line 2867 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2864,15 +2873,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1993 "Python/bytecodes.c" + #line 2002 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2870 "Python/generated_cases.c.h" + #line 2879 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1995 "Python/bytecodes.c" + #line 2004 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2876 "Python/generated_cases.c.h" + #line 2885 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2883,12 +2892,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2000 "Python/bytecodes.c" + #line 2009 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2889 "Python/generated_cases.c.h" + #line 2898 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2002 "Python/bytecodes.c" + #line 2011 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2896,10 +2905,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2900 "Python/generated_cases.c.h" + #line 2909 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2010 "Python/bytecodes.c" + #line 2019 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2908,7 +2917,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2912 "Python/generated_cases.c.h" + #line 2921 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2918,21 +2927,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2021 "Python/bytecodes.c" + #line 2030 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2925 "Python/generated_cases.c.h" + #line 2934 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2024 "Python/bytecodes.c" + #line 2033 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2932 "Python/generated_cases.c.h" + #line 2941 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2029 "Python/bytecodes.c" + #line 2038 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2936 "Python/generated_cases.c.h" + #line 2945 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2941,15 +2950,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2033 "Python/bytecodes.c" + #line 2042 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2948 "Python/generated_cases.c.h" + #line 2957 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2036 "Python/bytecodes.c" + #line 2045 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2953 "Python/generated_cases.c.h" + #line 2962 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2958,29 +2967,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2040 "Python/bytecodes.c" + #line 2049 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2966 "Python/generated_cases.c.h" + #line 2975 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2046 "Python/bytecodes.c" + #line 2055 "Python/bytecodes.c" JUMPBY(oparg); - #line 2975 "Python/generated_cases.c.h" + #line 2984 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2050 "Python/bytecodes.c" + #line 2059 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2984 "Python/generated_cases.c.h" + #line 2993 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2988,7 +2997,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2056 "Python/bytecodes.c" + #line 2065 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -2998,9 +3007,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3002 "Python/generated_cases.c.h" + #line 3011 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2066 "Python/bytecodes.c" + #line 2075 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3008,14 +3017,14 @@ if (err < 0) goto pop_1_error; } } - #line 3012 "Python/generated_cases.c.h" + #line 3021 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2076 "Python/bytecodes.c" + #line 2085 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3025,9 +3034,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3029 "Python/generated_cases.c.h" + #line 3038 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2086 "Python/bytecodes.c" + #line 2095 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3035,67 +3044,67 @@ if (err < 0) goto pop_1_error; } } - #line 3039 "Python/generated_cases.c.h" + #line 3048 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2096 "Python/bytecodes.c" + #line 2105 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3048 "Python/generated_cases.c.h" + #line 3057 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2098 "Python/bytecodes.c" + #line 2107 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3056 "Python/generated_cases.c.h" + #line 3065 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2106 "Python/bytecodes.c" + #line 2115 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3069 "Python/generated_cases.c.h" + #line 3078 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2112 "Python/bytecodes.c" + #line 2121 "Python/bytecodes.c" } - #line 3073 "Python/generated_cases.c.h" + #line 3082 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2116 "Python/bytecodes.c" + #line 2125 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3086 "Python/generated_cases.c.h" + #line 3095 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2125 "Python/bytecodes.c" + #line 2134 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3099 "Python/generated_cases.c.h" + #line 3108 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3106,16 +3115,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2133 "Python/bytecodes.c" + #line 2142 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3115 "Python/generated_cases.c.h" + #line 3124 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2138 "Python/bytecodes.c" + #line 2147 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3123,7 +3132,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3127 "Python/generated_cases.c.h" + #line 3136 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3132,10 +3141,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2148 "Python/bytecodes.c" + #line 2157 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3139 "Python/generated_cases.c.h" + #line 3148 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3145,10 +3154,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2154 "Python/bytecodes.c" + #line 2163 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3152 "Python/generated_cases.c.h" + #line 3161 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3159,11 +3168,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2160 "Python/bytecodes.c" + #line 2169 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3167 "Python/generated_cases.c.h" + #line 3176 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3172,14 +3181,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2166 "Python/bytecodes.c" + #line 2175 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3179 "Python/generated_cases.c.h" + #line 3188 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2169 "Python/bytecodes.c" + #line 2178 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3183 "Python/generated_cases.c.h" + #line 3192 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3187,7 +3196,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2173 "Python/bytecodes.c" + #line 2182 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3210,11 +3219,11 @@ if (iter == NULL) { goto error; } - #line 3214 "Python/generated_cases.c.h" + #line 3223 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2196 "Python/bytecodes.c" + #line 2205 "Python/bytecodes.c" } - #line 3218 "Python/generated_cases.c.h" + #line 3227 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3225,7 +3234,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2215 "Python/bytecodes.c" + #line 2224 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3256,7 +3265,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3260 "Python/generated_cases.c.h" + #line 3269 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3264,7 +3273,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2248 "Python/bytecodes.c" + #line 2257 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3290,14 +3299,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3294 "Python/generated_cases.c.h" + #line 3303 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2276 "Python/bytecodes.c" + #line 2285 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3317,7 +3326,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3321 "Python/generated_cases.c.h" + #line 3330 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3327,7 +3336,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2298 "Python/bytecodes.c" + #line 2307 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3347,7 +3356,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3351 "Python/generated_cases.c.h" + #line 3360 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3357,7 +3366,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2320 "Python/bytecodes.c" + #line 2329 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3375,7 +3384,7 @@ if (next == NULL) { goto error; } - #line 3379 "Python/generated_cases.c.h" + #line 3388 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3384,7 +3393,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2340 "Python/bytecodes.c" + #line 2349 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3399,14 +3408,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3403 "Python/generated_cases.c.h" + #line 3412 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2357 "Python/bytecodes.c" + #line 2366 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3429,16 +3438,16 @@ Py_DECREF(enter); goto error; } - #line 3433 "Python/generated_cases.c.h" + #line 3442 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2380 "Python/bytecodes.c" + #line 2389 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3442 "Python/generated_cases.c.h" + #line 3451 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3450,7 +3459,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2390 "Python/bytecodes.c" + #line 2399 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3476,16 +3485,16 @@ Py_DECREF(enter); goto error; } - #line 3480 "Python/generated_cases.c.h" + #line 3489 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2416 "Python/bytecodes.c" + #line 2425 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3489 "Python/generated_cases.c.h" + #line 3498 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3497,7 +3506,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2425 "Python/bytecodes.c" + #line 2434 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3518,7 +3527,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3522 "Python/generated_cases.c.h" + #line 3531 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3527,7 +3536,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2448 "Python/bytecodes.c" + #line 2457 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3537,7 +3546,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3541 "Python/generated_cases.c.h" + #line 3550 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3551,7 +3560,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2460 "Python/bytecodes.c" + #line 2469 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3568,7 +3577,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3572 "Python/generated_cases.c.h" + #line 3581 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3582,7 +3591,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2479 "Python/bytecodes.c" + #line 2488 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3592,7 +3601,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3596 "Python/generated_cases.c.h" + #line 3605 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3606,7 +3615,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2491 "Python/bytecodes.c" + #line 2500 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3620,7 +3629,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3624 "Python/generated_cases.c.h" + #line 3633 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3629,16 +3638,16 @@ } TARGET(KW_NAMES) { - #line 2507 "Python/bytecodes.c" + #line 2516 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3637 "Python/generated_cases.c.h" + #line 3646 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2513 "Python/bytecodes.c" + #line 2522 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3651,7 +3660,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3655 "Python/generated_cases.c.h" + #line 3664 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3661,7 +3670,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2558 "Python/bytecodes.c" + #line 2567 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3743,7 +3752,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3747 "Python/generated_cases.c.h" + #line 3756 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3755,7 +3764,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2646 "Python/bytecodes.c" + #line 2655 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3765,7 +3774,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3769 "Python/generated_cases.c.h" + #line 3778 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3774,7 +3783,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2658 "Python/bytecodes.c" + #line 2667 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3800,7 +3809,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3804 "Python/generated_cases.c.h" + #line 3813 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3808,7 +3817,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2686 "Python/bytecodes.c" + #line 2695 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3844,7 +3853,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3848 "Python/generated_cases.c.h" + #line 3857 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3852,7 +3861,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2724 "Python/bytecodes.c" + #line 2733 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3862,7 +3871,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3866 "Python/generated_cases.c.h" + #line 3875 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3875,7 +3884,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2736 "Python/bytecodes.c" + #line 2745 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3886,7 +3895,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3890 "Python/generated_cases.c.h" + #line 3899 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3900,7 +3909,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2750 "Python/bytecodes.c" + #line 2759 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3911,7 +3920,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3915 "Python/generated_cases.c.h" + #line 3924 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3925,7 +3934,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2764 "Python/bytecodes.c" + #line 2773 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3947,7 +3956,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3951 "Python/generated_cases.c.h" + #line 3960 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3961,7 +3970,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2789 "Python/bytecodes.c" + #line 2798 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3989,7 +3998,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3993 "Python/generated_cases.c.h" + #line 4002 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4003,7 +4012,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2820 "Python/bytecodes.c" + #line 2829 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4035,7 +4044,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4039 "Python/generated_cases.c.h" + #line 4048 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4049,7 +4058,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2855 "Python/bytecodes.c" + #line 2864 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4081,7 +4090,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4085 "Python/generated_cases.c.h" + #line 4094 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4095,7 +4104,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2890 "Python/bytecodes.c" + #line 2899 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4120,7 +4129,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4124 "Python/generated_cases.c.h" + #line 4133 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4133,7 +4142,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2917 "Python/bytecodes.c" + #line 2926 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4160,7 +4169,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4164 "Python/generated_cases.c.h" + #line 4173 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4172,7 +4181,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2947 "Python/bytecodes.c" + #line 2956 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4190,14 +4199,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4194 "Python/generated_cases.c.h" + #line 4203 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2967 "Python/bytecodes.c" + #line 2976 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4228,7 +4237,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4232 "Python/generated_cases.c.h" + #line 4241 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4241,7 +4250,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3001 "Python/bytecodes.c" + #line 3010 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4270,7 +4279,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4274 "Python/generated_cases.c.h" + #line 4283 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4283,7 +4292,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3033 "Python/bytecodes.c" + #line 3042 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4312,7 +4321,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4316 "Python/generated_cases.c.h" + #line 4325 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4325,7 +4334,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3065 "Python/bytecodes.c" + #line 3074 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4353,7 +4362,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4357 "Python/generated_cases.c.h" + #line 4366 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4363,9 +4372,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3096 "Python/bytecodes.c" + #line 3105 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4369 "Python/generated_cases.c.h" + #line 4378 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4374,7 +4383,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3100 "Python/bytecodes.c" + #line 3109 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4417,14 +4426,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4421 "Python/generated_cases.c.h" + #line 4430 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3143 "Python/bytecodes.c" + #line 3152 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4428 "Python/generated_cases.c.h" + #line 4437 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4439,7 +4448,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3153 "Python/bytecodes.c" + #line 3162 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4468,14 +4477,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4472 "Python/generated_cases.c.h" + #line 4481 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3184 "Python/bytecodes.c" + #line 3193 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4496,7 +4505,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4500 "Python/generated_cases.c.h" + #line 4509 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4504,15 +4513,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3207 "Python/bytecodes.c" + #line 3216 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4510 "Python/generated_cases.c.h" + #line 4519 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3209 "Python/bytecodes.c" + #line 3218 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4516 "Python/generated_cases.c.h" + #line 4525 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4523,7 +4532,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3213 "Python/bytecodes.c" + #line 3222 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4558,7 +4567,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4562 "Python/generated_cases.c.h" + #line 4571 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4567,10 +4576,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3250 "Python/bytecodes.c" + #line 3259 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4574 "Python/generated_cases.c.h" + #line 4583 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4582,7 +4591,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3255 "Python/bytecodes.c" + #line 3264 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4597,12 +4606,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4601 "Python/generated_cases.c.h" + #line 4610 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3270 "Python/bytecodes.c" + #line 3279 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4606 "Python/generated_cases.c.h" + #line 4615 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4612,16 +4621,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3275 "Python/bytecodes.c" + #line 3284 "Python/bytecodes.c" assert(oparg >= 2); - #line 4618 "Python/generated_cases.c.h" + #line 4627 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3279 "Python/bytecodes.c" + #line 3288 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4641,11 +4650,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4645 "Python/generated_cases.c.h" + #line 4654 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3301 "Python/bytecodes.c" + #line 3310 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4657,26 +4666,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4661 "Python/generated_cases.c.h" + #line 4670 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3315 "Python/bytecodes.c" + #line 3324 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4667 "Python/generated_cases.c.h" + #line 4676 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3319 "Python/bytecodes.c" + #line 3328 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4674 "Python/generated_cases.c.h" + #line 4683 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3324 "Python/bytecodes.c" + #line 3333 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4685,12 +4694,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4689 "Python/generated_cases.c.h" + #line 4698 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3335 "Python/bytecodes.c" + #line 3344 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4699,12 +4708,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4703 "Python/generated_cases.c.h" + #line 4712 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3346 "Python/bytecodes.c" + #line 3355 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4717,12 +4726,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4721 "Python/generated_cases.c.h" + #line 4730 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3361 "Python/bytecodes.c" + #line 3370 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4735,30 +4744,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4739 "Python/generated_cases.c.h" + #line 4748 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3376 "Python/bytecodes.c" + #line 3385 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4750 "Python/generated_cases.c.h" + #line 4759 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3384 "Python/bytecodes.c" + #line 3393 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4757 "Python/generated_cases.c.h" + #line 4766 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3389 "Python/bytecodes.c" + #line 3398 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4764 "Python/generated_cases.c.h" + #line 4773 "Python/generated_cases.c.h" } diff --git a/Python/symtable.c b/Python/symtable.c index 1a03b406dfbf8f..df9d2577a5424d 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1947,15 +1947,17 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); if (tp->v.TypeVar.bound) { + int is_in_class = st->st_cur->ste_type_params_in_class; if (!symtable_enter_block(st, tp->v.TypeVar.name, TypeVarBoundBlock, (void *)tp, LOCATION(tp))) VISIT_QUIT(st, 0); + st->st_cur->ste_type_params_in_class = is_in_class; VISIT(st, expr, tp->v.TypeVar.bound); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - } break; + } case TypeVarTuple_kind: if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); From 2e913ca083c680557b795853824caf5fb94ea6e7 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 18:31:12 -0600 Subject: [PATCH 111/200] Same for type aliases --- Python/compile.c | 5 +++++ Python/symtable.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Python/compile.c b/Python/compile.c index cac5dd2e8624a0..e93108d97624c8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2540,6 +2540,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) RETURN_IF_ERROR(compiler_add_const(c->c_const_cache, c->u, Py_None)); VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); + int is_in_class = c->u->u_ste->ste_type_params_in_class; PyCodeObject *co = optimize_and_assemble(c, 1); compiler_exit_scope(c); if (co == NULL) { @@ -2550,6 +2551,10 @@ compiler_typealias(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); + if (is_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); + } ADDOP_I(c, loc, BUILD_TUPLE, 3); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); if (asdl_seq_LEN(typeparams) > 0) { diff --git a/Python/symtable.c b/Python/symtable.c index df9d2577a5424d..32c517e810c120 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1399,6 +1399,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT(st, expr, s->v.TypeAlias.name); assert(s->v.TypeAlias.name->kind == Name_kind); PyObject *name = s->v.TypeAlias.name->v.Name.id; + int is_in_class = st->st_cur->ste_type == ClassBlock; if (asdl_seq_LEN(s->v.TypeAlias.typeparams) > 0) { if (!symtable_enter_typeparam_block( st, name, @@ -1412,6 +1413,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (!symtable_enter_block(st, name, TypeAliasBlock, (void *)s, LOCATION(s))) VISIT_QUIT(st, 0); + st->st_cur->ste_type_params_in_class = is_in_class; VISIT(st, expr, s->v.TypeAlias.value); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); From 394d1288f1113a59f5d26859df5087d2bacff85c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 18:48:48 -0600 Subject: [PATCH 112/200] Add test cases --- Lib/test/test_type_params.py | 36 ++++++++++++++++++++++++++++++++++++ Python/symtable.c | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 9c7f40a2166f7f..4bc01d7b2f1a39 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -305,6 +305,42 @@ class Foo[T: Undefined, U: (Undefined,)]: self.assertEqual(type_params[1].__constraints__, ("defined",)) +class TypeParamsClassScopeTest(unittest.TestCase): + def test_alias(self): + class X: + T = int + type U = T + self.assertIs(X.U.__value__, int) + + code = textwrap.dedent("""\ + glb = "global" + class X: + cls = "class" + type U = (glb, cls) + + assert X.U.__value__ == ("global", "class"), X.U.__value__ + """) + exec(code, {}) + + def test_bound(self): + class X: + T = int + def foo[U: T](self): ... + self.assertIs(X.foo.__type_params__[0].__bound__, int) + + code = textwrap.dedent("""\ + glb = "global" + class X: + cls = "class" + def foo[T: glb, U: cls](self): ... + + T, U = X.foo.__type_params__ + assert T.__bound__ == "global" + assert U.__bound__ == "class" + """) + exec(code, {}) + + class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): code = textwrap.dedent("""\ diff --git a/Python/symtable.c b/Python/symtable.c index 32c517e810c120..2331bf9643c705 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1958,8 +1958,8 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) VISIT(st, expr, tp->v.TypeVar.bound); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); + } break; - } case TypeVarTuple_kind: if (!symtable_add_def(st, tp->v.TypeVarTuple.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); From bd496227ebfe63025d1fb70af71569b11e948dab Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 19:10:52 -0600 Subject: [PATCH 113/200] Handle name mangling --- Lib/test/test_type_params.py | 23 +++++++++++++++++++++++ Python/compile.c | 1 + Python/symtable.c | 1 + 3 files changed, 25 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 4bc01d7b2f1a39..8734442c7e083f 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -341,6 +341,29 @@ def foo[T: glb, U: cls](self): ... exec(code, {}) +class ManglingTest(unittest.TestCase): + def test_mangling(self): + class Foo[__T]: + param = __T + def meth[__U](self, arg: __T, arg2: __U): + return (__T, __U) + type Alias[__V] = (__T, __V) + + T = Foo.__type_params__[0] + self.assertEqual(T.__name__, "__T") + U = Foo.meth.__type_params__[0] + self.assertEqual(U.__name__, "__U") + V = Foo.Alias.__type_params__[0] + self.assertEqual(V.__name__, "__V") + + anno = Foo.meth.__annotations__ + self.assertIs(anno["arg"], T) + self.assertIs(anno["arg2"], U) + self.assertEqual(Foo().meth(1, 2), (T, U)) + + self.assertEqual(Foo.Alias.__value__, (T, V)) + + class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): code = textwrap.dedent("""\ diff --git a/Python/compile.c b/Python/compile.c index e93108d97624c8..d8a356e1313a14 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2339,6 +2339,7 @@ compiler_class(struct compiler *c, stmt_ty s) asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; if (asdl_seq_LEN(typeparams) > 0) { + Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); ADDOP(c, loc, PUSH_NULL); PyObject *typeparams_name = PyUnicode_FromFormat("", s->v.ClassDef.name); diff --git a/Python/symtable.c b/Python/symtable.c index 2331bf9643c705..fefd3e7ed1a768 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1193,6 +1193,7 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, } } if (kind == ClassDef_kind) { + st->st_private = name; // This is used for setting the generic base _Py_DECLARE_STR(generic_base, ".generic_base"); if (!symtable_add_def(st, &_Py_STR(generic_base), DEF_LOCAL, From bf45a8ede4d4ac183e986a6028cc0a4deeddba99 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 21:57:33 -0600 Subject: [PATCH 114/200] I don't need __globals__ and it causes a lot of failures --- Include/internal/pycore_global_objects_fini_generated.h | 1 - Include/internal/pycore_global_strings.h | 1 - Include/internal/pycore_runtime_init_generated.h | 1 - Include/internal/pycore_unicodeobject_generated.h | 3 --- Objects/typeobject.c | 3 --- Python/bltinmodule.c | 5 ----- 6 files changed, 14 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index fcf51273db2b7e..b70c622dd1d370 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -636,7 +636,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getnewargs__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getnewargs_ex__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__getstate__)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__globals__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__gt__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__hash__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__iadd__)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 083585b5b9db10..29bf60403c33bf 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -124,7 +124,6 @@ struct _Py_global_strings { STRUCT_FOR_ID(__getnewargs__) STRUCT_FOR_ID(__getnewargs_ex__) STRUCT_FOR_ID(__getstate__) - STRUCT_FOR_ID(__globals__) STRUCT_FOR_ID(__gt__) STRUCT_FOR_ID(__hash__) STRUCT_FOR_ID(__iadd__) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 73f36457bc7d63..73134816574fae 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -630,7 +630,6 @@ extern "C" { INIT_ID(__getnewargs__), \ INIT_ID(__getnewargs_ex__), \ INIT_ID(__getstate__), \ - INIT_ID(__globals__), \ INIT_ID(__gt__), \ INIT_ID(__hash__), \ INIT_ID(__iadd__), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index ae103fd8328233..fd265484eef456 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -210,9 +210,6 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(__getstate__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); - string = &_Py_ID(__globals__); - assert(_PyUnicode_CheckConsistency(string, 1)); - _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(__gt__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 8649c632b66702..4f6ecf2540cbf1 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3040,9 +3040,6 @@ type_new_set_module(PyTypeObject *type) if (PyDict_SetItem(type->tp_dict, &_Py_ID(__module__), module) < 0) { return -1; } - if (PyDict_SetItem(type->tp_dict, &_Py_ID(__globals__), globals) < 0) { - return -1; - } return 0; } diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 5544b3b9586459..fcb4d7a9a975c6 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -195,11 +195,6 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs, Py_TYPE(ns)->tp_name); goto error; } - PyObject *globals = PyEval_GetGlobals(); - if ((globals == NULL) - || (PyMapping_SetItemString(ns, "__globals__", globals) < 0)) { - goto error; - } PyThreadState *tstate = _PyThreadState_GET(); EVAL_CALL_STAT_INC(EVAL_CALL_BUILD_CLASS); cell = _PyEval_Vector(tstate, (PyFunctionObject *)func, ns, NULL, 0, NULL); From ce7fe9cc25e3401d565f25a51761ca0ffed2a340 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 21:59:12 -0600 Subject: [PATCH 115/200] Fix another test --- Lib/test/test_sys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index 64af630aa26f34..c266f94b51b5dc 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1449,7 +1449,7 @@ def func(): check(x, size('3Pii3c7P2ic??2P')) # function def func(): pass - check(func, size('15Pi')) + check(func, size('16Pi')) class c(): @staticmethod def foo(): From 96324a528510253bb8bad17515f43f67aefa70c4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 26 Apr 2023 22:58:16 -0600 Subject: [PATCH 116/200] Extend NEWS entry, give credit to Larry --- ...-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst index db0c4df0335b5f..4b03bfeb89ba52 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst @@ -1,2 +1,19 @@ Implement :pep:`695`, adding syntactic support for generic classes, generic -functions, and type aliases. Patch by Eric Traut and Jelle Zijlstra. +functions, and type aliases. Patch by Eric Traut, Larry Hastings, and Jelle +Zijlstra. + +This includes the following changes: + +- A new ``type X = ...`` syntax for type aliases, which resolves at + runtime to an instance of the new class ``typing.TypeAliasType``. + This is implemented as a new AST node ``ast.TypeAlias``. +- New syntax (``class X[T]: ...``, ``def func[T](): ...``) for defining + generic functions and classes. This is implemented as a new + ``typeparams`` attribute on the AST nodes for classes and functions. + This node holds instances of the new AST classes ``ast.TypeVar``, + ``ast.ParamSpec``, and ``ast.TypeVarTuple``. +- ``typing.TypeVar``, ``typing.ParamSpec``, ``typing.ParamSpecArgs``, + ``typing.ParamSpecKwargs``, ``typing.TypeVarTuple``, and + ``typing.Generic`` are now implemented in C rather than Python. +- New bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` + to support correct resolution of names in class namespaces. From fd0f7b4cdc057ed487027cef93c0d9d7119de18b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 05:40:24 -0600 Subject: [PATCH 117/200] Fix GC tracking in error conditions --- Objects/typevarobject.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 6d4c4c2c0fe393..c15a7fd13cdc23 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -283,18 +283,21 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { + + char *owned_name = strdup(name); + if (owned_name == NULL) { + return NULL; + } + PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevar_type; assert(tp != NULL); typevarobject *tv = PyObject_GC_New(typevarobject, tp); if (tv == NULL) { + free((void *)owned_name); return NULL; } - tv->name = strdup(name); - if (tv->name == NULL) { - Py_DECREF(tv); - return NULL; - } + tv->name = owned_name; tv->bound = Py_XNewRef(bound); tv->evaluate_bound = Py_XNewRef(evaluate_bound); @@ -304,6 +307,8 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, tv->covariant = covariant; tv->contravariant = contravariant; tv->infer_variance = infer_variance; + PyObject_GC_Track(tv); + if (module != NULL) { if (PyObject_SetAttrString((PyObject *)tv, "__module__", module) < 0) { Py_DECREF(tv); @@ -311,7 +316,6 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, } } - PyObject_GC_Track(tv); return tv; } From e784da171b98566f37b235ede656e213a17341e7 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 05:44:46 -0600 Subject: [PATCH 118/200] More error paths --- Objects/typevarobject.c | 43 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index c15a7fd13cdc23..aea80ab6ffedda 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -286,6 +286,7 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, char *owned_name = strdup(name); if (owned_name == NULL) { + PyErr_NoMemory(); return NULL; } @@ -307,7 +308,7 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, tv->covariant = covariant; tv->contravariant = contravariant; tv->infer_variance = infer_variance; - PyObject_GC_Track(tv); + _PyObject_GC_TRACK(tv); if (module != NULL) { if (PyObject_SetAttrString((PyObject *)tv, "__module__", module) < 0) { @@ -813,27 +814,29 @@ static paramspecobject * paramspec_alloc(const char *name, PyObject *bound, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { + char *owned_name = strdup(name); + if (owned_name == NULL) { + PyErr_NoMemory(); + return NULL; + } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; paramspecobject *ps = PyObject_GC_New(paramspecobject, tp); if (ps == NULL) { + free((void *)owned_name); return NULL; } - ps->name = strdup(name); - if (ps->name == NULL) { - Py_DECREF(ps); - return NULL; - } + ps->name = owned_name; ps->bound = Py_XNewRef(bound); ps->covariant = covariant; ps->contravariant = contravariant; ps->infer_variance = infer_variance; + _PyObject_GC_TRACK(ps); if (module != NULL) { if (PyObject_SetAttrString((PyObject *)ps, "__module__", module) < 0) { Py_DECREF(ps); return NULL; } } - _PyObject_GC_TRACK(ps); return ps; } @@ -1071,23 +1074,25 @@ static PyMemberDef typevartuple_members[] = { static typevartupleobject * typevartuple_alloc(const char *name, PyObject *module) { + char *owned_name = strdup(name); + if (owned_name == NULL) { + PyErr_NoMemory(); + return NULL; + } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, tp); if (tvt == NULL) { + free(owned_name); return NULL; } - tvt->name = strdup(name); - if (tvt->name == NULL) { - Py_DECREF(tvt); - return NULL; - } + tvt->name = owned_name; + _PyObject_GC_TRACK(tvt); if (module != NULL) { if (PyObject_SetAttrString((PyObject *)tvt, "__module__", module) < 0) { Py_DECREF(tvt); return NULL; } } - _PyObject_GC_TRACK(tvt); return tvt; } @@ -1421,16 +1426,18 @@ static PyGetSetDef typealias_getset[] = { static typealiasobject * typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) { + char *owned_name = strdup(name); + if (owned_name == NULL) { + PyErr_NoMemory(); + return NULL; + } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typealias_type; typealiasobject *ta = PyObject_GC_New(typealiasobject, tp); if (ta == NULL) { + free(owned_name); return NULL; } - ta->name = strdup(name); - if (ta->name == NULL) { - Py_DECREF(ta); - return NULL; - } + ta->name = owned_name; ta->type_params = Py_IsNone(type_params) ? NULL : Py_XNewRef(type_params); ta->compute_value = Py_NewRef(compute_value); ta->value = NULL; From 72fc40c9284febb76f546c2c7aae3fd219b74275 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 05:44:57 -0600 Subject: [PATCH 119/200] Fix the NEWS? --- .../2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst index 4b03bfeb89ba52..8e0a437286b6f4 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst @@ -1,6 +1,5 @@ Implement :pep:`695`, adding syntactic support for generic classes, generic -functions, and type aliases. Patch by Eric Traut, Larry Hastings, and Jelle -Zijlstra. +functions, and type aliases. This includes the following changes: @@ -17,3 +16,5 @@ This includes the following changes: ``typing.Generic`` are now implemented in C rather than Python. - New bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` to support correct resolution of names in class namespaces. + +Patch by Eric Traut, Larry Hastings, and Jelle Zijlstra. From 93a45524b5afdf489ee78ce00d8917f191288db3 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 05:55:32 -0600 Subject: [PATCH 120/200] Can't have multi-line bulleted lists in NEWS --- ...-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst index 8e0a437286b6f4..09f2de23ae14e2 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst @@ -1,20 +1,22 @@ Implement :pep:`695`, adding syntactic support for generic classes, generic functions, and type aliases. -This includes the following changes: +A new ``type X = ...`` syntax is added for type aliases, which resolves at +runtime to an instance of the new class ``typing.TypeAliasType``. +The value is lazily evaluated and is accessible through the ``.__value__`` +attribute. This is implemented as a new AST node ``ast.TypeAlias``. -- A new ``type X = ...`` syntax for type aliases, which resolves at - runtime to an instance of the new class ``typing.TypeAliasType``. - This is implemented as a new AST node ``ast.TypeAlias``. -- New syntax (``class X[T]: ...``, ``def func[T](): ...``) for defining - generic functions and classes. This is implemented as a new - ``typeparams`` attribute on the AST nodes for classes and functions. - This node holds instances of the new AST classes ``ast.TypeVar``, - ``ast.ParamSpec``, and ``ast.TypeVarTuple``. -- ``typing.TypeVar``, ``typing.ParamSpec``, ``typing.ParamSpecArgs``, - ``typing.ParamSpecKwargs``, ``typing.TypeVarTuple``, and - ``typing.Generic`` are now implemented in C rather than Python. -- New bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` - to support correct resolution of names in class namespaces. +New syntax (``class X[T]: ...``, ``def func[T](): ...``) is added for defining +generic functions and classes. This is implemented as a new +``typeparams`` attribute on the AST nodes for classes and functions. +This node holds instances of the new AST classes ``ast.TypeVar``, +``ast.ParamSpec``, and ``ast.TypeVarTuple``. + +``typing.TypeVar``, ``typing.ParamSpec``, ``typing.ParamSpecArgs``, +``typing.ParamSpecKwargs``, ``typing.TypeVarTuple``, and +``typing.Generic`` are now implemented in C rather than Python. + +There are new bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` +to support correct resolution of names in class namespaces. Patch by Eric Traut, Larry Hastings, and Jelle Zijlstra. From b36b7af7d761d2e2039b1532b26e8878f4794f5e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 09:20:39 -0600 Subject: [PATCH 121/200] More test cases, remove redundant comment --- Lib/test/test_type_aliases.py | 25 +++++++++++++++++++++++-- Lib/test/test_type_params.py | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 0e519150057b92..30e9d1db07e04d 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -2,7 +2,7 @@ import types import unittest -from typing import TypeAliasType +from typing import Callable, TypeAliasType class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): @@ -90,13 +90,34 @@ def outer[A](): b = o.__parameters__[0] self.assertEqual(o.__type_params__, (b,)) + def more_generic[T, *Ts, **P](): + type TA[T2, *Ts2, **P2] = tuple[Callable[P, tuple[T, *Ts]], Callable[P2, tuple[T2, *Ts2]]] + return TA + + alias = more_generic() + self.assertIsInstance(alias, TypeAliasType) + T2, Ts2, P2 = alias.__type_params__ + self.assertEqual(alias.__parameters__, (T2, *Ts2, P2)) + T, Ts, P = more_generic.__type_params__ + self.assertEqual(alias.__value__, tuple[Callable[P, tuple[T, *Ts]], Callable[P2, tuple[T2, *Ts2]]]) + def test_subscripting(self): type NonGeneric = int type Generic[A] = dict[A, A] + type VeryGeneric[T, *Ts, **P] = Callable[P, tuple[T, *Ts]] with self.assertRaises(TypeError): NonGeneric[int] - self.assertIsInstance(Generic[int], types.GenericAlias) + + specialized = Generic[int] + self.assertIsInstance(specialized, types.GenericAlias) + self.assertIs(specialized.__origin__, Generic) + self.assertEqual(specialized.__args__, (int,)) + + specialized2 = VeryGeneric[int, str, float, [bool, range]] + self.assertIsInstance(specialized2, types.GenericAlias) + self.assertIs(specialized2.__origin__, VeryGeneric) + self.assertEqual(specialized2.__args__, (int, str, float, [bool, range])) def test_repr(self): type Simple = int diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 8734442c7e083f..e5b5cca2d6f9ad 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -257,7 +257,7 @@ def test_nonlocal(self): def outer2[T](): def inner1(): - nonlocal T # Syntax error: nonlocal binding not allowed for type parameter + nonlocal T """) with self.assertRaisesRegex(SyntaxError, "nonlocal binding not allowed for type parameter 'T'"): exec(code, {}) From 64540263c2f575906439a6103f2594b6a43b5c0e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 12:35:31 -0600 Subject: [PATCH 122/200] Add LOAD_CLASSDICT_OR_DEREF --- Include/internal/pycore_opcode.h | 8 +- Include/opcode.h | 3 +- Lib/opcode.py | 3 +- Lib/test/test_type_params.py | 10 + Python/bytecodes.c | 38 +- Python/compile.c | 13 +- Python/generated_cases.c.h | 667 +++++++++++++++++-------------- Python/opcode_metadata.h | 15 +- Python/opcode_targets.h | 4 +- 9 files changed, 442 insertions(+), 319 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index b87e157abc780b..8e064fe236936e 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -168,7 +168,8 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, [LOAD_CLASSDEREF] = LOAD_CLASSDEREF, - [LOAD_CLASS_OR_GLOBAL] = LOAD_CLASS_OR_GLOBAL, + [LOAD_CLASSDICT_OR_DEREF] = LOAD_CLASSDICT_OR_DEREF, + [LOAD_CLASSDICT_OR_GLOBAL] = LOAD_CLASSDICT_OR_GLOBAL, [LOAD_CLOSURE] = LOAD_CLOSURE, [LOAD_CONST] = LOAD_CONST, [LOAD_CONST__LOAD_FAST] = LOAD_CONST, @@ -417,8 +418,8 @@ static const char *const _PyOpcode_OpName[266] = { [KW_NAMES] = "KW_NAMES", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", - [LOAD_CLASS_OR_GLOBAL] = "LOAD_CLASS_OR_GLOBAL", - [176] = "<176>", + [LOAD_CLASSDICT_OR_GLOBAL] = "LOAD_CLASSDICT_OR_GLOBAL", + [LOAD_CLASSDICT_OR_DEREF] = "LOAD_CLASSDICT_OR_DEREF", [177] = "<177>", [178] = "<178>", [179] = "<179>", @@ -515,7 +516,6 @@ static const char *const _PyOpcode_OpName[266] = { case 168: \ case 169: \ case 170: \ - case 176: \ case 177: \ case 178: \ case 179: \ diff --git a/Include/opcode.h b/Include/opcode.h index b0221c182744d5..6eb648263b95c8 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -118,7 +118,8 @@ extern "C" { #define KW_NAMES 172 #define CALL_INTRINSIC_1 173 #define CALL_INTRINSIC_2 174 -#define LOAD_CLASS_OR_GLOBAL 175 +#define LOAD_CLASSDICT_OR_GLOBAL 175 +#define LOAD_CLASSDICT_OR_DEREF 176 #define MIN_INSTRUMENTED_OPCODE 238 #define INSTRUMENTED_POP_JUMP_IF_NONE 238 #define INSTRUMENTED_POP_JUMP_IF_NOT_NONE 239 diff --git a/Lib/opcode.py b/Lib/opcode.py index b873e08de66b82..d47c22edbb360b 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -227,7 +227,8 @@ def pseudo_op(name, op, real_ops): def_op('CALL_INTRINSIC_1', 173) def_op('CALL_INTRINSIC_2', 174) -name_op('LOAD_CLASS_OR_GLOBAL', 175) +name_op('LOAD_CLASSDICT_OR_GLOBAL', 175) +name_op('LOAD_CLASSDICT_OR_DEREF', 176) # Instrumented instructions MIN_INSTRUMENTED_OPCODE = 238 diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index e5b5cca2d6f9ad..0857a43a69a051 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -252,6 +252,16 @@ class Child[T](Base): pass """) exec(code, {}) + def test_class_deref(self): + code = textwrap.dedent("""\ + class C[T]: + T = "class" + type Alias = T + + assert C.Alias.__value__ == "class", repr(C.Alias) + """) + exec(code, {}) + def test_nonlocal(self): code = textwrap.dedent("""\ def outer2[T](): diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 241564a51dae5d..31fce8fbed2259 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1179,7 +1179,7 @@ dummy_func( } } - op(_LOAD_CLASS_OR_GLOBAL_INTRO, (-- class_dict, name)) { + op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (-- class_dict, name)) { name = GETITEM(frame->f_code->co_names, oparg); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; if (func == NULL) { @@ -1251,7 +1251,7 @@ dummy_func( macro(LOAD_NAME) = _LOAD_NAME_INTRO + _LOAD_NAME_COMMON; - macro(LOAD_CLASS_OR_GLOBAL) = _LOAD_CLASS_OR_GLOBAL_INTRO + _LOAD_NAME_COMMON; + macro(LOAD_CLASSDICT_OR_GLOBAL) = _LOAD_CLASSDICT_OR_GLOBAL_INTRO + _LOAD_NAME_COMMON; family(load_global, INLINE_CACHE_ENTRIES_LOAD_GLOBAL) = { LOAD_GLOBAL, @@ -1373,13 +1373,32 @@ dummy_func( Py_DECREF(oldobj); } - inst(LOAD_CLASSDEREF, ( -- value)) { - PyObject *name, *locals = LOCALS(); - assert(locals); + op(_LOAD_CLASSDEREF_INTRO, (-- class_dict)) { + class_dict = LOCALS(); + } + + op(_LOAD_CLASSDICT_OR_DEREF_INTRO, (-- class_dict)) { + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no function defined when loading from class dict"); + goto error; + } + class_dict = func->func_class_dict; + if (class_dict == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no class dict set when loading from class dict"); + goto error; + } + } + + op(_LOAD_CLASSDEREF_COMMON, (class_dict -- value)) { + PyObject *name; + assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); - if (PyDict_CheckExact(locals)) { - value = PyDict_GetItemWithError(locals, name); + if (PyDict_CheckExact(class_dict)) { + value = PyDict_GetItemWithError(class_dict, name); if (value != NULL) { Py_INCREF(value); } @@ -1388,7 +1407,7 @@ dummy_func( } } else { - value = PyObject_GetItem(locals, name); + value = PyObject_GetItem(class_dict, name); if (value == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { goto error; @@ -1407,6 +1426,9 @@ dummy_func( } } + macro(LOAD_CLASSDEREF) = _LOAD_CLASSDEREF_INTRO + _LOAD_CLASSDEREF_COMMON; + macro(LOAD_CLASSDICT_OR_DEREF) = _LOAD_CLASSDICT_OR_DEREF_INTRO + _LOAD_CLASSDEREF_COMMON; + inst(LOAD_DEREF, ( -- value)) { PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); diff --git a/Python/compile.c b/Python/compile.c index d8a356e1313a14..871a3784705ea4 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4037,7 +4037,15 @@ compiler_nameop(struct compiler *c, location loc, case OP_DEREF: switch (ctx) { case Load: - op = (c->u->u_ste->ste_type == ClassBlock) ? LOAD_CLASSDEREF : LOAD_DEREF; + if (c->u->u_ste->ste_type == ClassBlock) { + op = LOAD_CLASSDEREF; + } + else if (c->u->u_ste->ste_type_params_in_class) { + op = LOAD_CLASSDICT_OR_DEREF; + } + else { + op = LOAD_DEREF; + } break; case Store: op = STORE_DEREF; break; case Del: op = DELETE_DEREF; break; @@ -4055,7 +4063,7 @@ compiler_nameop(struct compiler *c, location loc, switch (ctx) { case Load: if (c->u->u_ste->ste_type_params_in_class) { - op = LOAD_CLASS_OR_GLOBAL; + op = LOAD_CLASSDICT_OR_GLOBAL; } else { op = LOAD_GLOBAL; } @@ -7195,6 +7203,7 @@ fix_cell_offsets(struct compiler_unit *u, basicblock *entryblock, int *fixedmap) case STORE_DEREF: case DELETE_DEREF: case LOAD_CLASSDEREF: + case LOAD_CLASSDICT_OR_DEREF: assert(oldoffset >= 0); assert(oldoffset < noffsets); assert(fixedmap[oldoffset] >= 0); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 45cd6e31d0a52e..89b545ebdabd44 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1703,7 +1703,7 @@ DISPATCH(); } - TARGET(LOAD_CLASS_OR_GLOBAL) { + TARGET(LOAD_CLASSDICT_OR_GLOBAL) { PyObject *_tmp_1; PyObject *_tmp_2; { @@ -1952,48 +1952,123 @@ } TARGET(LOAD_CLASSDEREF) { - PyObject *value; - #line 1377 "Python/bytecodes.c" - PyObject *name, *locals = LOCALS(); - assert(locals); - assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); - name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); - if (PyDict_CheckExact(locals)) { - value = PyDict_GetItemWithError(locals, name); - if (value != NULL) { + PyObject *_tmp_1; + { + PyObject *class_dict; + #line 1377 "Python/bytecodes.c" + class_dict = LOCALS(); + #line 1961 "Python/generated_cases.c.h" + _tmp_1 = class_dict; + } + { + PyObject *class_dict = _tmp_1; + PyObject *value; + #line 1396 "Python/bytecodes.c" + PyObject *name; + assert(class_dict); + assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); + name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); + if (PyDict_CheckExact(class_dict)) { + value = PyDict_GetItemWithError(class_dict, name); + if (value != NULL) { + Py_INCREF(value); + } + else if (_PyErr_Occurred(tstate)) { + goto error; + } + } + else { + value = PyObject_GetItem(class_dict, name); + if (value == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + goto error; + } + _PyErr_Clear(tstate); + } + } + if (!value) { + PyObject *cell = GETLOCAL(oparg); + value = PyCell_GET(cell); + if (value == NULL) { + format_exc_unbound(tstate, frame->f_code, oparg); + goto error; + } Py_INCREF(value); } - else if (_PyErr_Occurred(tstate)) { + #line 1999 "Python/generated_cases.c.h" + _tmp_1 = value; + } + STACK_GROW(1); + stack_pointer[-1] = _tmp_1; + DISPATCH(); + } + + TARGET(LOAD_CLASSDICT_OR_DEREF) { + PyObject *_tmp_1; + { + PyObject *class_dict; + #line 1381 "Python/bytecodes.c" + PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; + if (func == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no function defined when loading from class dict"); + goto error; + } + class_dict = func->func_class_dict; + if (class_dict == NULL) { + _PyErr_Format(tstate, PyExc_SystemError, + "no class dict set when loading from class dict"); goto error; } + #line 2024 "Python/generated_cases.c.h" + _tmp_1 = class_dict; } - else { - value = PyObject_GetItem(locals, name); - if (value == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + { + PyObject *class_dict = _tmp_1; + PyObject *value; + #line 1396 "Python/bytecodes.c" + PyObject *name; + assert(class_dict); + assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); + name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); + if (PyDict_CheckExact(class_dict)) { + value = PyDict_GetItemWithError(class_dict, name); + if (value != NULL) { + Py_INCREF(value); + } + else if (_PyErr_Occurred(tstate)) { goto error; } - _PyErr_Clear(tstate); } - } - if (!value) { - PyObject *cell = GETLOCAL(oparg); - value = PyCell_GET(cell); - if (value == NULL) { - format_exc_unbound(tstate, frame->f_code, oparg); - goto error; + else { + value = PyObject_GetItem(class_dict, name); + if (value == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + goto error; + } + _PyErr_Clear(tstate); + } } - Py_INCREF(value); + if (!value) { + PyObject *cell = GETLOCAL(oparg); + value = PyCell_GET(cell); + if (value == NULL) { + format_exc_unbound(tstate, frame->f_code, oparg); + goto error; + } + Py_INCREF(value); + } + #line 2062 "Python/generated_cases.c.h" + _tmp_1 = value; } - #line 1989 "Python/generated_cases.c.h" STACK_GROW(1); - stack_pointer[-1] = value; + stack_pointer[-1] = _tmp_1; DISPATCH(); } TARGET(LOAD_DEREF) { PyObject *value; - #line 1411 "Python/bytecodes.c" + #line 1467 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -2001,7 +2076,7 @@ if (true) goto error; } Py_INCREF(value); - #line 2005 "Python/generated_cases.c.h" + #line 2080 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -2009,18 +2084,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1421 "Python/bytecodes.c" + #line 1477 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2018 "Python/generated_cases.c.h" + #line 2093 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1428 "Python/bytecodes.c" + #line 1484 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2031,22 +2106,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2035 "Python/generated_cases.c.h" + #line 2110 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1441 "Python/bytecodes.c" + #line 1497 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2044 "Python/generated_cases.c.h" + #line 2119 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1443 "Python/bytecodes.c" + #line 1499 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2050 "Python/generated_cases.c.h" + #line 2125 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2056,10 +2131,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1447 "Python/bytecodes.c" + #line 1503 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2063 "Python/generated_cases.c.h" + #line 2138 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2069,10 +2144,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1452 "Python/bytecodes.c" + #line 1508 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2076 "Python/generated_cases.c.h" + #line 2151 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2082,7 +2157,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1457 "Python/bytecodes.c" + #line 1513 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2093,13 +2168,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2097 "Python/generated_cases.c.h" + #line 2172 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1468 "Python/bytecodes.c" + #line 1524 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2103 "Python/generated_cases.c.h" + #line 2178 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2108,13 +2183,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1475 "Python/bytecodes.c" + #line 1531 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2114 "Python/generated_cases.c.h" + #line 2189 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1477 "Python/bytecodes.c" + #line 1533 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2118 "Python/generated_cases.c.h" + #line 2193 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2122,7 +2197,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1481 "Python/bytecodes.c" + #line 1537 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2137,7 +2212,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2141 "Python/generated_cases.c.h" + #line 2216 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2147,7 +2222,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1498 "Python/bytecodes.c" + #line 1554 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2155,13 +2230,13 @@ if (map == NULL) goto error; - #line 2159 "Python/generated_cases.c.h" + #line 2234 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1506 "Python/bytecodes.c" + #line 1562 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2165 "Python/generated_cases.c.h" + #line 2240 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2169,7 +2244,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1510 "Python/bytecodes.c" + #line 1566 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2209,7 +2284,7 @@ Py_DECREF(ann_dict); } } - #line 2213 "Python/generated_cases.c.h" + #line 2288 "Python/generated_cases.c.h" DISPATCH(); } @@ -2217,7 +2292,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1552 "Python/bytecodes.c" + #line 1608 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2227,14 +2302,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2231 "Python/generated_cases.c.h" + #line 2306 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1562 "Python/bytecodes.c" + #line 1618 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2238 "Python/generated_cases.c.h" + #line 2313 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2242,7 +2317,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1566 "Python/bytecodes.c" + #line 1622 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2250,12 +2325,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2254 "Python/generated_cases.c.h" + #line 2329 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1574 "Python/bytecodes.c" + #line 1630 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2259 "Python/generated_cases.c.h" + #line 2334 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2263,17 +2338,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1580 "Python/bytecodes.c" + #line 1636 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2272 "Python/generated_cases.c.h" + #line 2347 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1585 "Python/bytecodes.c" + #line 1641 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2277 "Python/generated_cases.c.h" + #line 2352 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2283,13 +2358,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1592 "Python/bytecodes.c" + #line 1648 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2293 "Python/generated_cases.c.h" + #line 2368 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2303,7 +2378,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1606 "Python/bytecodes.c" + #line 1662 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2321,16 +2396,16 @@ // handle any case whose performance we care about PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2325 "Python/generated_cases.c.h" + #line 2400 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1624 "Python/bytecodes.c" + #line 1680 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2334 "Python/generated_cases.c.h" + #line 2409 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2348,7 +2423,7 @@ uint32_t class_version = read_u32(&next_instr[1].cache); uint32_t self_type_version = read_u32(&next_instr[3].cache); PyObject *method = read_obj(&next_instr[5].cache); - #line 1631 "Python/bytecodes.c" + #line 1687 "Python/bytecodes.c" DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); DEOPT_IF(((PyTypeObject *)class)->tp_version_tag != class_version, LOAD_SUPER_ATTR); @@ -2359,7 +2434,7 @@ Py_INCREF(res2); Py_DECREF(global_super); Py_DECREF(class); - #line 2363 "Python/generated_cases.c.h" + #line 2438 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2373,7 +2448,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1658 "Python/bytecodes.c" + #line 1714 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2407,9 +2482,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2411 "Python/generated_cases.c.h" + #line 2486 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1692 "Python/bytecodes.c" + #line 1748 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2418,12 +2493,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2422 "Python/generated_cases.c.h" + #line 2497 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1701 "Python/bytecodes.c" + #line 1757 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2427 "Python/generated_cases.c.h" + #line 2502 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2437,7 +2512,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1706 "Python/bytecodes.c" + #line 1762 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2450,7 +2525,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2454 "Python/generated_cases.c.h" + #line 2529 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2465,7 +2540,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1722 "Python/bytecodes.c" + #line 1778 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2478,7 +2553,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2482 "Python/generated_cases.c.h" + #line 2557 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2493,7 +2568,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1738 "Python/bytecodes.c" + #line 1794 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2520,7 +2595,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2524 "Python/generated_cases.c.h" + #line 2599 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2535,7 +2610,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1768 "Python/bytecodes.c" + #line 1824 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2545,7 +2620,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2549 "Python/generated_cases.c.h" + #line 2624 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2560,7 +2635,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1781 "Python/bytecodes.c" + #line 1837 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2572,7 +2647,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2576 "Python/generated_cases.c.h" + #line 2651 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2586,7 +2661,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1796 "Python/bytecodes.c" + #line 1852 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2610,7 +2685,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2614 "Python/generated_cases.c.h" + #line 2689 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2618,7 +2693,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1822 "Python/bytecodes.c" + #line 1878 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2644,7 +2719,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2648 "Python/generated_cases.c.h" + #line 2723 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2652,7 +2727,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1850 "Python/bytecodes.c" + #line 1906 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2670,7 +2745,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2674 "Python/generated_cases.c.h" + #line 2749 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2681,7 +2756,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1870 "Python/bytecodes.c" + #line 1926 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2720,7 +2795,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2724 "Python/generated_cases.c.h" + #line 2799 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2731,7 +2806,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1911 "Python/bytecodes.c" + #line 1967 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2741,7 +2816,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2745 "Python/generated_cases.c.h" + #line 2820 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2753,7 +2828,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1930 "Python/bytecodes.c" + #line 1986 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2766,12 +2841,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2770 "Python/generated_cases.c.h" + #line 2845 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1943 "Python/bytecodes.c" + #line 1999 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2775 "Python/generated_cases.c.h" + #line 2850 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2782,7 +2857,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1947 "Python/bytecodes.c" + #line 2003 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2794,7 +2869,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2798 "Python/generated_cases.c.h" + #line 2873 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2805,7 +2880,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1962 "Python/bytecodes.c" + #line 2018 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2821,7 +2896,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2825 "Python/generated_cases.c.h" + #line 2900 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2832,7 +2907,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1981 "Python/bytecodes.c" + #line 2037 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2845,7 +2920,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2849 "Python/generated_cases.c.h" + #line 2924 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2856,14 +2931,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 1996 "Python/bytecodes.c" + #line 2052 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2862 "Python/generated_cases.c.h" + #line 2937 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1998 "Python/bytecodes.c" + #line 2054 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2867 "Python/generated_cases.c.h" + #line 2942 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2873,15 +2948,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2002 "Python/bytecodes.c" + #line 2058 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2879 "Python/generated_cases.c.h" + #line 2954 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2004 "Python/bytecodes.c" + #line 2060 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2885 "Python/generated_cases.c.h" + #line 2960 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2892,12 +2967,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2009 "Python/bytecodes.c" + #line 2065 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2898 "Python/generated_cases.c.h" + #line 2973 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2011 "Python/bytecodes.c" + #line 2067 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2905,10 +2980,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2909 "Python/generated_cases.c.h" + #line 2984 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2019 "Python/bytecodes.c" + #line 2075 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2917,7 +2992,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2921 "Python/generated_cases.c.h" + #line 2996 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2927,21 +3002,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2030 "Python/bytecodes.c" + #line 2086 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 2934 "Python/generated_cases.c.h" + #line 3009 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2033 "Python/bytecodes.c" + #line 2089 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 2941 "Python/generated_cases.c.h" + #line 3016 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2038 "Python/bytecodes.c" + #line 2094 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2945 "Python/generated_cases.c.h" + #line 3020 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -2950,15 +3025,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2042 "Python/bytecodes.c" + #line 2098 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 2957 "Python/generated_cases.c.h" + #line 3032 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2045 "Python/bytecodes.c" + #line 2101 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2962 "Python/generated_cases.c.h" + #line 3037 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -2967,29 +3042,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2049 "Python/bytecodes.c" + #line 2105 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 2975 "Python/generated_cases.c.h" + #line 3050 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2055 "Python/bytecodes.c" + #line 2111 "Python/bytecodes.c" JUMPBY(oparg); - #line 2984 "Python/generated_cases.c.h" + #line 3059 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2059 "Python/bytecodes.c" + #line 2115 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 2993 "Python/generated_cases.c.h" + #line 3068 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -2997,7 +3072,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2065 "Python/bytecodes.c" + #line 2121 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3007,9 +3082,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3011 "Python/generated_cases.c.h" + #line 3086 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2075 "Python/bytecodes.c" + #line 2131 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3017,14 +3092,14 @@ if (err < 0) goto pop_1_error; } } - #line 3021 "Python/generated_cases.c.h" + #line 3096 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2085 "Python/bytecodes.c" + #line 2141 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3034,9 +3109,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3038 "Python/generated_cases.c.h" + #line 3113 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2095 "Python/bytecodes.c" + #line 2151 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3044,67 +3119,67 @@ if (err < 0) goto pop_1_error; } } - #line 3048 "Python/generated_cases.c.h" + #line 3123 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2105 "Python/bytecodes.c" + #line 2161 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3057 "Python/generated_cases.c.h" + #line 3132 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2107 "Python/bytecodes.c" + #line 2163 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3065 "Python/generated_cases.c.h" + #line 3140 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2115 "Python/bytecodes.c" + #line 2171 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3078 "Python/generated_cases.c.h" + #line 3153 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2121 "Python/bytecodes.c" + #line 2177 "Python/bytecodes.c" } - #line 3082 "Python/generated_cases.c.h" + #line 3157 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2125 "Python/bytecodes.c" + #line 2181 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3095 "Python/generated_cases.c.h" + #line 3170 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2134 "Python/bytecodes.c" + #line 2190 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3108 "Python/generated_cases.c.h" + #line 3183 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3115,16 +3190,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2142 "Python/bytecodes.c" + #line 2198 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3124 "Python/generated_cases.c.h" + #line 3199 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2147 "Python/bytecodes.c" + #line 2203 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3132,7 +3207,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3136 "Python/generated_cases.c.h" + #line 3211 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3141,10 +3216,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2157 "Python/bytecodes.c" + #line 2213 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3148 "Python/generated_cases.c.h" + #line 3223 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3154,10 +3229,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2163 "Python/bytecodes.c" + #line 2219 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3161 "Python/generated_cases.c.h" + #line 3236 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3168,11 +3243,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2169 "Python/bytecodes.c" + #line 2225 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3176 "Python/generated_cases.c.h" + #line 3251 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3181,14 +3256,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2175 "Python/bytecodes.c" + #line 2231 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3188 "Python/generated_cases.c.h" + #line 3263 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2178 "Python/bytecodes.c" + #line 2234 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3192 "Python/generated_cases.c.h" + #line 3267 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3196,7 +3271,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2182 "Python/bytecodes.c" + #line 2238 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3219,11 +3294,11 @@ if (iter == NULL) { goto error; } - #line 3223 "Python/generated_cases.c.h" + #line 3298 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2205 "Python/bytecodes.c" + #line 2261 "Python/bytecodes.c" } - #line 3227 "Python/generated_cases.c.h" + #line 3302 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3234,7 +3309,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2224 "Python/bytecodes.c" + #line 2280 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3265,7 +3340,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3269 "Python/generated_cases.c.h" + #line 3344 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3273,7 +3348,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2257 "Python/bytecodes.c" + #line 2313 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3299,14 +3374,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3303 "Python/generated_cases.c.h" + #line 3378 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2285 "Python/bytecodes.c" + #line 2341 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3326,7 +3401,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3330 "Python/generated_cases.c.h" + #line 3405 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3336,7 +3411,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2307 "Python/bytecodes.c" + #line 2363 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3356,7 +3431,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3360 "Python/generated_cases.c.h" + #line 3435 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3366,7 +3441,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2329 "Python/bytecodes.c" + #line 2385 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3384,7 +3459,7 @@ if (next == NULL) { goto error; } - #line 3388 "Python/generated_cases.c.h" + #line 3463 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3393,7 +3468,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2349 "Python/bytecodes.c" + #line 2405 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3408,14 +3483,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3412 "Python/generated_cases.c.h" + #line 3487 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2366 "Python/bytecodes.c" + #line 2422 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3438,16 +3513,16 @@ Py_DECREF(enter); goto error; } - #line 3442 "Python/generated_cases.c.h" + #line 3517 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2389 "Python/bytecodes.c" + #line 2445 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3451 "Python/generated_cases.c.h" + #line 3526 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3459,7 +3534,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2399 "Python/bytecodes.c" + #line 2455 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3485,16 +3560,16 @@ Py_DECREF(enter); goto error; } - #line 3489 "Python/generated_cases.c.h" + #line 3564 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2425 "Python/bytecodes.c" + #line 2481 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3498 "Python/generated_cases.c.h" + #line 3573 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3506,7 +3581,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2434 "Python/bytecodes.c" + #line 2490 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3527,7 +3602,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3531 "Python/generated_cases.c.h" + #line 3606 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3536,7 +3611,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2457 "Python/bytecodes.c" + #line 2513 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3546,7 +3621,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3550 "Python/generated_cases.c.h" + #line 3625 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3560,7 +3635,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2469 "Python/bytecodes.c" + #line 2525 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3577,7 +3652,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3581 "Python/generated_cases.c.h" + #line 3656 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3591,7 +3666,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2488 "Python/bytecodes.c" + #line 2544 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3601,7 +3676,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3605 "Python/generated_cases.c.h" + #line 3680 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3615,7 +3690,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2500 "Python/bytecodes.c" + #line 2556 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3629,7 +3704,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3633 "Python/generated_cases.c.h" + #line 3708 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3638,16 +3713,16 @@ } TARGET(KW_NAMES) { - #line 2516 "Python/bytecodes.c" + #line 2572 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3646 "Python/generated_cases.c.h" + #line 3721 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2522 "Python/bytecodes.c" + #line 2578 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3660,7 +3735,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3664 "Python/generated_cases.c.h" + #line 3739 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3670,7 +3745,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2567 "Python/bytecodes.c" + #line 2623 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3752,7 +3827,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3756 "Python/generated_cases.c.h" + #line 3831 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3764,7 +3839,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2655 "Python/bytecodes.c" + #line 2711 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3774,7 +3849,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3778 "Python/generated_cases.c.h" + #line 3853 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3783,7 +3858,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2667 "Python/bytecodes.c" + #line 2723 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3809,7 +3884,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3813 "Python/generated_cases.c.h" + #line 3888 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3817,7 +3892,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2695 "Python/bytecodes.c" + #line 2751 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3853,7 +3928,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3857 "Python/generated_cases.c.h" + #line 3932 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3861,7 +3936,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2733 "Python/bytecodes.c" + #line 2789 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3871,7 +3946,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3875 "Python/generated_cases.c.h" + #line 3950 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3884,7 +3959,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2745 "Python/bytecodes.c" + #line 2801 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3895,7 +3970,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3899 "Python/generated_cases.c.h" + #line 3974 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3909,7 +3984,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2759 "Python/bytecodes.c" + #line 2815 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3920,7 +3995,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3924 "Python/generated_cases.c.h" + #line 3999 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3934,7 +4009,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2773 "Python/bytecodes.c" + #line 2829 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3956,7 +4031,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3960 "Python/generated_cases.c.h" + #line 4035 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3970,7 +4045,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2798 "Python/bytecodes.c" + #line 2854 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -3998,7 +4073,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4002 "Python/generated_cases.c.h" + #line 4077 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4012,7 +4087,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2829 "Python/bytecodes.c" + #line 2885 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4044,7 +4119,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4048 "Python/generated_cases.c.h" + #line 4123 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4058,7 +4133,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2864 "Python/bytecodes.c" + #line 2920 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4090,7 +4165,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4094 "Python/generated_cases.c.h" + #line 4169 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4104,7 +4179,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2899 "Python/bytecodes.c" + #line 2955 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4129,7 +4204,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4133 "Python/generated_cases.c.h" + #line 4208 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4142,7 +4217,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2926 "Python/bytecodes.c" + #line 2982 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4169,7 +4244,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4173 "Python/generated_cases.c.h" + #line 4248 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4181,7 +4256,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2956 "Python/bytecodes.c" + #line 3012 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4199,14 +4274,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4203 "Python/generated_cases.c.h" + #line 4278 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2976 "Python/bytecodes.c" + #line 3032 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4237,7 +4312,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4241 "Python/generated_cases.c.h" + #line 4316 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4250,7 +4325,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3010 "Python/bytecodes.c" + #line 3066 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4279,7 +4354,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4283 "Python/generated_cases.c.h" + #line 4358 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4292,7 +4367,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3042 "Python/bytecodes.c" + #line 3098 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4321,7 +4396,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4325 "Python/generated_cases.c.h" + #line 4400 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4334,7 +4409,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3074 "Python/bytecodes.c" + #line 3130 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4362,7 +4437,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4366 "Python/generated_cases.c.h" + #line 4441 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4372,9 +4447,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3105 "Python/bytecodes.c" + #line 3161 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4378 "Python/generated_cases.c.h" + #line 4453 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4383,7 +4458,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3109 "Python/bytecodes.c" + #line 3165 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4426,14 +4501,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4430 "Python/generated_cases.c.h" + #line 4505 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3152 "Python/bytecodes.c" + #line 3208 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4437 "Python/generated_cases.c.h" + #line 4512 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4448,7 +4523,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3162 "Python/bytecodes.c" + #line 3218 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4477,14 +4552,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4481 "Python/generated_cases.c.h" + #line 4556 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3193 "Python/bytecodes.c" + #line 3249 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4505,7 +4580,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4509 "Python/generated_cases.c.h" + #line 4584 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4513,15 +4588,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3216 "Python/bytecodes.c" + #line 3272 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4519 "Python/generated_cases.c.h" + #line 4594 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3218 "Python/bytecodes.c" + #line 3274 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4525 "Python/generated_cases.c.h" + #line 4600 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4532,7 +4607,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3222 "Python/bytecodes.c" + #line 3278 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4567,7 +4642,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4571 "Python/generated_cases.c.h" + #line 4646 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4576,10 +4651,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3259 "Python/bytecodes.c" + #line 3315 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4583 "Python/generated_cases.c.h" + #line 4658 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4591,7 +4666,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3264 "Python/bytecodes.c" + #line 3320 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4606,12 +4681,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4610 "Python/generated_cases.c.h" + #line 4685 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3279 "Python/bytecodes.c" + #line 3335 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4615 "Python/generated_cases.c.h" + #line 4690 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4621,16 +4696,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3284 "Python/bytecodes.c" + #line 3340 "Python/bytecodes.c" assert(oparg >= 2); - #line 4627 "Python/generated_cases.c.h" + #line 4702 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3288 "Python/bytecodes.c" + #line 3344 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4650,11 +4725,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4654 "Python/generated_cases.c.h" + #line 4729 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3310 "Python/bytecodes.c" + #line 3366 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4666,26 +4741,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4670 "Python/generated_cases.c.h" + #line 4745 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3324 "Python/bytecodes.c" + #line 3380 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4676 "Python/generated_cases.c.h" + #line 4751 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3328 "Python/bytecodes.c" + #line 3384 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4683 "Python/generated_cases.c.h" + #line 4758 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3333 "Python/bytecodes.c" + #line 3389 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4694,12 +4769,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4698 "Python/generated_cases.c.h" + #line 4773 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3344 "Python/bytecodes.c" + #line 3400 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4708,12 +4783,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4712 "Python/generated_cases.c.h" + #line 4787 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3355 "Python/bytecodes.c" + #line 3411 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4726,12 +4801,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4730 "Python/generated_cases.c.h" + #line 4805 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3370 "Python/bytecodes.c" + #line 3426 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4744,30 +4819,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4748 "Python/generated_cases.c.h" + #line 4823 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3385 "Python/bytecodes.c" + #line 3441 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4759 "Python/generated_cases.c.h" + #line 4834 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3393 "Python/bytecodes.c" + #line 3449 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4766 "Python/generated_cases.c.h" + #line 4841 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3398 "Python/bytecodes.c" + #line 3454 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4773 "Python/generated_cases.c.h" + #line 4848 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 7e9508dd586f1d..ab61f6e1af1e31 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -163,7 +163,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 0; case LOAD_NAME: return 0+2; - case LOAD_CLASS_OR_GLOBAL: + case LOAD_CLASSDICT_OR_GLOBAL: return 0+2; case LOAD_GLOBAL: return 0; @@ -178,7 +178,9 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case DELETE_DEREF: return 0; case LOAD_CLASSDEREF: - return 0; + return 0+1; + case LOAD_CLASSDICT_OR_DEREF: + return 0+1; case LOAD_DEREF: return 0; case STORE_DEREF: @@ -555,7 +557,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case LOAD_NAME: return 2+1; - case LOAD_CLASS_OR_GLOBAL: + case LOAD_CLASSDICT_OR_GLOBAL: return 2+1; case LOAD_GLOBAL: return ((oparg & 1) ? 1 : 0) + 1; @@ -570,7 +572,9 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { case DELETE_DEREF: return 0; case LOAD_CLASSDEREF: - return 1; + return 1+1; + case LOAD_CLASSDICT_OR_DEREF: + return 1+1; case LOAD_DEREF: return 1; case STORE_DEREF: @@ -874,7 +878,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [STORE_GLOBAL] = { true, INSTR_FMT_IB }, [DELETE_GLOBAL] = { true, INSTR_FMT_IB }, [LOAD_NAME] = { true, INSTR_FMT_IB }, - [LOAD_CLASS_OR_GLOBAL] = { true, INSTR_FMT_IB }, + [LOAD_CLASSDICT_OR_GLOBAL] = { true, INSTR_FMT_IB }, [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 }, @@ -882,6 +886,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [MAKE_CELL] = { true, INSTR_FMT_IB }, [DELETE_DEREF] = { true, INSTR_FMT_IB }, [LOAD_CLASSDEREF] = { true, INSTR_FMT_IB }, + [LOAD_CLASSDICT_OR_DEREF] = { true, INSTR_FMT_IB }, [LOAD_DEREF] = { true, INSTR_FMT_IB }, [STORE_DEREF] = { true, INSTR_FMT_IB }, [COPY_FREE_VARS] = { true, INSTR_FMT_IB }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 8036bc9eec33c9..37b498959c2495 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -174,8 +174,8 @@ static void *opcode_targets[256] = { &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, - &&TARGET_LOAD_CLASS_OR_GLOBAL, - &&_unknown_opcode, + &&TARGET_LOAD_CLASSDICT_OR_GLOBAL, + &&TARGET_LOAD_CLASSDICT_OR_DEREF, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 21667d9b2b06acbe00fe8421d85aaef5f8d65604 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 12:37:01 -0600 Subject: [PATCH 123/200] Remove outdated comment --- Include/internal/pycore_symtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index b95e4c64e104d1..7ec9e6d2789d1e 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -51,7 +51,7 @@ typedef struct _symtable_entry { PyObject *ste_varnames; /* list of function parameters */ PyObject *ste_children; /* list of child blocks */ PyObject *ste_directives;/* locations of global and nonlocal statements */ - _Py_block_ty ste_type; /* module, class, function or annotation */ + _Py_block_ty ste_type; int ste_nested; /* true if block is nested */ unsigned ste_free : 1; /* true if block has free variables */ unsigned ste_child_free : 1; /* true if a child block has free vars, From e65d668152c144c540ed39086d3b7637afedaca9 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 12:43:42 -0600 Subject: [PATCH 124/200] Add helper function to tests --- Lib/test/test_type_params.py | 156 +++++++++++++++-------------------- 1 file changed, 65 insertions(+), 91 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 0857a43a69a051..e704578f7987a5 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -2,192 +2,180 @@ import textwrap import unittest -from typing import Sequence, TypeVar, TypeVarTuple, ParamSpec +from typing import Any, Sequence, TypeVar, TypeVarTuple, ParamSpec + + +def run_code(code: str) -> dict[str, Any]: + ns = {} + exec(textwrap.dedent(code), ns) + return ns class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): - code = """def func[**A, A](): ...""" with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): - exec(code, {}) + run_code("""def func[**A, A](): ...""") def test_name_non_collision_02(self): - code = """def func[A](A): ...""" - exec(code, {}) + run_code("""def func[A](A): ...""") def test_name_non_collision_03(self): - code = """def func[A](*A): ...""" - exec(code, {}) + run_code("""def func[A](*A): ...""") def test_name_non_collision_04(self): # Mangled names should not cause a conflict. - code = textwrap.dedent("""\ + run_code("""\ class ClassA: def func[__A](self, __A): ... """ ) - exec(code, {}) def test_name_non_collision_05(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA: def func[_ClassA__A](self, __A): ... """ ) - exec(code, {}) def test_name_non_collision_06(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[X]: def func(self, X): ... """ ) - exec(code, {}) def test_name_non_collision_07(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[X]: def func(self): X = 1 """ ) - exec(code, {}) def test_name_non_collision_08(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[X]: def func(self): a = [X for X in []] """ ) - exec(code, {}) def test_name_non_collision_9(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[X]: def func[X](self): ... """ ) - exec(code, {}) def test_name_non_collision_10(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[X]: X: int """ ) - exec(code, {}) def test_name_non_collision_11(self): - code = textwrap.dedent("""\ + run_code("""\ def outer(): X = 1 def inner[X](): nonlocal X """ ) - exec(code, {}) def test_name_non_collision_13(self): - code = textwrap.dedent("""\ + run_code("""\ X = 1 def outer(): def inner[X](): global X """ ) - exec(code, {}) def test_disallowed_expressions(self): with self.assertRaises(SyntaxError): - exec("type X = (yield)", {}) + run_code("type X = (yield)") with self.assertRaises(SyntaxError): - exec("type X = (yield from x)", {}) + run_code("type X = (yield from x)") with self.assertRaises(SyntaxError): - exec("type X = (await 42)", {}) + run_code("type X = (await 42)") with self.assertRaises(SyntaxError): - exec("async def f(): type X = (yield)", {}) + run_code("async def f(): type X = (yield)") with self.assertRaises(SyntaxError): - exec("type X = (y := 3)", {}) + run_code("type X = (y := 3)") with self.assertRaises(SyntaxError): - exec("class X[T: (yield)]: pass", {}) + run_code("class X[T: (yield)]: pass") with self.assertRaises(SyntaxError): - exec("class X[T: (yield from x)]: pass", {}) + run_code("class X[T: (yield from x)]: pass") with self.assertRaises(SyntaxError): - exec("class X[T: (await 42)]: pass", {}) + run_code("class X[T: (await 42)]: pass") with self.assertRaises(SyntaxError): - exec("class X[T: (y := 3)]: pass", {}) + run_code("class X[T: (y := 3)]: pass") with self.assertRaises(SyntaxError): - exec("class X[T](y := Sequence[T]): pass", {}) + run_code("class X[T](y := Sequence[T]): pass") with self.assertRaises(SyntaxError): - exec("def f[T](y: (x := Sequence[T])): pass", {}) + run_code("def f[T](y: (x := Sequence[T])): pass") class TypeParamsAccessTest(unittest.TestCase): def test_class_access_01(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[A, B](dict[A, B]): ... """ ) - exec(code, {}) def test_class_access_02(self): - code = textwrap.dedent("""\ + run_code("""\ class MyMeta[A, B](type): ... class ClassA[A, B](metaclass=MyMeta[A, B]): ... """ ) - exec(code, {}) def test_class_access_03(self): - code = textwrap.dedent("""\ + code = """\ def my_decorator(a): ... @my_decorator(A) class ClassA[A, B](): ... """ - ) with self.assertRaisesRegex(NameError, "name 'A' is not defined"): - exec(code, {}) + run_code(code) def test_function_access_01(self): - code = textwrap.dedent("""\ + run_code("""\ def func[A, B](a: dict[A, B]): ... """ ) - exec(code, {}) def test_function_access_02(self): - code = textwrap.dedent("""\ + code = """\ def func[A](a = list[A]()): ... """ - ) with self.assertRaisesRegex(NameError, "name 'A' is not defined"): - exec(code, {}) + run_code(code) def test_function_access_03(self): - code = textwrap.dedent("""\ + code = """\ def my_decorator(a): ... @my_decorator(A) def func[A](): ... """ - ) with self.assertRaisesRegex(NameError, "name 'A' is not defined"): - exec(code, {}) + run_code(code) def test_method_access_01(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA: x = int def func[T](self, a: x, b: T): @@ -196,10 +184,9 @@ def func[T](self, a: x, b: T): assert ClassA.func.__annotations__["a"] is int """ ) - exec(code, {}) def test_nested_access_01(self): - code = textwrap.dedent("""\ + run_code("""\ class ClassA[A]: def funcB[B](self): class ClassC[C]: @@ -207,42 +194,38 @@ def funcD[D](self): lambda : (A, B, C, D) """ ) - exec(code, {}) def test_out_of_scope_01(self): - code = textwrap.dedent("""\ + code = """\ class ClassA[T]: ... x = T """ - ) with self.assertRaisesRegex(NameError, "name 'T' is not defined"): - exec(code, {}) + run_code(code) def test_out_of_scope_02(self): - code = textwrap.dedent("""\ + code = """\ class ClassA[A]: def funcB[B](self): ... x = B """ - ) with self.assertRaisesRegex(NameError, "name 'B' is not defined"): - exec(code, {}) + run_code(code) def test_class_scope_interaction_01(self): - code = textwrap.dedent("""\ + run_code("""\ class C: x = 1 def method[T](self, arg: x): pass assert C.method.__annotations__["arg"] == 1 """) - exec(code, {}) def test_class_scope_interaction_02(self): - code = textwrap.dedent("""\ + run_code("""\ from typing import Generic class C: class Base: pass @@ -250,27 +233,25 @@ class Child[T](Base): pass assert C.Child.__bases__ == (C.Base, Generic) """) - exec(code, {}) def test_class_deref(self): - code = textwrap.dedent("""\ + run_code("""\ class C[T]: T = "class" type Alias = T assert C.Alias.__value__ == "class", repr(C.Alias) """) - exec(code, {}) def test_nonlocal(self): - code = textwrap.dedent("""\ + code = """\ def outer2[T](): def inner1(): nonlocal T - """) + """ with self.assertRaisesRegex(SyntaxError, "nonlocal binding not allowed for type parameter 'T'"): - exec(code, {}) + run_code(code) def test_reference_previous_typevar(self): def func[S, T: Sequence[S]](): @@ -322,7 +303,7 @@ class X: type U = T self.assertIs(X.U.__value__, int) - code = textwrap.dedent("""\ + run_code("""\ glb = "global" class X: cls = "class" @@ -330,7 +311,6 @@ class X: assert X.U.__value__ == ("global", "class"), X.U.__value__ """) - exec(code, {}) def test_bound(self): class X: @@ -338,7 +318,7 @@ class X: def foo[U: T](self): ... self.assertIs(X.foo.__type_params__[0].__bound__, int) - code = textwrap.dedent("""\ + run_code("""\ glb = "global" class X: cls = "class" @@ -348,7 +328,6 @@ def foo[T: glb, U: cls](self): ... assert T.__bound__ == "global" assert U.__bound__ == "class" """) - exec(code, {}) class ManglingTest(unittest.TestCase): @@ -376,14 +355,13 @@ def meth[__U](self, arg: __T, arg2: __U): class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): - code = textwrap.dedent("""\ - from typing import Generic - class ClassA[T](Generic[T]): ... + code = """\ + from typing import Generic + class ClassA[T](Generic[T]): ... """ - ) with self.assertRaisesRegex(TypeError, r"Cannot inherit from Generic\[...\] multiple types."): - exec(code, {}) + run_code(code) def test_traditional_02(self): from typing import TypeVar @@ -467,14 +445,13 @@ async def coroutine[B](): class TypeParamsTypeVarTupleTest(unittest.TestCase): def test_typevartuple_01(self): - code = textwrap.dedent("""\ + code = """\ def func1[*A: str](): return (A, B, C) """ - ) with self.assertRaisesRegex(SyntaxError, r"expected '\('"): - exec(code, {}) + run_code(code) def test_typevartuple_02(self): def func1[*A](): @@ -486,14 +463,13 @@ def func1[*A](): class TypeParamsTypeVarParamSpec(unittest.TestCase): def test_paramspec_01(self): - code = textwrap.dedent("""\ + code = """\ def func1[**A: str](): return (A, B, C) """ - ) with self.assertRaisesRegex(SyntaxError, r"expected '\('"): - exec(code, {}) + run_code(code) def test_paramspec_02(self): def func1[**A](): @@ -528,15 +504,14 @@ class ClassA: self.assertEqual(ClassA.__type_params__, ()) def test_typeparams_dunder_class_03(self): - code = textwrap.dedent("""\ + code = """\ class ClassA[A](): pass ClassA.__type_params__ = () """ - ) with self.assertRaisesRegex(AttributeError, "attribute '__type_params__' of 'type' objects is not writable"): - exec(code, {}) + run_code(code) def test_typeparams_dunder_function_01(self): def outer[A, B](): @@ -557,12 +532,11 @@ def func1(): self.assertEqual(func1.__type_params__, ()) def test_typeparams_dunder_function_03(self): - code = textwrap.dedent("""\ + code = """\ def func[A](): pass func.__type_params__ = () """ - ) with self.assertRaisesRegex(AttributeError, "attribute '__type_params__' of 'function' objects is not writable"): - exec(code, {}) + run_code(code) From e0a0b04cd17528ca1191aec1a98d7df11226e10c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:04:17 -0600 Subject: [PATCH 125/200] Expose TypeVar and friends through _typing --- Lib/test/test_typing.py | 40 +++++++------------------- Lib/typing.py | 64 ++++++++++++----------------------------- Modules/_typingmodule.c | 26 +++++++++++++++++ 3 files changed, 54 insertions(+), 76 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 2b012ecc6566f4..881be2477f0413 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -48,10 +48,6 @@ from test import _typed_dict_helper -py_typing = import_helper.import_fresh_module('typing', blocked=['_typing']) -c_typing = import_helper.import_fresh_module('typing', fresh=['_typing']) - - CANNOT_SUBCLASS_TYPE = 'Cannot subclass special typing classes' NOT_A_BASE_TYPE = "type 'typing.%s' is not an acceptable base type" CANNOT_SUBCLASS_INSTANCE = 'Cannot subclass an instance of %s' @@ -6434,34 +6430,27 @@ def foo(a: A) -> Optional[BaseException]: class TestModules(TestCase): func_names = ['_idfunc'] - def test_py_functions(self): - for fname in self.func_names: - self.assertEqual(getattr(py_typing, fname).__module__, 'typing') - - @skipUnless(c_typing, 'requires _typing') def test_c_functions(self): for fname in self.func_names: - self.assertEqual(getattr(c_typing, fname).__module__, '_typing') + self.assertEqual(getattr(typing, fname).__module__, '_typing') -class NewTypeTests: +class NewTypeTests(BaseTestCase): def cleanup(self): - for f in self.module._cleanups: + for f in typing._cleanups: f() @classmethod def setUpClass(cls): - sys.modules['typing'] = cls.module global UserId - UserId = cls.module.NewType('UserId', int) - cls.UserName = cls.module.NewType(cls.__qualname__ + '.UserName', str) + UserId = typing.NewType('UserId', int) + cls.UserName = typing.NewType(cls.__qualname__ + '.UserName', str) @classmethod def tearDownClass(cls): global UserId del UserId del cls.UserName - sys.modules['typing'] = typing def tearDown(self): self.cleanup() @@ -6481,11 +6470,11 @@ class D(UserId): def test_or(self): for cls in (int, self.UserName): with self.subTest(cls=cls): - self.assertEqual(UserId | cls, self.module.Union[UserId, cls]) - self.assertEqual(cls | UserId, self.module.Union[cls, UserId]) + self.assertEqual(UserId | cls, typing.Union[UserId, cls]) + self.assertEqual(cls | UserId, typing.Union[cls, UserId]) - self.assertEqual(self.module.get_args(UserId | cls), (UserId, cls)) - self.assertEqual(self.module.get_args(cls | UserId), (cls, UserId)) + self.assertEqual(typing.get_args(UserId | cls), (UserId, cls)) + self.assertEqual(typing.get_args(cls | UserId), (cls, UserId)) def test_special_attrs(self): self.assertEqual(UserId.__name__, 'UserId') @@ -6506,7 +6495,7 @@ def test_repr(self): f'{__name__}.{self.__class__.__qualname__}.UserName') def test_pickle(self): - UserAge = self.module.NewType('UserAge', float) + UserAge = typing.NewType('UserAge', float) for proto in range(pickle.HIGHEST_PROTOCOL + 1): with self.subTest(proto=proto): pickled = pickle.dumps(UserId, proto) @@ -6538,15 +6527,6 @@ class ProUserId(UserId): ... -class NewTypePythonTests(NewTypeTests, BaseTestCase): - module = py_typing - - -@skipUnless(c_typing, 'requires _typing') -class NewTypeCTests(NewTypeTests, BaseTestCase): - module = c_typing - - class NamedTupleTests(BaseTestCase): class NestedEmployee(NamedTuple): name: str diff --git a/Lib/typing.py b/Lib/typing.py index a73fe22d89a086..a2383ca1dc4db0 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -33,12 +33,16 @@ import warnings from types import WrapperDescriptorType, MethodWrapperType, MethodDescriptorType, GenericAlias - -try: - from _typing import _idfunc -except ImportError: - def _idfunc(_, x): - return x +from _typing import ( + _idfunc, + TypeVar, + ParamSpec, + TypeVarTuple, + ParamSpecArgs, + ParamSpecKwargs, + TypeAliasType, + Generic, +) # Please keep __all__ alphabetized within each category. __all__ = [ @@ -180,11 +184,7 @@ def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms= We append the repr() of the actual value (truncated to 100 chars). """ - try: - invalid_generic_forms = (Generic, Protocol) - except NameError: - # Run during interpreter startup - return arg + invalid_generic_forms = (Generic, Protocol) if not allow_special_forms: invalid_generic_forms += (ClassVar,) if is_argument: @@ -1022,11 +1022,7 @@ def _generic_class_getitem(cls, params): params = (params,) params = tuple(_type_convert(p) for p in params) - try: - is_generic_or_protocol = cls in (Generic, Protocol) - except NameError: - # Happens during interpreter startup - return _GenericAlias(cls, params, _paramspec_tvars=True) + is_generic_or_protocol = cls in (Generic, Protocol) if is_generic_or_protocol: # Generic and Protocol can only be subscripted with unique type variables. @@ -1062,18 +1058,12 @@ def _generic_class_getitem(cls, params): def _generic_init_subclass(cls, *args, **kwargs): - try: - generic_cls = Generic - except NameError: - # Happens during interpreter startup. We are creating - # the _Dummy class. - generic_cls = cls.__mro__[1] - super(generic_cls, cls).__init_subclass__(*args, **kwargs) + super(Generic, cls).__init_subclass__(*args, **kwargs) tvars = [] if '__orig_bases__' in cls.__dict__: - error = generic_cls in cls.__orig_bases__ + error = Generic in cls.__orig_bases__ else: - error = (generic_cls in cls.__bases__ and + error = (Generic in cls.__bases__ and cls.__name__ != 'Protocol' and type(cls) != _TypedDictMeta) if error: @@ -1088,7 +1078,7 @@ def _generic_init_subclass(cls, *args, **kwargs): gvars = None for base in cls.__orig_bases__: if (isinstance(base, _GenericAlias) and - base.__origin__ is generic_cls): + base.__origin__ is Generic): if gvars is not None: raise TypeError( "Cannot inherit from Generic[...] multiple types.") @@ -1394,12 +1384,7 @@ def __mro_entries__(self, bases): if self._name: # generic version of an ABC or built-in class return super().__mro_entries__(bases) - try: - is_Generic = self.__origin__ is Generic - except NameError: - # Happens during interpreter startup - return (self.__origin__,) - if is_Generic: + if self.__origin__ is Generic: if Protocol in bases: return () i = bases.index(self) @@ -1751,16 +1736,6 @@ def _lazy_load_getattr_static(): _cleanups.append(_lazy_load_getattr_static.cache_clear) -class _Dummy[T, *Ts, **P]: - pass - -TypeVar = type(_Dummy.__type_params__[0]) -TypeVarTuple = type(_Dummy.__type_params__[1]) -ParamSpec = type(_Dummy.__type_params__[2]) -ParamSpecArgs = type(ParamSpec("P").args) -ParamSpecKwargs = type(ParamSpec("P").kwargs) -Generic = _Dummy.__mro__[1] - def _pickle_psargs(psargs): return ParamSpecArgs, (psargs.__origin__,) @@ -1771,10 +1746,7 @@ def _pickle_pskwargs(pskwargs): copyreg.pickle(ParamSpecKwargs, _pickle_pskwargs) -type _Alias = int -TypeAliasType = type(_Alias) - -del _Dummy, _pickle_psargs, _pickle_pskwargs, _Alias +del _pickle_psargs, _pickle_pskwargs class _ProtocolMeta(ABCMeta): diff --git a/Modules/_typingmodule.c b/Modules/_typingmodule.c index 262dddb63fd5fe..9623336d70bb7b 100644 --- a/Modules/_typingmodule.c +++ b/Modules/_typingmodule.c @@ -1,6 +1,9 @@ /* typing accelerator C extension: _typing module. */ +#define Py_BUILD_CORE + #include "Python.h" +#include "internal/pycore_interp.h" #include "clinic/_typingmodule.c.h" /*[clinic input] @@ -35,7 +38,30 @@ static PyMethodDef typing_methods[] = { PyDoc_STRVAR(typing_doc, "Accelerators for the typing module.\n"); +static int +_typing_exec(PyObject *m) +{ + PyInterpreterState *interp = PyInterpreterState_Get(); + +#define EXPORT_TYPE(name, typename) \ + if (PyModule_AddObjectRef(m, name, \ + (PyObject *)interp->cached_objects.typename) < 0) { \ + return -1; \ + } + + EXPORT_TYPE("TypeVar", typevar_type); + EXPORT_TYPE("TypeVarTuple", typevartuple_type); + EXPORT_TYPE("ParamSpec", paramspec_type); + EXPORT_TYPE("ParamSpecArgs", paramspecargs_type); + EXPORT_TYPE("ParamSpecKwargs", paramspeckwargs_type); + EXPORT_TYPE("TypeAliasType", typealias_type); + EXPORT_TYPE("Generic", generic_type); +#undef EXPORT_TYPE + return 0; +} + static struct PyModuleDef_Slot _typingmodule_slots[] = { + {Py_mod_exec, _typing_exec}, {0, NULL} }; From d5c44f552645d3cf2a235b74e36619d1ba49ccb8 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:06:38 -0600 Subject: [PATCH 126/200] Remove unnecessary symtable entry --- Python/symtable.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Python/symtable.c b/Python/symtable.c index fefd3e7ed1a768..d71972f42af002 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1172,11 +1172,6 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, } if (current_type == ClassBlock) { st->st_cur->ste_type_params_in_class = 1; - _Py_DECLARE_STR(namespace, ".namespace"); - if (!symtable_add_def(st, &_Py_STR(namespace), DEF_PARAM, - lineno, col_offset, end_lineno, end_col_offset)) { - return 0; - } } if (kind == AsyncFunctionDef_kind || kind == FunctionDef_kind || kind == ClassDef_kind) { _Py_DECLARE_STR(type_params, ".type_params"); From ce6a990ade9348051e5d98d9683b93c97266480b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:10:18 -0600 Subject: [PATCH 127/200] Rename variable for clarity --- .../pycore_global_objects_fini_generated.h | 1 - Include/internal/pycore_global_strings.h | 1 - .../internal/pycore_runtime_init_generated.h | 1 - Python/bytecodes.c | 20 +- Python/generated_cases.c.h | 302 +++++++++--------- 5 files changed, 161 insertions(+), 164 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 2c1f38d290c970..c464c780531e7c 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -563,7 +563,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(json_decoder)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(kwdefaults)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(list_err)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(namespace)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(newline)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(open_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(percent)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 86aacddf81f55c..4ddcdd3ada68f1 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -48,7 +48,6 @@ struct _Py_global_strings { STRUCT_FOR_STR(json_decoder, "json.decoder") STRUCT_FOR_STR(kwdefaults, ".kwdefaults") STRUCT_FOR_STR(list_err, "list index out of range") - STRUCT_FOR_STR(namespace, ".namespace") STRUCT_FOR_STR(newline, "\n") STRUCT_FOR_STR(open_br, "{") STRUCT_FOR_STR(percent, "%") diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index b1644bcd827ff7..8b7be4f2da0666 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -554,7 +554,6 @@ extern "C" { INIT_STR(json_decoder, "json.decoder"), \ INIT_STR(kwdefaults, ".kwdefaults"), \ INIT_STR(list_err, "list index out of range"), \ - INIT_STR(namespace, ".namespace"), \ INIT_STR(newline, "\n"), \ INIT_STR(open_br, "{"), \ INIT_STR(percent, "%"), \ diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 31fce8fbed2259..fff0dc214b6843 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1169,17 +1169,17 @@ dummy_func( } } - op(_LOAD_NAME_INTRO, (-- class_dict, name)) { + op(_LOAD_NAME_INTRO, (-- mad_or_class_dict, name)) { name = GETITEM(frame->f_code->co_names, oparg); - class_dict = LOCALS(); - if (class_dict == NULL) { + mad_or_class_dict = LOCALS(); + if (mad_or_class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals when loading %R", name); goto error; } } - op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (-- class_dict, name)) { + op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (-- mad_or_class_dict, name)) { name = GETITEM(frame->f_code->co_names, oparg); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; if (func == NULL) { @@ -1187,17 +1187,17 @@ dummy_func( "no function defined when loading %R from class dict", name); goto error; } - class_dict = func->func_class_dict; - if (class_dict == NULL) { + mad_or_class_dict = func->func_class_dict; + if (mad_or_class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no class dict set when loading %R", name); goto error; } } - op(_LOAD_NAME_COMMON, (class_dict, name -- v)) { - if (PyDict_CheckExact(class_dict)) { - v = PyDict_GetItemWithError(class_dict, name); + op(_LOAD_NAME_COMMON, (mad_or_class_dict, name -- v)) { + if (PyDict_CheckExact(mad_or_class_dict)) { + v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } @@ -1206,7 +1206,7 @@ dummy_func( } } else { - v = PyObject_GetItem(class_dict, name); + v = PyObject_GetItem(mad_or_class_dict, name); if (v == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 89b545ebdabd44..91de2e4acf17d9 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1625,27 +1625,27 @@ PyObject *_tmp_1; PyObject *_tmp_2; { - PyObject *class_dict; + PyObject *mad_or_class_dict; PyObject *name; #line 1173 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); - class_dict = LOCALS(); - if (class_dict == NULL) { + mad_or_class_dict = LOCALS(); + if (mad_or_class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals when loading %R", name); goto error; } #line 1639 "Python/generated_cases.c.h" - _tmp_2 = class_dict; + _tmp_2 = mad_or_class_dict; _tmp_1 = name; } { PyObject *name = _tmp_1; - PyObject *class_dict = _tmp_2; + PyObject *mad_or_class_dict = _tmp_2; PyObject *v; #line 1199 "Python/bytecodes.c" - if (PyDict_CheckExact(class_dict)) { - v = PyDict_GetItemWithError(class_dict, name); + if (PyDict_CheckExact(mad_or_class_dict)) { + v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } @@ -1654,7 +1654,7 @@ } } else { - v = PyObject_GetItem(class_dict, name); + v = PyObject_GetItem(mad_or_class_dict, name); if (v == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; @@ -1707,7 +1707,7 @@ PyObject *_tmp_1; PyObject *_tmp_2; { - PyObject *class_dict; + PyObject *mad_or_class_dict; PyObject *name; #line 1183 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); @@ -1717,23 +1717,23 @@ "no function defined when loading %R from class dict", name); goto error; } - class_dict = func->func_class_dict; - if (class_dict == NULL) { + mad_or_class_dict = func->func_class_dict; + if (mad_or_class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no class dict set when loading %R", name); goto error; } #line 1727 "Python/generated_cases.c.h" - _tmp_2 = class_dict; + _tmp_2 = mad_or_class_dict; _tmp_1 = name; } { PyObject *name = _tmp_1; - PyObject *class_dict = _tmp_2; + PyObject *mad_or_class_dict = _tmp_2; PyObject *v; #line 1199 "Python/bytecodes.c" - if (PyDict_CheckExact(class_dict)) { - v = PyDict_GetItemWithError(class_dict, name); + if (PyDict_CheckExact(mad_or_class_dict)) { + v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } @@ -1742,7 +1742,7 @@ } } else { - v = PyObject_GetItem(class_dict, name); + v = PyObject_GetItem(mad_or_class_dict, name); if (v == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; @@ -2068,7 +2068,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1467 "Python/bytecodes.c" + #line 1433 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -2084,7 +2084,7 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1477 "Python/bytecodes.c" + #line 1443 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); @@ -2095,7 +2095,7 @@ } TARGET(COPY_FREE_VARS) { - #line 1484 "Python/bytecodes.c" + #line 1450 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2113,13 +2113,13 @@ TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1497 "Python/bytecodes.c" + #line 1463 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); #line 2119 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1499 "Python/bytecodes.c" + #line 1465 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } #line 2125 "Python/generated_cases.c.h" STACK_SHRINK(oparg); @@ -2131,7 +2131,7 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1503 "Python/bytecodes.c" + #line 1469 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } #line 2138 "Python/generated_cases.c.h" @@ -2144,7 +2144,7 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1508 "Python/bytecodes.c" + #line 1474 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } #line 2151 "Python/generated_cases.c.h" @@ -2157,7 +2157,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1513 "Python/bytecodes.c" + #line 1479 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2170,7 +2170,7 @@ } #line 2172 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1524 "Python/bytecodes.c" + #line 1490 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); @@ -2183,11 +2183,11 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1531 "Python/bytecodes.c" + #line 1497 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); #line 2189 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1533 "Python/bytecodes.c" + #line 1499 "Python/bytecodes.c" if (err < 0) goto pop_1_error; #line 2193 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2197,7 +2197,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1537 "Python/bytecodes.c" + #line 1503 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2222,7 +2222,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1554 "Python/bytecodes.c" + #line 1520 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2234,7 +2234,7 @@ for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1562 "Python/bytecodes.c" + #line 1528 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } #line 2240 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); @@ -2244,7 +2244,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1566 "Python/bytecodes.c" + #line 1532 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2292,7 +2292,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1608 "Python/bytecodes.c" + #line 1574 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2307,7 +2307,7 @@ Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1618 "Python/bytecodes.c" + #line 1584 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } #line 2313 "Python/generated_cases.c.h" STACK_SHRINK(oparg); @@ -2317,7 +2317,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1622 "Python/bytecodes.c" + #line 1588 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2327,7 +2327,7 @@ } #line 2329 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1630 "Python/bytecodes.c" + #line 1596 "Python/bytecodes.c" if (true) goto pop_1_error; } #line 2334 "Python/generated_cases.c.h" @@ -2338,14 +2338,14 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1636 "Python/bytecodes.c" + #line 1602 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); #line 2347 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1641 "Python/bytecodes.c" + #line 1607 "Python/bytecodes.c" if (true) goto pop_1_error; } #line 2352 "Python/generated_cases.c.h" @@ -2358,7 +2358,7 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1648 "Python/bytecodes.c" + #line 1614 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ @@ -2378,7 +2378,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1662 "Python/bytecodes.c" + #line 1628 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2400,7 +2400,7 @@ Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1680 "Python/bytecodes.c" + #line 1646 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); @@ -2423,7 +2423,7 @@ uint32_t class_version = read_u32(&next_instr[1].cache); uint32_t self_type_version = read_u32(&next_instr[3].cache); PyObject *method = read_obj(&next_instr[5].cache); - #line 1687 "Python/bytecodes.c" + #line 1653 "Python/bytecodes.c" DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); DEOPT_IF(((PyTypeObject *)class)->tp_version_tag != class_version, LOAD_SUPER_ATTR); @@ -2448,7 +2448,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1714 "Python/bytecodes.c" + #line 1680 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2484,7 +2484,7 @@ */ #line 2486 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1748 "Python/bytecodes.c" + #line 1714 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2495,7 +2495,7 @@ res = PyObject_GetAttr(owner, name); #line 2497 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1757 "Python/bytecodes.c" + #line 1723 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } #line 2502 "Python/generated_cases.c.h" @@ -2512,7 +2512,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1762 "Python/bytecodes.c" + #line 1728 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2540,7 +2540,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1778 "Python/bytecodes.c" + #line 1744 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2568,7 +2568,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1794 "Python/bytecodes.c" + #line 1760 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2610,7 +2610,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1824 "Python/bytecodes.c" + #line 1790 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2635,7 +2635,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1837 "Python/bytecodes.c" + #line 1803 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2661,7 +2661,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1852 "Python/bytecodes.c" + #line 1818 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2693,7 +2693,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1878 "Python/bytecodes.c" + #line 1844 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2727,7 +2727,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1906 "Python/bytecodes.c" + #line 1872 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2756,7 +2756,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1926 "Python/bytecodes.c" + #line 1892 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2806,7 +2806,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1967 "Python/bytecodes.c" + #line 1933 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2828,7 +2828,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1986 "Python/bytecodes.c" + #line 1952 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2844,7 +2844,7 @@ #line 2845 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1999 "Python/bytecodes.c" + #line 1965 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 2850 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2857,7 +2857,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2003 "Python/bytecodes.c" + #line 1969 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2880,7 +2880,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2018 "Python/bytecodes.c" + #line 1984 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2907,7 +2907,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2037 "Python/bytecodes.c" + #line 2003 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2931,12 +2931,12 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2052 "Python/bytecodes.c" + #line 2018 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; #line 2937 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2054 "Python/bytecodes.c" + #line 2020 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); #line 2942 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -2948,12 +2948,12 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2058 "Python/bytecodes.c" + #line 2024 "Python/bytecodes.c" int res = PySequence_Contains(right, left); #line 2954 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2060 "Python/bytecodes.c" + #line 2026 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); #line 2960 "Python/generated_cases.c.h" @@ -2967,12 +2967,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2065 "Python/bytecodes.c" + #line 2031 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { #line 2973 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2067 "Python/bytecodes.c" + #line 2033 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2983,7 +2983,7 @@ #line 2984 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2075 "Python/bytecodes.c" + #line 2041 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -3002,19 +3002,19 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2086 "Python/bytecodes.c" + #line 2052 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { #line 3009 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2089 "Python/bytecodes.c" + #line 2055 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); #line 3016 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2094 "Python/bytecodes.c" + #line 2060 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); #line 3020 "Python/generated_cases.c.h" stack_pointer[-1] = b; @@ -3025,13 +3025,13 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2098 "Python/bytecodes.c" + #line 2064 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); #line 3032 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2101 "Python/bytecodes.c" + #line 2067 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 3037 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -3042,7 +3042,7 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2105 "Python/bytecodes.c" + #line 2071 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; @@ -3053,7 +3053,7 @@ } TARGET(JUMP_FORWARD) { - #line 2111 "Python/bytecodes.c" + #line 2077 "Python/bytecodes.c" JUMPBY(oparg); #line 3059 "Python/generated_cases.c.h" DISPATCH(); @@ -3061,7 +3061,7 @@ TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2115 "Python/bytecodes.c" + #line 2081 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); #line 3068 "Python/generated_cases.c.h" @@ -3072,7 +3072,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2121 "Python/bytecodes.c" + #line 2087 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3084,7 +3084,7 @@ int err = PyObject_IsTrue(cond); #line 3086 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2131 "Python/bytecodes.c" + #line 2097 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3099,7 +3099,7 @@ TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2141 "Python/bytecodes.c" + #line 2107 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3111,7 +3111,7 @@ int err = PyObject_IsTrue(cond); #line 3113 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2151 "Python/bytecodes.c" + #line 2117 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3126,11 +3126,11 @@ TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2161 "Python/bytecodes.c" + #line 2127 "Python/bytecodes.c" if (!Py_IsNone(value)) { #line 3132 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2163 "Python/bytecodes.c" + #line 2129 "Python/bytecodes.c" JUMPBY(oparg); } else { @@ -3143,7 +3143,7 @@ TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2171 "Python/bytecodes.c" + #line 2137 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); @@ -3151,7 +3151,7 @@ else { #line 3153 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2177 "Python/bytecodes.c" + #line 2143 "Python/bytecodes.c" } #line 3157 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -3159,7 +3159,7 @@ } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2181 "Python/bytecodes.c" + #line 2147 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. @@ -3173,7 +3173,7 @@ TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2190 "Python/bytecodes.c" + #line 2156 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; @@ -3190,7 +3190,7 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2198 "Python/bytecodes.c" + #line 2164 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); @@ -3199,7 +3199,7 @@ Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2203 "Python/bytecodes.c" + #line 2169 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3216,7 +3216,7 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2213 "Python/bytecodes.c" + #line 2179 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); #line 3223 "Python/generated_cases.c.h" @@ -3229,7 +3229,7 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2219 "Python/bytecodes.c" + #line 2185 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); #line 3236 "Python/generated_cases.c.h" @@ -3243,7 +3243,7 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2225 "Python/bytecodes.c" + #line 2191 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; @@ -3256,12 +3256,12 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2231 "Python/bytecodes.c" + #line 2197 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); #line 3263 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2234 "Python/bytecodes.c" + #line 2200 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; #line 3267 "Python/generated_cases.c.h" stack_pointer[-1] = iter; @@ -3271,7 +3271,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2238 "Python/bytecodes.c" + #line 2204 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3296,7 +3296,7 @@ } #line 3298 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2261 "Python/bytecodes.c" + #line 2227 "Python/bytecodes.c" } #line 3302 "Python/generated_cases.c.h" stack_pointer[-1] = iter; @@ -3309,7 +3309,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2280 "Python/bytecodes.c" + #line 2246 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3348,7 +3348,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2313 "Python/bytecodes.c" + #line 2279 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3381,7 +3381,7 @@ TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2341 "Python/bytecodes.c" + #line 2307 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3411,7 +3411,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2363 "Python/bytecodes.c" + #line 2329 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3441,7 +3441,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2385 "Python/bytecodes.c" + #line 2351 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3468,7 +3468,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2405 "Python/bytecodes.c" + #line 2371 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3490,7 +3490,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2422 "Python/bytecodes.c" + #line 2388 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3515,7 +3515,7 @@ } #line 3517 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2445 "Python/bytecodes.c" + #line 2411 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { @@ -3534,7 +3534,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2455 "Python/bytecodes.c" + #line 2421 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3562,7 +3562,7 @@ } #line 3564 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2481 "Python/bytecodes.c" + #line 2447 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { @@ -3581,7 +3581,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2490 "Python/bytecodes.c" + #line 2456 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3611,7 +3611,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2513 "Python/bytecodes.c" + #line 2479 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3635,7 +3635,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2525 "Python/bytecodes.c" + #line 2491 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3666,7 +3666,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2544 "Python/bytecodes.c" + #line 2510 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3690,7 +3690,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2556 "Python/bytecodes.c" + #line 2522 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3713,7 +3713,7 @@ } TARGET(KW_NAMES) { - #line 2572 "Python/bytecodes.c" + #line 2538 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); @@ -3722,7 +3722,7 @@ } TARGET(INSTRUMENTED_CALL) { - #line 2578 "Python/bytecodes.c" + #line 2544 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3745,7 +3745,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2623 "Python/bytecodes.c" + #line 2589 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3839,7 +3839,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2711 "Python/bytecodes.c" + #line 2677 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3858,7 +3858,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2723 "Python/bytecodes.c" + #line 2689 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3892,7 +3892,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2751 "Python/bytecodes.c" + #line 2717 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3936,7 +3936,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2789 "Python/bytecodes.c" + #line 2755 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3959,7 +3959,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2801 "Python/bytecodes.c" + #line 2767 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3984,7 +3984,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2815 "Python/bytecodes.c" + #line 2781 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4009,7 +4009,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2829 "Python/bytecodes.c" + #line 2795 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4045,7 +4045,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2854 "Python/bytecodes.c" + #line 2820 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4087,7 +4087,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2885 "Python/bytecodes.c" + #line 2851 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4133,7 +4133,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2920 "Python/bytecodes.c" + #line 2886 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4179,7 +4179,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2955 "Python/bytecodes.c" + #line 2921 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4217,7 +4217,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2982 "Python/bytecodes.c" + #line 2948 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4256,7 +4256,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3012 "Python/bytecodes.c" + #line 2978 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4281,7 +4281,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3032 "Python/bytecodes.c" + #line 2998 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4325,7 +4325,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3066 "Python/bytecodes.c" + #line 3032 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4367,7 +4367,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3098 "Python/bytecodes.c" + #line 3064 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4409,7 +4409,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3130 "Python/bytecodes.c" + #line 3096 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4447,7 +4447,7 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3161 "Python/bytecodes.c" + #line 3127 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); #line 4453 "Python/generated_cases.c.h" } @@ -4458,7 +4458,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3165 "Python/bytecodes.c" + #line 3131 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4505,7 +4505,7 @@ Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3208 "Python/bytecodes.c" + #line 3174 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } #line 4512 "Python/generated_cases.c.h" @@ -4523,7 +4523,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3218 "Python/bytecodes.c" + #line 3184 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4559,7 +4559,7 @@ } TARGET(RETURN_GENERATOR) { - #line 3249 "Python/bytecodes.c" + #line 3215 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4588,13 +4588,13 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3272 "Python/bytecodes.c" + #line 3238 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); #line 4594 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3274 "Python/bytecodes.c" + #line 3240 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } #line 4600 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); @@ -4607,7 +4607,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3278 "Python/bytecodes.c" + #line 3244 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4651,7 +4651,7 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3315 "Python/bytecodes.c" + #line 3281 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); #line 4658 "Python/generated_cases.c.h" @@ -4666,7 +4666,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3320 "Python/bytecodes.c" + #line 3286 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4684,7 +4684,7 @@ #line 4685 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3335 "Python/bytecodes.c" + #line 3301 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; #line 4690 "Python/generated_cases.c.h" STACK_SHRINK(1); @@ -4696,7 +4696,7 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3340 "Python/bytecodes.c" + #line 3306 "Python/bytecodes.c" assert(oparg >= 2); #line 4702 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; @@ -4705,7 +4705,7 @@ } TARGET(INSTRUMENTED_LINE) { - #line 3344 "Python/bytecodes.c" + #line 3310 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4729,7 +4729,7 @@ } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3366 "Python/bytecodes.c" + #line 3332 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4745,14 +4745,14 @@ } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3380 "Python/bytecodes.c" + #line 3346 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); #line 4751 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3384 "Python/bytecodes.c" + #line 3350 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); #line 4758 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); @@ -4760,7 +4760,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3389 "Python/bytecodes.c" + #line 3355 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4774,7 +4774,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3400 "Python/bytecodes.c" + #line 3366 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4788,7 +4788,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3411 "Python/bytecodes.c" + #line 3377 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4806,7 +4806,7 @@ } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3426 "Python/bytecodes.c" + #line 3392 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4824,7 +4824,7 @@ } TARGET(EXTENDED_ARG) { - #line 3441 "Python/bytecodes.c" + #line 3407 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; @@ -4834,14 +4834,14 @@ } TARGET(CACHE) { - #line 3449 "Python/bytecodes.c" + #line 3415 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); #line 4841 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3454 "Python/bytecodes.c" + #line 3420 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); #line 4848 "Python/generated_cases.c.h" From 2fc9cc715a3f0d64569ff0aba5d4fd757c139a01 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:14:12 -0600 Subject: [PATCH 128/200] fix shadowed test --- Lib/test/test_type_aliases.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 30e9d1db07e04d..2c8ee89a317fef 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -67,18 +67,20 @@ def test_alias_value_01(self): self.assertEqual(TA2.__parameters__, ()) self.assertEqual(TA2.__type_params__, ()) - def test_alias_access_02(self): + def test_alias_value_02(self): class Parent[A]: type TA1[B] = dict[A, B] self.assertIsInstance(Parent.TA1, TypeAliasType) self.assertEqual(len(Parent.TA1.__parameters__), 1) self.assertEqual(len(Parent.__parameters__), 1) - a = Parent.__parameters__[0] - b = Parent.TA1.__parameters__[0] - self.assertEqual(Parent.TA1.__type_params__, (a, b)) + a, = Parent.__parameters__ + b, = Parent.TA1.__parameters__ + self.assertEqual(Parent.__parameters__, (a,)) + self.assertEqual(Parent.TA1.__type_params__, (b,)) + self.assertEqual(Parent.TA1.__value__, dict[a, b]) - def test_alias_access_02(self): + def test_alias_value_03(self): def outer[A](): type TA1[B] = dict[A, B] return TA1 From 3f7191108ef65a4e71169c57d4fc5ea58d5a777a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:15:51 -0600 Subject: [PATCH 129/200] Use run_code in test_type_aliases too --- Lib/test/test_type_aliases.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 2c8ee89a317fef..7e645a4eed75d0 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -1,52 +1,47 @@ -import textwrap import types import unittest from typing import Callable, TypeAliasType +from .test_type_params import run_code + + class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): - code = """type TA1[A, **A] = None""" - with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): - exec(code, {}, {}) + run_code("""type TA1[A, **A] = None""") def test_name_non_collision_02(self): - code = """type TA1[A] = lambda A: None""" - exec(code, {}, {}) + run_code("""type TA1[A] = lambda A: None""") def test_name_non_collision_03(self): - code = textwrap.dedent("""\ + run_code("""\ class Outer[A]: type TA1[A] = None """ ) - exec(code, {}, {}) class TypeParamsAccessTest(unittest.TestCase): def test_alias_access_01(self): - code = textwrap.dedent("""\ + run_code("""\ type TA1[A, B] = dict[A, B] """ ) - exec(code, {}, {}) def test_alias_access_02(self): - code = textwrap.dedent("""\ + run_code("""\ type TA1[A, B] = TA1[A, B] | int """ ) - exec(code, {}, {}) def test_alias_access_03(self): - code = textwrap.dedent("""\ + run_code("""\ class Outer[A]: def inner[B](self): type TA1[C] = TA1[A, B] | int """ ) - exec(code, {}, {}) class TypeParamsAliasValueTest(unittest.TestCase): From 0891a61e9d94f8d23cbbfcfcc1c149fbd7f1a24c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:18:35 -0600 Subject: [PATCH 130/200] Update NEWS --- .../2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst index 09f2de23ae14e2..cefe6429ab2041 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst @@ -16,7 +16,8 @@ This node holds instances of the new AST classes ``ast.TypeVar``, ``typing.ParamSpecKwargs``, ``typing.TypeVarTuple``, and ``typing.Generic`` are now implemented in C rather than Python. -There are new bytecode instructions ``LOAD_LOCALS`` and ``LOAD_CLASS_OR_GLOBAL`` +There are new bytecode instructions ``LOAD_LOCALS``, +``LOAD_CLASSDICT_OR_GLOBAL``, and ``LOAD_CLASSDICT_OR_DEREF`` to support correct resolution of names in class namespaces. Patch by Eric Traut, Larry Hastings, and Jelle Zijlstra. From 78a9ba2ca3708e85e83bbed013ffb4e26c08d6bf Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:19:34 -0600 Subject: [PATCH 131/200] type is a soft keyword too --- Lib/keyword.py | 2 +- Lib/test/test_keyword.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/keyword.py b/Lib/keyword.py index e22c837835e740..ac737d7e703445 100644 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -57,7 +57,7 @@ '_', 'case', 'match', - 'type' + 'type', ] iskeyword = frozenset(kwlist).__contains__ diff --git a/Lib/test/test_keyword.py b/Lib/test/test_keyword.py index f329f88fa01d51..858e5de3b92e6a 100644 --- a/Lib/test/test_keyword.py +++ b/Lib/test/test_keyword.py @@ -39,7 +39,8 @@ def test_async_and_await_are_keywords(self): self.assertIn("async", keyword.kwlist) self.assertIn("await", keyword.kwlist) - def test_match_and_case_are_soft_keywords(self): + def test_soft_keywords(self): + self.assertIn("type", keyword.softkwlist) self.assertIn("match", keyword.softkwlist) self.assertIn("case", keyword.softkwlist) self.assertIn("_", keyword.softkwlist) From c0b45e1caabc55a0aaa6db04f01b0836be79c3e6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:24:27 -0600 Subject: [PATCH 132/200] add to test_ast --- Lib/test/test_ast.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index caf713bd9f333f..0e57ffbff9b852 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -179,7 +179,22 @@ def to_tuple(t): "def f(a=1, /, b=2, *, c): pass", "def f(a=1, /, b=2, *, c=4, **kwargs): pass", "def f(a=1, /, b=2, *, c, **kwargs): pass", - + # Type aliases + "type X = int", + "type X[T] = int", + "type X[T, *Ts, **P] = (T, Ts, P)", + "type X[T: int, *Ts, **P] = (T, Ts, P)", + "type X[T: (int, str), *Ts, **P] = (T, Ts, P)", + # Generic classes + "class X[T]: pass", + "class X[T, *Ts, **P]: pass", + "class X[T: int, *Ts, **P]: pass", + "class X[T: (int, str), *Ts, **P]: pass", + # Generic functions + "def f[T](): pass", + "def f[T, *Ts, **P](): pass", + "def f[T: int, *Ts, **P](): pass", + "def f[T: (int, str), *Ts, **P](): pass", ] # These are compiled through "single" @@ -260,7 +275,6 @@ def to_tuple(t): "()", # Combination "a.b.c.d(a.b[1:2])", - ] # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension @@ -2684,6 +2698,19 @@ def main(): ('Module', [('FunctionDef', (1, 0, 1, 30), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [None], None, [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 26, 1, 30))], [], None, None)], []), ('Module', [('FunctionDef', (1, 0, 1, 42), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [('Constant', (1, 24, 1, 25), 4, None)], ('arg', (1, 29, 1, 35), 'kwargs', None, None), [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 38, 1, 42))], [], None, None)], []), ('Module', [('FunctionDef', (1, 0, 1, 40), 'f', [], ('arguments', [('arg', (1, 6, 1, 7), 'a', None, None)], [('arg', (1, 14, 1, 15), 'b', None, None)], None, [('arg', (1, 22, 1, 23), 'c', None, None)], [None], ('arg', (1, 27, 1, 33), 'kwargs', None, None), [('Constant', (1, 8, 1, 9), 1, None), ('Constant', (1, 16, 1, 17), 2, None)]), [('Pass', (1, 36, 1, 40))], [], None, None)], []), +('Module', [('TypeAlias', (1, 0, 1, 12), ('Name', (1, 5, 1, 6), 'X', ('Store',)), [], ('Name', (1, 9, 1, 12), 'int', ('Load',)))], []), +('Module', [('TypeAlias', (1, 0, 1, 15), ('Name', (1, 5, 1, 6), 'X', ('Store',)), [('TypeVar', (1, 7, 1, 8), 'T', None)], ('Name', (1, 12, 1, 15), 'int', ('Load',)))], []), +('Module', [('TypeAlias', (1, 0, 1, 32), ('Name', (1, 5, 1, 6), 'X', ('Store',)), [('TypeVar', (1, 7, 1, 8), 'T', None), ('TypeVarTuple', (1, 10, 1, 13), 'Ts'), ('ParamSpec', (1, 15, 1, 18), 'P')], ('Tuple', (1, 22, 1, 32), [('Name', (1, 23, 1, 24), 'T', ('Load',)), ('Name', (1, 26, 1, 28), 'Ts', ('Load',)), ('Name', (1, 30, 1, 31), 'P', ('Load',))], ('Load',)))], []), +('Module', [('TypeAlias', (1, 0, 1, 37), ('Name', (1, 5, 1, 6), 'X', ('Store',)), [('TypeVar', (1, 7, 1, 13), 'T', ('Name', (1, 10, 1, 13), 'int', ('Load',))), ('TypeVarTuple', (1, 15, 1, 18), 'Ts'), ('ParamSpec', (1, 20, 1, 23), 'P')], ('Tuple', (1, 27, 1, 37), [('Name', (1, 28, 1, 29), 'T', ('Load',)), ('Name', (1, 31, 1, 33), 'Ts', ('Load',)), ('Name', (1, 35, 1, 36), 'P', ('Load',))], ('Load',)))], []), +('Module', [('TypeAlias', (1, 0, 1, 44), ('Name', (1, 5, 1, 6), 'X', ('Store',)), [('TypeVar', (1, 7, 1, 20), 'T', ('Tuple', (1, 10, 1, 20), [('Name', (1, 11, 1, 14), 'int', ('Load',)), ('Name', (1, 16, 1, 19), 'str', ('Load',))], ('Load',))), ('TypeVarTuple', (1, 22, 1, 25), 'Ts'), ('ParamSpec', (1, 27, 1, 30), 'P')], ('Tuple', (1, 34, 1, 44), [('Name', (1, 35, 1, 36), 'T', ('Load',)), ('Name', (1, 38, 1, 40), 'Ts', ('Load',)), ('Name', (1, 42, 1, 43), 'P', ('Load',))], ('Load',)))], []), +('Module', [('ClassDef', (1, 0, 1, 16), 'X', [('TypeVar', (1, 8, 1, 9), 'T', None)], [], [], [('Pass', (1, 12, 1, 16))], [])], []), +('Module', [('ClassDef', (1, 0, 1, 26), 'X', [('TypeVar', (1, 8, 1, 9), 'T', None), ('TypeVarTuple', (1, 11, 1, 14), 'Ts'), ('ParamSpec', (1, 16, 1, 19), 'P')], [], [], [('Pass', (1, 22, 1, 26))], [])], []), +('Module', [('ClassDef', (1, 0, 1, 31), 'X', [('TypeVar', (1, 8, 1, 14), 'T', ('Name', (1, 11, 1, 14), 'int', ('Load',))), ('TypeVarTuple', (1, 16, 1, 19), 'Ts'), ('ParamSpec', (1, 21, 1, 24), 'P')], [], [], [('Pass', (1, 27, 1, 31))], [])], []), +('Module', [('ClassDef', (1, 0, 1, 38), 'X', [('TypeVar', (1, 8, 1, 21), 'T', ('Tuple', (1, 11, 1, 21), [('Name', (1, 12, 1, 15), 'int', ('Load',)), ('Name', (1, 17, 1, 20), 'str', ('Load',))], ('Load',))), ('TypeVarTuple', (1, 23, 1, 26), 'Ts'), ('ParamSpec', (1, 28, 1, 31), 'P')], [], [], [('Pass', (1, 34, 1, 38))], [])], []), +('Module', [('FunctionDef', (1, 0, 1, 16), 'f', [('TypeVar', (1, 6, 1, 7), 'T', None)], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 12, 1, 16))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 26), 'f', [('TypeVar', (1, 6, 1, 7), 'T', None), ('TypeVarTuple', (1, 9, 1, 12), 'Ts'), ('ParamSpec', (1, 14, 1, 17), 'P')], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 22, 1, 26))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 31), 'f', [('TypeVar', (1, 6, 1, 12), 'T', ('Name', (1, 9, 1, 12), 'int', ('Load',))), ('TypeVarTuple', (1, 14, 1, 17), 'Ts'), ('ParamSpec', (1, 19, 1, 22), 'P')], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 27, 1, 31))], [], None, None)], []), +('Module', [('FunctionDef', (1, 0, 1, 38), 'f', [('TypeVar', (1, 6, 1, 19), 'T', ('Tuple', (1, 9, 1, 19), [('Name', (1, 10, 1, 13), 'int', ('Load',)), ('Name', (1, 15, 1, 18), 'str', ('Load',))], ('Load',))), ('TypeVarTuple', (1, 21, 1, 24), 'Ts'), ('ParamSpec', (1, 26, 1, 29), 'P')], ('arguments', [], [], None, [], [], None, []), [('Pass', (1, 34, 1, 38))], [], None, None)], []), ] single_results = [ ('Interactive', [('Expr', (1, 0, 1, 3), ('BinOp', (1, 0, 1, 3), ('Constant', (1, 0, 1, 1), 1, None), ('Add',), ('Constant', (1, 2, 1, 3), 2, None)))]), From 16a037f67f502854b3dbd7de76ff51bf0bc4a69a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 13:28:53 -0600 Subject: [PATCH 133/200] Move functions closer together --- Python/ast.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index cb694ab2e77d76..d9390ce3801b7c 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -674,27 +674,6 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok) return ret; } -static int -validate_typeparam(struct validator *state, typeparam_ty tp) -{ - VALIDATE_POSITIONS(tp); - int ret = -1; - switch (tp->kind) { - case TypeVar_kind: - ret = validate_name(tp->v.TypeVar.name) && - (!tp->v.TypeVar.bound || - validate_expr(state, tp->v.TypeVar.bound, Load)); - break; - case ParamSpec_kind: - ret = validate_name(tp->v.ParamSpec.name); - break; - case TypeVarTuple_kind: - ret = validate_name(tp->v.TypeVarTuple.name); - break; - } - return ret; -} - static int _validate_nonempty_seq(asdl_seq *seq, const char *what, const char *owner) { @@ -996,6 +975,27 @@ validate_patterns(struct validator *state, asdl_pattern_seq *patterns, int star_ return 1; } +static int +validate_typeparam(struct validator *state, typeparam_ty tp) +{ + VALIDATE_POSITIONS(tp); + int ret = -1; + switch (tp->kind) { + case TypeVar_kind: + ret = validate_name(tp->v.TypeVar.name) && + (!tp->v.TypeVar.bound || + validate_expr(state, tp->v.TypeVar.bound, Load)); + break; + case ParamSpec_kind: + ret = validate_name(tp->v.ParamSpec.name); + break; + case TypeVarTuple_kind: + ret = validate_name(tp->v.TypeVarTuple.name); + break; + } + return ret; +} + static int validate_typeparams(struct validator *state, asdl_typeparam_seq *tps) { From c5d93788287396abc734872a6eed8ff1240579d4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 17:17:26 -0700 Subject: [PATCH 134/200] try this way --- Lib/keyword.py | 2 +- Modules/Setup.bootstrap.in | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/keyword.py b/Lib/keyword.py index ac737d7e703445..e22c837835e740 100644 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -57,7 +57,7 @@ '_', 'case', 'match', - 'type', + 'type' ] iskeyword = frozenset(kwlist).__contains__ diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index e3e9b96b0630df..1d6a90e0192e1d 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -22,6 +22,7 @@ _sre _sre/sre.c _thread _threadmodule.c time timemodule.c _weakref _weakref.c +_typing _typingmodule.c # commonly used core modules _abc _abc.c From 0399ed4865fca6acc5a12a5e24febe0d1ed577aa Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 17:22:26 -0700 Subject: [PATCH 135/200] comments --- Lib/typing.py | 7 ++++++- Objects/typevarobject.c | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Lib/typing.py b/Lib/typing.py index a2383ca1dc4db0..02a194f3959bb6 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -702,7 +702,12 @@ def Union(self, parameters): return _UnionGenericAlias(self, parameters) def _make_union(left, right): - """Used from the C implementation of TypeVar.""" + """Used from the C implementation of TypeVar. + + TypeVar.__or__ calls this instead of returning types.UnionType + because we want to allow unions between TypeVars and strings + (forward references.) + """ return Union[left, right] @_SpecialForm diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index aea80ab6ffedda..1b2909d396bab6 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -87,6 +87,14 @@ type_check(PyObject *arg) return result; } +/* + * Return a typing.Union. This is used as the nb_or (|) operator for + * TypeVar and ParamSpec. We use this rather than _Py_union_type_or + * (which would produce a types.Union) because historically TypeVar + * supported unions with forward references, and we want to preserve + * that behavior. _Py_union_type_or only allows a small set of + * types. + */ static PyObject * make_union(PyObject *self, PyObject *other) { @@ -1007,6 +1015,8 @@ static PyType_Slot paramspec_slots[] = { {Py_tp_members, paramspec_members}, {Py_tp_methods, paramspec_methods}, {Py_tp_getset, paramspec_getset}, + // Unions of ParamSpecs have no defined meaning, but they were allowed + // by the Python implementation, so we allow them here too. {Py_nb_or, make_union}, {Py_tp_new, paramspec_new}, {Py_tp_dealloc, paramspec_dealloc}, From 782fc350580bb2a1fd072d3bbc2281396068c25c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 17:32:31 -0700 Subject: [PATCH 136/200] Maybe this --- Modules/Setup.bootstrap.in | 2 +- Modules/Setup.stdlib.in | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/Setup.bootstrap.in b/Modules/Setup.bootstrap.in index 1d6a90e0192e1d..8ef0f203a82a8e 100644 --- a/Modules/Setup.bootstrap.in +++ b/Modules/Setup.bootstrap.in @@ -21,8 +21,8 @@ itertools itertoolsmodule.c _sre _sre/sre.c _thread _threadmodule.c time timemodule.c -_weakref _weakref.c _typing _typingmodule.c +_weakref _weakref.c # commonly used core modules _abc _abc.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index fe1b9f8f5380c1..6b2e17b9908a95 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -41,7 +41,6 @@ @MODULE__QUEUE_TRUE@_queue _queuemodule.c @MODULE__RANDOM_TRUE@_random _randommodule.c @MODULE__STRUCT_TRUE@_struct _struct.c -@MODULE__TYPING_TRUE@_typing _typingmodule.c @MODULE__XXSUBINTERPRETERS_TRUE@_xxsubinterpreters _xxsubinterpretersmodule.c @MODULE__XXINTERPCHANNELS_TRUE@_xxinterpchannels _xxinterpchannelsmodule.c @MODULE__ZONEINFO_TRUE@_zoneinfo _zoneinfo.c From 0241da54e9cdedbf951e86ac1cefc6eca74fe6e0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 17:43:24 -0700 Subject: [PATCH 137/200] avoid special qualname handling --- Lib/test/test_type_params.py | 19 +++++++++++++++++++ Python/compile.c | 13 ------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index e704578f7987a5..f7e897f3512fcb 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -261,7 +261,26 @@ def func[S, T: Sequence[S]](): self.assertEqual(T.__bound__, Sequence[S]) +def global_generic_func[T](): + pass + +class GlobalGenericClass[T]: + pass + + class TypeParamsLazyEvaluationTest(unittest.TestCase): + def test_qualname(self): + class Foo[T]: + pass + + def func[T](): + pass + + self.assertEqual(Foo.__qualname__, "TypeParamsLazyEvaluationTest.test_qualname..Foo") + self.assertEqual(func.__qualname__, "TypeParamsLazyEvaluationTest.test_qualname..func") + self.assertEqual(global_generic_func.__qualname__, "global_generic_func") + self.assertEqual(GlobalGenericClass.__qualname__, "GlobalGenericClass") + def test_recursive_class(self): class Foo[T: Foo, U: (Foo, Foo)]: pass diff --git a/Python/compile.c b/Python/compile.c index 871a3784705ea4..9362486a854484 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -702,19 +702,6 @@ compiler_set_qualname(struct compiler *c) capsule = PyList_GET_ITEM(c->c_stack, stack_size - 1); parent = (struct compiler_unit *)PyCapsule_GetPointer(capsule, CAPSULE_NAME); assert(parent); - if (parent->u_scope_type == COMPILER_SCOPE_TYPEPARAMS) { - /* The parent is a type parameter scope, so we need to - look at the grandparent. */ - if (stack_size == 2) { - // If we're immediately within the module, we can skip - // the rest and just set the qualname to be the same as name. - u->u_metadata.u_qualname = Py_NewRef(u->u_metadata.u_name); - return SUCCESS; - } - capsule = PyList_GET_ITEM(c->c_stack, stack_size - 2); - parent = (struct compiler_unit *)PyCapsule_GetPointer(capsule, CAPSULE_NAME); - assert(parent); - } if (u->u_scope_type == COMPILER_SCOPE_FUNCTION || u->u_scope_type == COMPILER_SCOPE_ASYNC_FUNCTION From 5b3a204e6a00deb6d9ceb63298ddde82c3717a45 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 18:36:32 -0700 Subject: [PATCH 138/200] Fix opcode classification --- Lib/opcode.py | 3 ++- Python/compile.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/opcode.py b/Lib/opcode.py index d47c22edbb360b..eab1094ed74498 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -228,7 +228,8 @@ def pseudo_op(name, op, real_ops): def_op('CALL_INTRINSIC_2', 174) name_op('LOAD_CLASSDICT_OR_GLOBAL', 175) -name_op('LOAD_CLASSDICT_OR_DEREF', 176) +def_op('LOAD_CLASSDICT_OR_DEREF', 176) +hasfree.append(176) # Instrumented instructions MIN_INSTRUMENTED_OPCODE = 238 diff --git a/Python/compile.c b/Python/compile.c index 9362486a854484..b095f85aa4b567 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2529,7 +2529,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); int is_in_class = c->u->u_ste->ste_type_params_in_class; - PyCodeObject *co = optimize_and_assemble(c, 1); + PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { return ERROR; From 78f3f4b43c26664d866cf975ba329846c83c3fbb Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 20:00:11 -0700 Subject: [PATCH 139/200] Fix qualname test --- Python/compile.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Python/compile.c b/Python/compile.c index b095f85aa4b567..9132143b55c222 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -702,6 +702,19 @@ compiler_set_qualname(struct compiler *c) capsule = PyList_GET_ITEM(c->c_stack, stack_size - 1); parent = (struct compiler_unit *)PyCapsule_GetPointer(capsule, CAPSULE_NAME); assert(parent); + if (parent->u_scope_type == COMPILER_SCOPE_TYPEPARAMS) { + /* The parent is a type parameter scope, so we need to + look at the grandparent. */ + if (stack_size == 2) { + // If we're immediately within the module, we can skip + // the rest and just set the qualname to be the same as name. + u->u_metadata.u_qualname = Py_NewRef(u->u_metadata.u_name); + return SUCCESS; + } + capsule = PyList_GET_ITEM(c->c_stack, stack_size - 2); + parent = (struct compiler_unit *)PyCapsule_GetPointer(capsule, CAPSULE_NAME); + assert(parent); + } if (u->u_scope_type == COMPILER_SCOPE_FUNCTION || u->u_scope_type == COMPILER_SCOPE_ASYNC_FUNCTION From 9d3177ba791f47daf13b65d8ea49d76348b74e23 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 20:16:25 -0700 Subject: [PATCH 140/200] Harmonize implementation of the two intrinsics --- Include/internal/pycore_function.h | 2 ++ Objects/funcobject.c | 17 ++++++++++++----- Python/intrinsics.c | 13 ++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Include/internal/pycore_function.h b/Include/internal/pycore_function.h index ecbb7001e7d840..7287fd4a6a3e14 100644 --- a/Include/internal/pycore_function.h +++ b/Include/internal/pycore_function.h @@ -19,6 +19,8 @@ extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr) extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func); extern PyObject *_Py_set_function_type_params( PyThreadState* unused, PyObject *func, PyObject *type_params); +extern PyObject *_Py_set_function_class_dict( + PyThreadState* unused, PyObject *func, PyObject *class_dict); #ifdef __cplusplus } diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 4e98a36ab3a2ea..df9f7c539f376b 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -682,16 +682,23 @@ PyObject * _Py_set_function_type_params(PyThreadState *unused, PyObject *func, PyObject *type_params) { + assert(PyFunction_Check(func)); + assert(PyTuple_Check(type_params)); PyFunctionObject *f = (PyFunctionObject *)func; - if (!PyTuple_Check(type_params)) { - PyErr_SetString(PyExc_TypeError, - "__type_params__ must be set to a tuple object"); - return NULL; - } Py_XSETREF(f->func_typeparams, Py_NewRef(type_params)); return Py_NewRef(func); } +PyObject * +_Py_set_function_class_dict(PyThreadState* unused, PyObject *func, + PyObject *class_dict) +{ + assert(PyFunction_Check(func)); + assert(PyDict_Check(class_dict)); + PyFunctionObject *f = (PyFunctionObject *)func; + Py_XSETREF(f->func_class_dict, Py_NewRef(class_dict)); + return Py_NewRef(func); +} static PyGetSetDef func_getsetlist[] = { {"__code__", (getter)func_get_code, (setter)func_set_code}, diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 64f377fbc3b873..f0bb75aa63b665 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -3,6 +3,7 @@ #include "Python.h" #include "pycore_frame.h" +#include "pycore_function.h" #include "pycore_runtime.h" #include "pycore_global_objects.h" #include "pycore_intrinsics.h" @@ -251,21 +252,11 @@ make_typevar_with_constraints(PyThreadState* unused, PyObject *name, evaluate_constraints); } -static PyObject * -set_class_dict(PyThreadState* unused, PyObject *fn, PyObject *class_dict) -{ - assert(PyFunction_Check(fn)); - assert(PyDict_Check(class_dict)); - PyFunctionObject *func = (PyFunctionObject *)fn; - Py_XSETREF(func->func_class_dict, Py_NewRef(class_dict)); - return Py_NewRef(fn); -} - const instrinsic_func2 _PyIntrinsics_BinaryFunctions[] = { [INTRINSIC_PREP_RERAISE_STAR] = prep_reraise_star, [INTRINSIC_TYPEVAR_WITH_BOUND] = make_typevar_with_bound, [INTRINSIC_TYPEVAR_WITH_CONSTRAINTS] = make_typevar_with_constraints, [INTRINSIC_SET_FUNCTION_TYPE_PARAMS] = _Py_set_function_type_params, - [INTRINSIC_SET_CLASS_DICT] = set_class_dict, + [INTRINSIC_SET_CLASS_DICT] = _Py_set_function_class_dict, }; From c52179c15aedcfb7ecd9446770387b743395d7b1 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2023 21:17:01 -0700 Subject: [PATCH 141/200] Simplify LOAD_LOCALS at the cost of compiler complexity --- .../pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + .../internal/pycore_runtime_init_generated.h | 1 + Python/bytecodes.c | 15 +- Python/compile.c | 44 +- Python/generated_cases.c.h | 685 +++++++++--------- Python/symtable.c | 17 +- 7 files changed, 388 insertions(+), 376 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index c464c780531e7c..7838f1e487707d 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -551,6 +551,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_setcomp)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_string)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_unknown)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(class_dict)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(close_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_close_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_open_br)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 4ddcdd3ada68f1..1e0ec2b7c0e915 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -36,6 +36,7 @@ struct _Py_global_strings { STRUCT_FOR_STR(anon_setcomp, "") STRUCT_FOR_STR(anon_string, "") STRUCT_FOR_STR(anon_unknown, "") + STRUCT_FOR_STR(class_dict, ".class_dict") STRUCT_FOR_STR(close_br, "}") STRUCT_FOR_STR(dbl_close_br, "}}") STRUCT_FOR_STR(dbl_open_br, "{{") diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 8b7be4f2da0666..7f9f49734c1691 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -542,6 +542,7 @@ extern "C" { INIT_STR(anon_setcomp, ""), \ INIT_STR(anon_string, ""), \ INIT_STR(anon_unknown, ""), \ + INIT_STR(class_dict, ".class_dict"), \ INIT_STR(close_br, "}"), \ INIT_STR(dbl_close_br, "}}"), \ INIT_STR(dbl_open_br, "{{"), \ diff --git a/Python/bytecodes.c b/Python/bytecodes.c index fff0dc214b6843..481d7fe47da119 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -997,18 +997,9 @@ dummy_func( inst(LOAD_LOCALS, ( -- locals)) { locals = LOCALS(); if (locals == NULL) { - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found"); - ERROR_IF(true, error); - } - locals = func->func_class_dict; - if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no class dict set when loading locals"); - ERROR_IF(true, error); - } + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + ERROR_IF(true, error); } Py_INCREF(locals); } diff --git a/Python/compile.c b/Python/compile.c index 9132143b55c222..1fe9ac5e0b7b5c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2112,7 +2112,7 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) } Py_DECREF(co); if (c->u->u_ste->ste_type_params_in_class) { - ADDOP(c, loc, LOAD_LOCALS); + ADDOP_I(c, loc, LOAD_FAST, 0); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); } @@ -2195,12 +2195,16 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) location loc = LOC(s); - int is_typeparams_in_class = 0; + int is_typeparams_in_class = c->u->u_ste->ste_type == ClassBlock; + int is_generic = asdl_seq_LEN(typeparams) > 0; - if (asdl_seq_LEN(typeparams) > 0) { + if (is_generic) { ADDOP(c, loc, PUSH_NULL); // We'll swap in the callable here later. ADDOP_LOAD_CONST(c, loc, Py_None); + if (is_typeparams_in_class) { + ADDOP(c, loc, LOAD_LOCALS); + } } funcflags = compiler_default_arguments(c, loc, args); @@ -2211,7 +2215,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int num_typeparam_args = 0; _Py_DECLARE_STR(type_params, ".type_params"); - if (asdl_seq_LEN(typeparams) > 0) { + if (is_generic) { PyObject *typeparams_name = PyUnicode_FromFormat("", name); if (!typeparams_name) { return ERROR; @@ -2278,18 +2282,19 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); - if (asdl_seq_LEN(typeparams) > 0) { + if (is_generic) { RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS); + if (is_typeparams_in_class) { + c->u->u_metadata.u_argcount += 1; + } if (funcflags & 0x02) { c->u->u_metadata.u_argcount += 1; } if (funcflags & 0x01) { c->u->u_metadata.u_argcount += 1; } - // Must be before we exit the scope - int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2338,7 +2343,8 @@ compiler_class(struct compiler *c, stmt_ty s) location loc = LOC(s); asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; - if (asdl_seq_LEN(typeparams) > 0) { + int is_generic = asdl_seq_LEN(typeparams) > 0; + if (is_generic) { Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); ADDOP(c, loc, PUSH_NULL); PyObject *typeparams_name = PyUnicode_FromFormat("", @@ -2452,7 +2458,7 @@ compiler_class(struct compiler *c, stmt_ty s) /* 5. generate the rest of the code for the call */ - if (asdl_seq_LEN(typeparams) > 0) { + if (is_generic) { _Py_DECLARE_STR(type_params, ".type_params"); _Py_DECLARE_STR(generic_base, ".generic_base"); RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); @@ -2479,6 +2485,7 @@ compiler_class(struct compiler *c, stmt_ty s) // Must be before we exit the scope int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; + c->u->u_metadata.u_argcount = is_typeparams_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2492,8 +2499,9 @@ compiler_class(struct compiler *c, stmt_ty s) if (is_typeparams_in_class) { ADDOP(c, loc, LOAD_LOCALS); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); + ADDOP(c, loc, LOAD_LOCALS); } - ADDOP_I(c, loc, CALL, 0); + ADDOP_I(c, loc, CALL, is_typeparams_in_class); } else { RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, s->v.ClassDef.bases, @@ -2513,8 +2521,9 @@ compiler_typealias(struct compiler *c, stmt_ty s) { location loc = LOC(s); asdl_typeparam_seq *typeparams = s->v.TypeAlias.typeparams; + int is_generic = asdl_seq_LEN(typeparams) > 0; PyObject *name = s->v.TypeAlias.name->v.Name.id; - if (asdl_seq_LEN(typeparams) > 0) { + if (is_generic) { ADDOP(c, loc, PUSH_NULL); PyObject *typeparams_name = PyUnicode_FromFormat("", name); @@ -2553,14 +2562,20 @@ compiler_typealias(struct compiler *c, stmt_ty s) } Py_DECREF(co); if (is_in_class) { - ADDOP(c, loc, LOAD_LOCALS); + if (is_generic) { + ADDOP_I(c, loc, LOAD_FAST, 0); + } + else { + ADDOP(c, loc, LOAD_LOCALS); + } ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); } ADDOP_I(c, loc, BUILD_TUPLE, 3); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); - if (asdl_seq_LEN(typeparams) > 0) { + if (is_generic) { // Must be before we exit the scope int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; + c->u->u_metadata.u_argcount = is_typeparams_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2574,8 +2589,9 @@ compiler_typealias(struct compiler *c, stmt_ty s) if (is_typeparams_in_class) { ADDOP(c, loc, LOAD_LOCALS); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); + ADDOP(c, loc, LOAD_LOCALS); } - ADDOP_I(c, loc, CALL, 0); + ADDOP_I(c, loc, CALL, is_typeparams_in_class); } RETURN_IF_ERROR(compiler_nameop(c, loc, name, Store)); return SUCCESS; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 91de2e4acf17d9..6585e2f83cfee2 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1375,21 +1375,12 @@ #line 998 "Python/bytecodes.c" locals = LOCALS(); if (locals == NULL) { - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found"); - if (true) goto error; - } - locals = func->func_class_dict; - if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no class dict set when loading locals"); - if (true) goto error; - } + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + if (true) goto error; } Py_INCREF(locals); - #line 1393 "Python/generated_cases.c.h" + #line 1384 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = locals; DISPATCH(); @@ -1397,33 +1388,33 @@ TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 1017 "Python/bytecodes.c" + #line 1008 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); - #line 1408 "Python/generated_cases.c.h" + #line 1399 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1024 "Python/bytecodes.c" + #line 1015 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); - #line 1417 "Python/generated_cases.c.h" + #line 1408 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1031 "Python/bytecodes.c" + #line 1022 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1421 "Python/generated_cases.c.h" + #line 1412 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { - #line 1035 "Python/bytecodes.c" + #line 1026 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1440,7 +1431,7 @@ name); goto error; } - #line 1444 "Python/generated_cases.c.h" + #line 1435 "Python/generated_cases.c.h" DISPATCH(); } @@ -1448,7 +1439,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 1061 "Python/bytecodes.c" + #line 1052 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1461,11 +1452,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); - #line 1465 "Python/generated_cases.c.h" + #line 1456 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1074 "Python/bytecodes.c" + #line 1065 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1469 "Python/generated_cases.c.h" + #line 1460 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1475,14 +1466,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1078 "Python/bytecodes.c" + #line 1069 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); - #line 1486 "Python/generated_cases.c.h" + #line 1477 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1493,7 +1484,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1088 "Python/bytecodes.c" + #line 1079 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1501,7 +1492,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1505 "Python/generated_cases.c.h" + #line 1496 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1512,7 +1503,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1099 "Python/bytecodes.c" + #line 1090 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1520,7 +1511,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1524 "Python/generated_cases.c.h" + #line 1515 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1530,15 +1521,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 1110 "Python/bytecodes.c" + #line 1101 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); - #line 1538 "Python/generated_cases.c.h" + #line 1529 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1114 "Python/bytecodes.c" + #line 1105 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1542 "Python/generated_cases.c.h" + #line 1533 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1549,7 +1540,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 1125 "Python/bytecodes.c" + #line 1116 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1565,12 +1556,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); - #line 1569 "Python/generated_cases.c.h" + #line 1560 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1141 "Python/bytecodes.c" + #line 1132 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 1574 "Python/generated_cases.c.h" + #line 1565 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1578,34 +1569,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1145 "Python/bytecodes.c" + #line 1136 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); - #line 1585 "Python/generated_cases.c.h" + #line 1576 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1148 "Python/bytecodes.c" + #line 1139 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1589 "Python/generated_cases.c.h" + #line 1580 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1152 "Python/bytecodes.c" + #line 1143 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); - #line 1599 "Python/generated_cases.c.h" + #line 1590 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1155 "Python/bytecodes.c" + #line 1146 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1603 "Python/generated_cases.c.h" + #line 1594 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { - #line 1159 "Python/bytecodes.c" + #line 1150 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1617,7 +1608,7 @@ } goto error; } - #line 1621 "Python/generated_cases.c.h" + #line 1612 "Python/generated_cases.c.h" DISPATCH(); } @@ -1627,7 +1618,7 @@ { PyObject *mad_or_class_dict; PyObject *name; - #line 1173 "Python/bytecodes.c" + #line 1164 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); mad_or_class_dict = LOCALS(); if (mad_or_class_dict == NULL) { @@ -1635,7 +1626,7 @@ "no locals when loading %R", name); goto error; } - #line 1639 "Python/generated_cases.c.h" + #line 1630 "Python/generated_cases.c.h" _tmp_2 = mad_or_class_dict; _tmp_1 = name; } @@ -1643,7 +1634,7 @@ PyObject *name = _tmp_1; PyObject *mad_or_class_dict = _tmp_2; PyObject *v; - #line 1199 "Python/bytecodes.c" + #line 1190 "Python/bytecodes.c" if (PyDict_CheckExact(mad_or_class_dict)) { v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { @@ -1695,7 +1686,7 @@ } } } - #line 1699 "Python/generated_cases.c.h" + #line 1690 "Python/generated_cases.c.h" _tmp_2 = v; } STACK_GROW(1); @@ -1709,7 +1700,7 @@ { PyObject *mad_or_class_dict; PyObject *name; - #line 1183 "Python/bytecodes.c" + #line 1174 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; if (func == NULL) { @@ -1723,7 +1714,7 @@ "no class dict set when loading %R", name); goto error; } - #line 1727 "Python/generated_cases.c.h" + #line 1718 "Python/generated_cases.c.h" _tmp_2 = mad_or_class_dict; _tmp_1 = name; } @@ -1731,7 +1722,7 @@ PyObject *name = _tmp_1; PyObject *mad_or_class_dict = _tmp_2; PyObject *v; - #line 1199 "Python/bytecodes.c" + #line 1190 "Python/bytecodes.c" if (PyDict_CheckExact(mad_or_class_dict)) { v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { @@ -1783,7 +1774,7 @@ } } } - #line 1787 "Python/generated_cases.c.h" + #line 1778 "Python/generated_cases.c.h" _tmp_2 = v; } STACK_GROW(1); @@ -1796,7 +1787,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1263 "Python/bytecodes.c" + #line 1254 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1848,7 +1839,7 @@ } } null = NULL; - #line 1852 "Python/generated_cases.c.h" + #line 1843 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1862,7 +1853,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1317 "Python/bytecodes.c" + #line 1308 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1873,7 +1864,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1877 "Python/generated_cases.c.h" + #line 1868 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1888,7 +1879,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1330 "Python/bytecodes.c" + #line 1321 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1903,7 +1894,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1907 "Python/generated_cases.c.h" + #line 1898 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1913,16 +1904,16 @@ } TARGET(DELETE_FAST) { - #line 1347 "Python/bytecodes.c" + #line 1338 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1921 "Python/generated_cases.c.h" + #line 1912 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1353 "Python/bytecodes.c" + #line 1344 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1931,12 +1922,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1935 "Python/generated_cases.c.h" + #line 1926 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1364 "Python/bytecodes.c" + #line 1355 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1947,7 +1938,7 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1951 "Python/generated_cases.c.h" + #line 1942 "Python/generated_cases.c.h" DISPATCH(); } @@ -1955,15 +1946,15 @@ PyObject *_tmp_1; { PyObject *class_dict; - #line 1377 "Python/bytecodes.c" + #line 1368 "Python/bytecodes.c" class_dict = LOCALS(); - #line 1961 "Python/generated_cases.c.h" + #line 1952 "Python/generated_cases.c.h" _tmp_1 = class_dict; } { PyObject *class_dict = _tmp_1; PyObject *value; - #line 1396 "Python/bytecodes.c" + #line 1387 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1995,7 +1986,7 @@ } Py_INCREF(value); } - #line 1999 "Python/generated_cases.c.h" + #line 1990 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(1); @@ -2007,7 +1998,7 @@ PyObject *_tmp_1; { PyObject *class_dict; - #line 1381 "Python/bytecodes.c" + #line 1372 "Python/bytecodes.c" PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; if (func == NULL) { _PyErr_Format(tstate, PyExc_SystemError, @@ -2020,13 +2011,13 @@ "no class dict set when loading from class dict"); goto error; } - #line 2024 "Python/generated_cases.c.h" + #line 2015 "Python/generated_cases.c.h" _tmp_1 = class_dict; } { PyObject *class_dict = _tmp_1; PyObject *value; - #line 1396 "Python/bytecodes.c" + #line 1387 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -2058,7 +2049,7 @@ } Py_INCREF(value); } - #line 2062 "Python/generated_cases.c.h" + #line 2053 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(1); @@ -2068,7 +2059,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1433 "Python/bytecodes.c" + #line 1424 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -2076,7 +2067,7 @@ if (true) goto error; } Py_INCREF(value); - #line 2080 "Python/generated_cases.c.h" + #line 2071 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -2084,18 +2075,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1443 "Python/bytecodes.c" + #line 1434 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2093 "Python/generated_cases.c.h" + #line 2084 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1450 "Python/bytecodes.c" + #line 1441 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2106,22 +2097,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2110 "Python/generated_cases.c.h" + #line 2101 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1463 "Python/bytecodes.c" + #line 1454 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2119 "Python/generated_cases.c.h" + #line 2110 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1465 "Python/bytecodes.c" + #line 1456 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2125 "Python/generated_cases.c.h" + #line 2116 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2131,10 +2122,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1469 "Python/bytecodes.c" + #line 1460 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2138 "Python/generated_cases.c.h" + #line 2129 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2144,10 +2135,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1474 "Python/bytecodes.c" + #line 1465 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2151 "Python/generated_cases.c.h" + #line 2142 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2157,7 +2148,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1479 "Python/bytecodes.c" + #line 1470 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2168,13 +2159,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2172 "Python/generated_cases.c.h" + #line 2163 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1490 "Python/bytecodes.c" + #line 1481 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2178 "Python/generated_cases.c.h" + #line 2169 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2183,13 +2174,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1497 "Python/bytecodes.c" + #line 1488 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2189 "Python/generated_cases.c.h" + #line 2180 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1499 "Python/bytecodes.c" + #line 1490 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2193 "Python/generated_cases.c.h" + #line 2184 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2197,7 +2188,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1503 "Python/bytecodes.c" + #line 1494 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2212,7 +2203,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2216 "Python/generated_cases.c.h" + #line 2207 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2222,7 +2213,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1520 "Python/bytecodes.c" + #line 1511 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2230,13 +2221,13 @@ if (map == NULL) goto error; - #line 2234 "Python/generated_cases.c.h" + #line 2225 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1528 "Python/bytecodes.c" + #line 1519 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2240 "Python/generated_cases.c.h" + #line 2231 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2244,7 +2235,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1532 "Python/bytecodes.c" + #line 1523 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2284,7 +2275,7 @@ Py_DECREF(ann_dict); } } - #line 2288 "Python/generated_cases.c.h" + #line 2279 "Python/generated_cases.c.h" DISPATCH(); } @@ -2292,7 +2283,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1574 "Python/bytecodes.c" + #line 1565 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2302,14 +2293,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2306 "Python/generated_cases.c.h" + #line 2297 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1584 "Python/bytecodes.c" + #line 1575 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2313 "Python/generated_cases.c.h" + #line 2304 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2317,7 +2308,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1588 "Python/bytecodes.c" + #line 1579 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2325,12 +2316,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2329 "Python/generated_cases.c.h" + #line 2320 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1596 "Python/bytecodes.c" + #line 1587 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2334 "Python/generated_cases.c.h" + #line 2325 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2338,17 +2329,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1602 "Python/bytecodes.c" + #line 1593 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2347 "Python/generated_cases.c.h" + #line 2338 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1607 "Python/bytecodes.c" + #line 1598 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2352 "Python/generated_cases.c.h" + #line 2343 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2358,13 +2349,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1614 "Python/bytecodes.c" + #line 1605 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2368 "Python/generated_cases.c.h" + #line 2359 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2378,7 +2369,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1628 "Python/bytecodes.c" + #line 1619 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2396,16 +2387,16 @@ // handle any case whose performance we care about PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2400 "Python/generated_cases.c.h" + #line 2391 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1646 "Python/bytecodes.c" + #line 1637 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2409 "Python/generated_cases.c.h" + #line 2400 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2423,7 +2414,7 @@ uint32_t class_version = read_u32(&next_instr[1].cache); uint32_t self_type_version = read_u32(&next_instr[3].cache); PyObject *method = read_obj(&next_instr[5].cache); - #line 1653 "Python/bytecodes.c" + #line 1644 "Python/bytecodes.c" DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); DEOPT_IF(((PyTypeObject *)class)->tp_version_tag != class_version, LOAD_SUPER_ATTR); @@ -2434,7 +2425,7 @@ Py_INCREF(res2); Py_DECREF(global_super); Py_DECREF(class); - #line 2438 "Python/generated_cases.c.h" + #line 2429 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2448,7 +2439,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1680 "Python/bytecodes.c" + #line 1671 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2482,9 +2473,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2486 "Python/generated_cases.c.h" + #line 2477 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1714 "Python/bytecodes.c" + #line 1705 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2493,12 +2484,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2497 "Python/generated_cases.c.h" + #line 2488 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1723 "Python/bytecodes.c" + #line 1714 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2502 "Python/generated_cases.c.h" + #line 2493 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2512,7 +2503,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1728 "Python/bytecodes.c" + #line 1719 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2525,7 +2516,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2529 "Python/generated_cases.c.h" + #line 2520 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2540,7 +2531,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1744 "Python/bytecodes.c" + #line 1735 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2553,7 +2544,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2557 "Python/generated_cases.c.h" + #line 2548 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2568,7 +2559,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1760 "Python/bytecodes.c" + #line 1751 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2595,7 +2586,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2599 "Python/generated_cases.c.h" + #line 2590 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2610,7 +2601,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1790 "Python/bytecodes.c" + #line 1781 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2620,7 +2611,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2624 "Python/generated_cases.c.h" + #line 2615 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2635,7 +2626,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1803 "Python/bytecodes.c" + #line 1794 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2647,7 +2638,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2651 "Python/generated_cases.c.h" + #line 2642 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2661,7 +2652,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1818 "Python/bytecodes.c" + #line 1809 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2685,7 +2676,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2689 "Python/generated_cases.c.h" + #line 2680 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2693,7 +2684,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1844 "Python/bytecodes.c" + #line 1835 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2719,7 +2710,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2723 "Python/generated_cases.c.h" + #line 2714 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2727,7 +2718,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1872 "Python/bytecodes.c" + #line 1863 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2745,7 +2736,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2749 "Python/generated_cases.c.h" + #line 2740 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2756,7 +2747,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1892 "Python/bytecodes.c" + #line 1883 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2795,7 +2786,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2799 "Python/generated_cases.c.h" + #line 2790 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2806,7 +2797,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1933 "Python/bytecodes.c" + #line 1924 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2816,7 +2807,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2820 "Python/generated_cases.c.h" + #line 2811 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2828,7 +2819,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1952 "Python/bytecodes.c" + #line 1943 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2841,12 +2832,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2845 "Python/generated_cases.c.h" + #line 2836 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1965 "Python/bytecodes.c" + #line 1956 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2850 "Python/generated_cases.c.h" + #line 2841 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2857,7 +2848,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1969 "Python/bytecodes.c" + #line 1960 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2869,7 +2860,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2873 "Python/generated_cases.c.h" + #line 2864 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2880,7 +2871,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1984 "Python/bytecodes.c" + #line 1975 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2896,7 +2887,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2900 "Python/generated_cases.c.h" + #line 2891 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2907,7 +2898,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2003 "Python/bytecodes.c" + #line 1994 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2920,7 +2911,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2924 "Python/generated_cases.c.h" + #line 2915 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2931,14 +2922,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2018 "Python/bytecodes.c" + #line 2009 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2937 "Python/generated_cases.c.h" + #line 2928 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2020 "Python/bytecodes.c" + #line 2011 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2942 "Python/generated_cases.c.h" + #line 2933 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2948,15 +2939,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2024 "Python/bytecodes.c" + #line 2015 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2954 "Python/generated_cases.c.h" + #line 2945 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2026 "Python/bytecodes.c" + #line 2017 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2960 "Python/generated_cases.c.h" + #line 2951 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2967,12 +2958,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2031 "Python/bytecodes.c" + #line 2022 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2973 "Python/generated_cases.c.h" + #line 2964 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2033 "Python/bytecodes.c" + #line 2024 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2980,10 +2971,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2984 "Python/generated_cases.c.h" + #line 2975 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2041 "Python/bytecodes.c" + #line 2032 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2992,7 +2983,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2996 "Python/generated_cases.c.h" + #line 2987 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -3002,21 +2993,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2052 "Python/bytecodes.c" + #line 2043 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 3009 "Python/generated_cases.c.h" + #line 3000 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2055 "Python/bytecodes.c" + #line 2046 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 3016 "Python/generated_cases.c.h" + #line 3007 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2060 "Python/bytecodes.c" + #line 2051 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 3020 "Python/generated_cases.c.h" + #line 3011 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -3025,15 +3016,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2064 "Python/bytecodes.c" + #line 2055 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 3032 "Python/generated_cases.c.h" + #line 3023 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2067 "Python/bytecodes.c" + #line 2058 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 3037 "Python/generated_cases.c.h" + #line 3028 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -3042,29 +3033,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2071 "Python/bytecodes.c" + #line 2062 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 3050 "Python/generated_cases.c.h" + #line 3041 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2077 "Python/bytecodes.c" + #line 2068 "Python/bytecodes.c" JUMPBY(oparg); - #line 3059 "Python/generated_cases.c.h" + #line 3050 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2081 "Python/bytecodes.c" + #line 2072 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 3068 "Python/generated_cases.c.h" + #line 3059 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -3072,7 +3063,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2087 "Python/bytecodes.c" + #line 2078 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3082,9 +3073,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3086 "Python/generated_cases.c.h" + #line 3077 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2097 "Python/bytecodes.c" + #line 2088 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3092,14 +3083,14 @@ if (err < 0) goto pop_1_error; } } - #line 3096 "Python/generated_cases.c.h" + #line 3087 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2107 "Python/bytecodes.c" + #line 2098 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3109,9 +3100,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3113 "Python/generated_cases.c.h" + #line 3104 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2117 "Python/bytecodes.c" + #line 2108 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3119,67 +3110,67 @@ if (err < 0) goto pop_1_error; } } - #line 3123 "Python/generated_cases.c.h" + #line 3114 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2127 "Python/bytecodes.c" + #line 2118 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3132 "Python/generated_cases.c.h" + #line 3123 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2129 "Python/bytecodes.c" + #line 2120 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3140 "Python/generated_cases.c.h" + #line 3131 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2137 "Python/bytecodes.c" + #line 2128 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3153 "Python/generated_cases.c.h" + #line 3144 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2143 "Python/bytecodes.c" + #line 2134 "Python/bytecodes.c" } - #line 3157 "Python/generated_cases.c.h" + #line 3148 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2147 "Python/bytecodes.c" + #line 2138 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3170 "Python/generated_cases.c.h" + #line 3161 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2156 "Python/bytecodes.c" + #line 2147 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3183 "Python/generated_cases.c.h" + #line 3174 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3190,16 +3181,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2164 "Python/bytecodes.c" + #line 2155 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3199 "Python/generated_cases.c.h" + #line 3190 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2169 "Python/bytecodes.c" + #line 2160 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3207,7 +3198,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3211 "Python/generated_cases.c.h" + #line 3202 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3216,10 +3207,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2179 "Python/bytecodes.c" + #line 2170 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3223 "Python/generated_cases.c.h" + #line 3214 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3229,10 +3220,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2185 "Python/bytecodes.c" + #line 2176 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3236 "Python/generated_cases.c.h" + #line 3227 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3243,11 +3234,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2191 "Python/bytecodes.c" + #line 2182 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3251 "Python/generated_cases.c.h" + #line 3242 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3256,14 +3247,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2197 "Python/bytecodes.c" + #line 2188 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3263 "Python/generated_cases.c.h" + #line 3254 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2200 "Python/bytecodes.c" + #line 2191 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3267 "Python/generated_cases.c.h" + #line 3258 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3271,7 +3262,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2204 "Python/bytecodes.c" + #line 2195 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3294,11 +3285,11 @@ if (iter == NULL) { goto error; } - #line 3298 "Python/generated_cases.c.h" + #line 3289 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2227 "Python/bytecodes.c" + #line 2218 "Python/bytecodes.c" } - #line 3302 "Python/generated_cases.c.h" + #line 3293 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3309,7 +3300,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2246 "Python/bytecodes.c" + #line 2237 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3340,7 +3331,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3344 "Python/generated_cases.c.h" + #line 3335 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3348,7 +3339,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2279 "Python/bytecodes.c" + #line 2270 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3374,14 +3365,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3378 "Python/generated_cases.c.h" + #line 3369 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2307 "Python/bytecodes.c" + #line 2298 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3401,7 +3392,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3405 "Python/generated_cases.c.h" + #line 3396 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3411,7 +3402,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2329 "Python/bytecodes.c" + #line 2320 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3431,7 +3422,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3435 "Python/generated_cases.c.h" + #line 3426 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3441,7 +3432,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2351 "Python/bytecodes.c" + #line 2342 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3459,7 +3450,7 @@ if (next == NULL) { goto error; } - #line 3463 "Python/generated_cases.c.h" + #line 3454 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3468,7 +3459,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2371 "Python/bytecodes.c" + #line 2362 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3483,14 +3474,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3487 "Python/generated_cases.c.h" + #line 3478 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2388 "Python/bytecodes.c" + #line 2379 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3513,16 +3504,16 @@ Py_DECREF(enter); goto error; } - #line 3517 "Python/generated_cases.c.h" + #line 3508 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2411 "Python/bytecodes.c" + #line 2402 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3526 "Python/generated_cases.c.h" + #line 3517 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3534,7 +3525,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2421 "Python/bytecodes.c" + #line 2412 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3560,16 +3551,16 @@ Py_DECREF(enter); goto error; } - #line 3564 "Python/generated_cases.c.h" + #line 3555 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2447 "Python/bytecodes.c" + #line 2438 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3573 "Python/generated_cases.c.h" + #line 3564 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3581,7 +3572,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2456 "Python/bytecodes.c" + #line 2447 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3602,7 +3593,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3606 "Python/generated_cases.c.h" + #line 3597 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3611,7 +3602,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2479 "Python/bytecodes.c" + #line 2470 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3621,7 +3612,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3625 "Python/generated_cases.c.h" + #line 3616 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3635,7 +3626,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2491 "Python/bytecodes.c" + #line 2482 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3652,7 +3643,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3656 "Python/generated_cases.c.h" + #line 3647 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3666,7 +3657,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2510 "Python/bytecodes.c" + #line 2501 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3676,7 +3667,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3680 "Python/generated_cases.c.h" + #line 3671 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3690,7 +3681,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2522 "Python/bytecodes.c" + #line 2513 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3704,7 +3695,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3708 "Python/generated_cases.c.h" + #line 3699 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3713,16 +3704,16 @@ } TARGET(KW_NAMES) { - #line 2538 "Python/bytecodes.c" + #line 2529 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3721 "Python/generated_cases.c.h" + #line 3712 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2544 "Python/bytecodes.c" + #line 2535 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3735,7 +3726,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3739 "Python/generated_cases.c.h" + #line 3730 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3745,7 +3736,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2589 "Python/bytecodes.c" + #line 2580 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3827,7 +3818,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3831 "Python/generated_cases.c.h" + #line 3822 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3839,7 +3830,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2677 "Python/bytecodes.c" + #line 2668 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3849,7 +3840,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3853 "Python/generated_cases.c.h" + #line 3844 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3858,7 +3849,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2689 "Python/bytecodes.c" + #line 2680 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3884,7 +3875,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3888 "Python/generated_cases.c.h" + #line 3879 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3892,7 +3883,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2717 "Python/bytecodes.c" + #line 2708 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3928,7 +3919,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3932 "Python/generated_cases.c.h" + #line 3923 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3936,7 +3927,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2755 "Python/bytecodes.c" + #line 2746 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3946,7 +3937,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3950 "Python/generated_cases.c.h" + #line 3941 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3959,7 +3950,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2767 "Python/bytecodes.c" + #line 2758 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3970,7 +3961,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3974 "Python/generated_cases.c.h" + #line 3965 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3984,7 +3975,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2781 "Python/bytecodes.c" + #line 2772 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3995,7 +3986,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3999 "Python/generated_cases.c.h" + #line 3990 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4009,7 +4000,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2795 "Python/bytecodes.c" + #line 2786 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4031,7 +4022,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4035 "Python/generated_cases.c.h" + #line 4026 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4045,7 +4036,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2820 "Python/bytecodes.c" + #line 2811 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4073,7 +4064,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4077 "Python/generated_cases.c.h" + #line 4068 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4087,7 +4078,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2851 "Python/bytecodes.c" + #line 2842 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4119,7 +4110,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4123 "Python/generated_cases.c.h" + #line 4114 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4133,7 +4124,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2886 "Python/bytecodes.c" + #line 2877 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4165,7 +4156,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4169 "Python/generated_cases.c.h" + #line 4160 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4179,7 +4170,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2921 "Python/bytecodes.c" + #line 2912 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4204,7 +4195,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4208 "Python/generated_cases.c.h" + #line 4199 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4217,7 +4208,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2948 "Python/bytecodes.c" + #line 2939 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4244,7 +4235,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4248 "Python/generated_cases.c.h" + #line 4239 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4256,7 +4247,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2978 "Python/bytecodes.c" + #line 2969 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4274,14 +4265,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4278 "Python/generated_cases.c.h" + #line 4269 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2998 "Python/bytecodes.c" + #line 2989 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4312,7 +4303,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4316 "Python/generated_cases.c.h" + #line 4307 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4325,7 +4316,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3032 "Python/bytecodes.c" + #line 3023 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4354,7 +4345,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4358 "Python/generated_cases.c.h" + #line 4349 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4367,7 +4358,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3064 "Python/bytecodes.c" + #line 3055 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4396,7 +4387,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4400 "Python/generated_cases.c.h" + #line 4391 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4409,7 +4400,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3096 "Python/bytecodes.c" + #line 3087 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4437,7 +4428,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4441 "Python/generated_cases.c.h" + #line 4432 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4447,9 +4438,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3127 "Python/bytecodes.c" + #line 3118 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4453 "Python/generated_cases.c.h" + #line 4444 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4458,7 +4449,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3131 "Python/bytecodes.c" + #line 3122 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4501,14 +4492,14 @@ else { result = PyObject_Call(func, callargs, kwargs); } - #line 4505 "Python/generated_cases.c.h" + #line 4496 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3174 "Python/bytecodes.c" + #line 3165 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4512 "Python/generated_cases.c.h" + #line 4503 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4523,7 +4514,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3184 "Python/bytecodes.c" + #line 3175 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4552,14 +4543,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4556 "Python/generated_cases.c.h" + #line 4547 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3215 "Python/bytecodes.c" + #line 3206 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4580,7 +4571,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4584 "Python/generated_cases.c.h" + #line 4575 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4588,15 +4579,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3238 "Python/bytecodes.c" + #line 3229 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4594 "Python/generated_cases.c.h" + #line 4585 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3240 "Python/bytecodes.c" + #line 3231 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4600 "Python/generated_cases.c.h" + #line 4591 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4607,7 +4598,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3244 "Python/bytecodes.c" + #line 3235 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4642,7 +4633,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4646 "Python/generated_cases.c.h" + #line 4637 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4651,10 +4642,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3281 "Python/bytecodes.c" + #line 3272 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4658 "Python/generated_cases.c.h" + #line 4649 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4666,7 +4657,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3286 "Python/bytecodes.c" + #line 3277 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4681,12 +4672,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4685 "Python/generated_cases.c.h" + #line 4676 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3301 "Python/bytecodes.c" + #line 3292 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4690 "Python/generated_cases.c.h" + #line 4681 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4696,16 +4687,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3306 "Python/bytecodes.c" + #line 3297 "Python/bytecodes.c" assert(oparg >= 2); - #line 4702 "Python/generated_cases.c.h" + #line 4693 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3310 "Python/bytecodes.c" + #line 3301 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4725,11 +4716,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4729 "Python/generated_cases.c.h" + #line 4720 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3332 "Python/bytecodes.c" + #line 3323 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4741,26 +4732,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4745 "Python/generated_cases.c.h" + #line 4736 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3346 "Python/bytecodes.c" + #line 3337 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4751 "Python/generated_cases.c.h" + #line 4742 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3350 "Python/bytecodes.c" + #line 3341 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4758 "Python/generated_cases.c.h" + #line 4749 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3355 "Python/bytecodes.c" + #line 3346 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4769,12 +4760,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4773 "Python/generated_cases.c.h" + #line 4764 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3366 "Python/bytecodes.c" + #line 3357 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4783,12 +4774,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4787 "Python/generated_cases.c.h" + #line 4778 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3377 "Python/bytecodes.c" + #line 3368 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4801,12 +4792,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4805 "Python/generated_cases.c.h" + #line 4796 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3392 "Python/bytecodes.c" + #line 3383 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4819,30 +4810,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4823 "Python/generated_cases.c.h" + #line 4814 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3407 "Python/bytecodes.c" + #line 3398 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4834 "Python/generated_cases.c.h" + #line 4825 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3415 "Python/bytecodes.c" + #line 3406 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4841 "Python/generated_cases.c.h" + #line 4832 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3420 "Python/bytecodes.c" + #line 3411 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4848 "Python/generated_cases.c.h" + #line 4839 "Python/generated_cases.c.h" } diff --git a/Python/symtable.c b/Python/symtable.c index d71972f42af002..94094a11b30185 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1172,6 +1172,15 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, } if (current_type == ClassBlock) { st->st_cur->ste_type_params_in_class = 1; + _Py_DECLARE_STR(class_dict, ".class_dict"); + if (!symtable_add_def(st, &_Py_STR(class_dict), + DEF_PARAM, lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } + if (!symtable_add_def(st, &_Py_STR(class_dict), + USE, lineno, col_offset, end_lineno, end_col_offset)) { + return 0; + } } if (kind == AsyncFunctionDef_kind || kind == FunctionDef_kind || kind == ClassDef_kind) { _Py_DECLARE_STR(type_params, ".type_params"); @@ -1391,12 +1400,13 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) } break; } - case TypeAlias_kind: + case TypeAlias_kind: { VISIT(st, expr, s->v.TypeAlias.name); assert(s->v.TypeAlias.name->kind == Name_kind); PyObject *name = s->v.TypeAlias.name->v.Name.id; int is_in_class = st->st_cur->ste_type == ClassBlock; - if (asdl_seq_LEN(s->v.TypeAlias.typeparams) > 0) { + int is_generic = asdl_seq_LEN(s->v.TypeAlias.typeparams) > 0; + if (is_generic) { if (!symtable_enter_typeparam_block( st, name, (void *)s->v.TypeAlias.typeparams, @@ -1413,11 +1423,12 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) VISIT(st, expr, s->v.TypeAlias.value); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); - if (asdl_seq_LEN(s->v.TypeAlias.typeparams) > 0) { + if (is_generic) { if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); } break; + } case Return_kind: if (s->v.Return.value) { VISIT(st, expr, s->v.Return.value); From d0fa718417c8f90e0e7df8529e2325b1c21fe1e4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 28 Apr 2023 17:47:25 -0700 Subject: [PATCH 142/200] fix WASM --- Lib/test/test_type_params.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index f7e897f3512fcb..50bdc205bcb617 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -1,6 +1,7 @@ import asyncio import textwrap import unittest +from test.support import requires_working_socket from typing import Any, Sequence, TypeVar, TypeVarTuple, ParamSpec @@ -445,6 +446,7 @@ def generator2[B](): self.assertIsInstance(c, TypeVar) self.assertEqual(c.__name__, "C") + @requires_working_socket() def test_typevar_coroutine(self): def get_coroutine[A](): async def coroutine[B](): From c3d6464aae2c188574b2153460d20ecf87e7e6af Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 29 Apr 2023 11:44:49 -0700 Subject: [PATCH 143/200] Fix compiler warning --- Modules/_typingmodule.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/_typingmodule.c b/Modules/_typingmodule.c index 9623336d70bb7b..327db5753979f0 100644 --- a/Modules/_typingmodule.c +++ b/Modules/_typingmodule.c @@ -1,6 +1,8 @@ /* typing accelerator C extension: _typing module. */ +#ifndef Py_BUILD_CORE #define Py_BUILD_CORE +#endif #include "Python.h" #include "internal/pycore_interp.h" From f58058370cbb4a76b112bc22306ba8df7bfa5db2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 29 Apr 2023 17:19:37 -0700 Subject: [PATCH 144/200] use check_syntax_error --- Lib/test/test_type_aliases.py | 14 ++++---- Lib/test/test_type_params.py | 60 +++++++++++------------------------ 2 files changed, 25 insertions(+), 49 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 7e645a4eed75d0..b1076bd6c84283 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -1,15 +1,15 @@ import types import unittest +from test.support import check_syntax_error -from typing import Callable, TypeAliasType +from typing import Callable, TypeAliasType, get_args, get_origin from .test_type_params import run_code class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): - with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): - run_code("""type TA1[A, **A] = None""") + check_syntax_error(self, """type TA1[A, **A] = None""", "duplicate type parameter 'A'") def test_name_non_collision_02(self): run_code("""type TA1[A] = lambda A: None""") @@ -24,10 +24,10 @@ class Outer[A]: class TypeParamsAccessTest(unittest.TestCase): def test_alias_access_01(self): - run_code("""\ - type TA1[A, B] = dict[A, B] - """ - ) + ns = run_code("type TA1[A, B] = dict[A, B]") + alias = ns["TA1"] + self.assertIsInstance(alias, TypeAliasType) + self.assertEqual(alias.__type_params__, get_args(alias.__value__)) def test_alias_access_02(self): run_code("""\ diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 50bdc205bcb617..8ae413501926f0 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -1,7 +1,7 @@ import asyncio import textwrap import unittest -from test.support import requires_working_socket +from test.support import requires_working_socket, check_syntax_error from typing import Any, Sequence, TypeVar, TypeVarTuple, ParamSpec @@ -14,8 +14,7 @@ def run_code(code: str) -> dict[str, Any]: class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): - with self.assertRaisesRegex(SyntaxError, "duplicate type parameter 'A'"): - run_code("""def func[**A, A](): ...""") + check_syntax_error(self, """def func[**A, A](): ...""") def test_name_non_collision_02(self): run_code("""def func[A](A): ...""") @@ -95,28 +94,17 @@ def inner[X](): ) def test_disallowed_expressions(self): - with self.assertRaises(SyntaxError): - run_code("type X = (yield)") - with self.assertRaises(SyntaxError): - run_code("type X = (yield from x)") - with self.assertRaises(SyntaxError): - run_code("type X = (await 42)") - with self.assertRaises(SyntaxError): - run_code("async def f(): type X = (yield)") - with self.assertRaises(SyntaxError): - run_code("type X = (y := 3)") - with self.assertRaises(SyntaxError): - run_code("class X[T: (yield)]: pass") - with self.assertRaises(SyntaxError): - run_code("class X[T: (yield from x)]: pass") - with self.assertRaises(SyntaxError): - run_code("class X[T: (await 42)]: pass") - with self.assertRaises(SyntaxError): - run_code("class X[T: (y := 3)]: pass") - with self.assertRaises(SyntaxError): - run_code("class X[T](y := Sequence[T]): pass") - with self.assertRaises(SyntaxError): - run_code("def f[T](y: (x := Sequence[T])): pass") + check_syntax_error(self, "type X = (yield)") + check_syntax_error(self, "type X = (yield from x)") + check_syntax_error(self, "type X = (await 42)") + check_syntax_error(self, "async def f(): type X = (yield)") + check_syntax_error(self, "type X = (y := 3)") + check_syntax_error(self, "class X[T: (yield)]: pass") + check_syntax_error(self, "class X[T: (yield from x)]: pass") + check_syntax_error(self, "class X[T: (await 42)]: pass") + check_syntax_error(self, "class X[T: (y := 3)]: pass") + check_syntax_error(self, "class X[T](y := Sequence[T]): pass") + check_syntax_error(self, "def f[T](y: (x := Sequence[T])): pass") class TypeParamsAccessTest(unittest.TestCase): @@ -247,12 +235,10 @@ class C[T]: def test_nonlocal(self): code = """\ def outer2[T](): - def inner1(): nonlocal T """ - with self.assertRaisesRegex(SyntaxError, "nonlocal binding not allowed for type parameter 'T'"): - run_code(code) + check_syntax_error(self, textwrap.dedent(code)) def test_reference_previous_typevar(self): def func[S, T: Sequence[S]](): @@ -466,13 +452,8 @@ async def coroutine[B](): class TypeParamsTypeVarTupleTest(unittest.TestCase): def test_typevartuple_01(self): - code = """\ - def func1[*A: str](): - return (A, B, C) - """ - - with self.assertRaisesRegex(SyntaxError, r"expected '\('"): - run_code(code) + code = """def func1[*A: str](): return (A, B, C)""" + check_syntax_error(self, code, r"expected '\('") def test_typevartuple_02(self): def func1[*A](): @@ -484,13 +465,8 @@ def func1[*A](): class TypeParamsTypeVarParamSpec(unittest.TestCase): def test_paramspec_01(self): - code = """\ - def func1[**A: str](): - return (A, B, C) - """ - - with self.assertRaisesRegex(SyntaxError, r"expected '\('"): - run_code(code) + code = """def func1[**A: str](): return (A, B, C)""" + check_syntax_error(self, code, r"expected '\('") def test_paramspec_02(self): def func1[**A](): From 17c80600d615a7cfc34bee1362fd7a12ce233b26 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 29 Apr 2023 17:43:53 -0700 Subject: [PATCH 145/200] Better error messages for illegal bounds/constraints --- Grammar/python.gram | 10 +++++ Lib/test/test_type_params.py | 28 ++++++++++++-- Parser/parser.c | 73 +++++++++++++++++++++++++++++++++++- 3 files changed, 106 insertions(+), 5 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 45fa7766be1318..90cb056038416d 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -646,7 +646,17 @@ type_param_seq[asdl_typeparam_seq*]: a[asdl_typeparam_seq*]=','.type_param+ [',' type_param[typeparam_ty] (memo): | a=NAME b=[type_param_bound] { _PyAST_TypeVar(a->v.Name.id, b, EXTRA) } + | '*' a=NAME colon=":" e=expression { + RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind + ? "cannot use constraints with TypeVarTuple" + : "cannot use bound with TypeVarTuple") + } | '*' a=NAME { _PyAST_TypeVarTuple(a->v.Name.id, EXTRA) } + | '**' a=NAME colon=":" e=expression { + RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind + ? "cannot use constraints with ParamSpec" + : "cannot use bound with ParamSpec") + } | '**' a=NAME { _PyAST_ParamSpec(a->v.Name.id, EXTRA) } type_param_bound[expr_ty]: ":" e=expression { e } diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 8ae413501926f0..f28317485e7896 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -452,8 +452,18 @@ async def coroutine[B](): class TypeParamsTypeVarTupleTest(unittest.TestCase): def test_typevartuple_01(self): - code = """def func1[*A: str](): return (A, B, C)""" - check_syntax_error(self, code, r"expected '\('") + code = """def func1[*A: str](): pass""" + check_syntax_error(self, code, "cannot use bound with TypeVarTuple") + code = """def func1[*A: (int, str)](): pass""" + check_syntax_error(self, code, "cannot use constraints with TypeVarTuple") + code = """class X[*A: str]: pass""" + check_syntax_error(self, code, "cannot use bound with TypeVarTuple") + code = """class X[*A: (int, str)]: pass""" + check_syntax_error(self, code, "cannot use constraints with TypeVarTuple") + code = """type X[*A: str] = int""" + check_syntax_error(self, code, "cannot use bound with TypeVarTuple") + code = """type X[*A: (int, str)] = int""" + check_syntax_error(self, code, "cannot use constraints with TypeVarTuple") def test_typevartuple_02(self): def func1[*A](): @@ -465,8 +475,18 @@ def func1[*A](): class TypeParamsTypeVarParamSpec(unittest.TestCase): def test_paramspec_01(self): - code = """def func1[**A: str](): return (A, B, C)""" - check_syntax_error(self, code, r"expected '\('") + code = """def func1[**A: str](): pass""" + check_syntax_error(self, code, "cannot use bound with ParamSpec") + code = """def func1[**A: (int, str)](): pass""" + check_syntax_error(self, code, "cannot use constraints with ParamSpec") + code = """class X[**A: str]: pass""" + check_syntax_error(self, code, "cannot use bound with ParamSpec") + code = """class X[**A: (int, str)]: pass""" + check_syntax_error(self, code, "cannot use constraints with ParamSpec") + code = """type X[**A: str] = int""" + check_syntax_error(self, code, "cannot use bound with ParamSpec") + code = """type X[**A: (int, str)] = int""" + check_syntax_error(self, code, "cannot use constraints with ParamSpec") def test_paramspec_02(self): def func1[**A](): diff --git a/Parser/parser.c b/Parser/parser.c index 84687b943f6273..c8ba9bfa499c7d 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -10750,7 +10750,12 @@ type_param_seq_rule(Parser *p) return _res; } -// type_param: NAME type_param_bound? | '*' NAME | '**' NAME +// type_param: +// | NAME type_param_bound? +// | '*' NAME ":" expression +// | '*' NAME +// | '**' NAME ":" expression +// | '**' NAME static typeparam_ty type_param_rule(Parser *p) { @@ -10813,6 +10818,39 @@ type_param_rule(Parser *p) D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME type_param_bound?")); } + { // '*' NAME ":" expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' NAME \":\" expression")); + Token * _literal; + expr_ty a; + Token * colon; + expr_ty e; + if ( + (_literal = _PyPegen_expect_token(p, 16)) // token='*' + && + (a = _PyPegen_name_token(p)) // NAME + && + (colon = _PyPegen_expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' NAME \":\" expression")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( colon , e -> kind == Tuple_kind ? "cannot use constraints with TypeVarTuple" : "cannot use bound with TypeVarTuple" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME \":\" expression")); + } { // '*' NAME if (p->error_indicator) { p->level--; @@ -10849,6 +10887,39 @@ type_param_rule(Parser *p) D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' NAME")); } + { // '**' NAME ":" expression + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> type_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' NAME \":\" expression")); + Token * _literal; + expr_ty a; + Token * colon; + expr_ty e; + if ( + (_literal = _PyPegen_expect_token(p, 35)) // token='**' + && + (a = _PyPegen_name_token(p)) // NAME + && + (colon = _PyPegen_expect_token(p, 11)) // token=':' + && + (e = expression_rule(p)) // expression + ) + { + D(fprintf(stderr, "%*c+ type_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' NAME \":\" expression")); + _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( colon , e -> kind == Tuple_kind ? "cannot use constraints with ParamSpec" : "cannot use bound with ParamSpec" ); + if (_res == NULL && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s type_param[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' NAME \":\" expression")); + } { // '**' NAME if (p->error_indicator) { p->level--; From f4ea500baf44010333a862eba135b1ab48d99631 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 29 Apr 2023 20:10:03 -0700 Subject: [PATCH 146/200] Add CHECK_VERSION for type param lists --- Grammar/python.gram | 3 ++- Lib/test/test_ast.py | 12 ++++++++++++ Parser/parser.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index 90cb056038416d..c79207b9cb51a4 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -640,7 +640,8 @@ type_alias[stmt_ty]: # Type parameter declaration # -------------------------- -type_params[asdl_typeparam_seq*]: '[' t=type_param_seq ']' { t } +type_params[asdl_typeparam_seq*]: '[' t=type_param_seq ']' { + CHECK_VERSION(asdl_typeparam_seq *, 12, "Type parameter lists are", t) } type_param_seq[asdl_typeparam_seq*]: a[asdl_typeparam_seq*]=','.type_param+ [','] { a } diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py index 0e57ffbff9b852..580449bdd18fac 100644 --- a/Lib/test/test_ast.py +++ b/Lib/test/test_ast.py @@ -802,6 +802,18 @@ def test_exception_groups_feature_version(self): with self.assertRaises(SyntaxError): ast.parse(code, feature_version=(3, 10)) + def test_type_params_feature_version(self): + samples = [ + "type X = int", + "class X[T]: pass", + "def f[T](): pass", + ] + for sample in samples: + with self.subTest(sample): + ast.parse(sample) + with self.assertRaises(SyntaxError): + ast.parse(sample, feature_version=(3, 11)) + def test_invalid_major_feature_version(self): with self.assertRaises(ValueError): ast.parse('pass', feature_version=(2, 7)) diff --git a/Parser/parser.c b/Parser/parser.c index c8ba9bfa499c7d..894846714eff94 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -10684,7 +10684,7 @@ type_params_rule(Parser *p) ) { D(fprintf(stderr, "%*c+ type_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' type_param_seq ']'")); - _res = t; + _res = CHECK_VERSION ( asdl_typeparam_seq* , 12 , "Type parameter lists are" , t ); if (_res == NULL && PyErr_Occurred()) { p->error_indicator = 1; p->level--; From 827b9e55554f4c0ae8b18244e91384addf255388 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 2 May 2023 19:13:28 -0700 Subject: [PATCH 147/200] Test that super() works correctly within a hidden function --- Lib/test/test_type_params.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index f28317485e7896..74454d1ce078a9 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -247,6 +247,18 @@ def func[S, T: Sequence[S]](): S, T = func.__type_params__ self.assertEqual(T.__bound__, Sequence[S]) + def test_super(self): + class Base: + def meth(self): + return "base" + + class Child(Base): + def meth[T](self) -> T: + return super().meth() + "child" + + c = Child() + self.assertEqual(c.meth(), "basechild") + def global_generic_func[T](): pass From 71cef781fb5ed9ccc7a5342ae1d5890f3bd76cae Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 6 May 2023 18:08:01 -0700 Subject: [PATCH 148/200] Use a __classdict__ cell to store the class namespace (#3) This is an idea by Larry Hastings and Carl Meyer to deal with the edge case where a class's namespace is modified after the class body executes. We introduce a new cell, `__classcell__`, that holds a reference to the class namespace. We read from this cell to get the classdict in LOAD_CLASSDICT_OR_GLOBAL and LOAD_CLASSDICT_OR_DEREF. --- Include/cpython/funcobject.h | 6 - .../pycore_global_objects_fini_generated.h | 3 +- Include/internal/pycore_global_strings.h | 3 +- Include/internal/pycore_intrinsics.h | 9 +- .../internal/pycore_runtime_init_generated.h | 3 +- Include/internal/pycore_symtable.h | 2 + .../internal/pycore_unicodeobject_generated.h | 6 + Lib/opcode.py | 1 - Lib/test/test_sys.py | 2 +- Lib/test/test_type_params.py | 9 + Objects/funcobject.c | 26 - Objects/typeobject.c | 34 +- Python/bytecodes.c | 28 +- Python/compile.c | 97 +-- Python/generated_cases.c.h | 620 +++++++++--------- Python/intrinsics.c | 1 - Python/opcode_metadata.h | 4 +- Python/symtable.c | 26 +- 18 files changed, 436 insertions(+), 444 deletions(-) diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index 86ab0b404305c0..4e5a3624addb9c 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -42,7 +42,6 @@ typedef struct { PyObject *func_module; /* The __module__ attribute, can be anything */ PyObject *func_annotations; /* Annotations, a dict or NULL */ PyObject *func_typeparams; /* Tuple of active type variables or NULL */ - PyObject *func_class_dict; /* Class dict, a dict or NULL */ vectorcallfunc vectorcall; /* Version number for use by specializer. * Can set to non-zero when we want to specialize. @@ -102,11 +101,6 @@ static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) { } #define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func)) -static inline PyObject* PyFunction_GET_CLASS_DICT(PyObject *func) { - return _PyFunction_CAST(func)->func_class_dict; -} -#define PyFunction_GET_CLASS_DICT(func) PyFunction_GET_CLASS_DICT(_PyObject_CAST(func)) - static inline PyObject* PyFunction_GET_MODULE(PyObject *func) { return _PyFunction_CAST(func)->func_module; } diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 0d3027950a7068..d04e0059070f51 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -551,7 +551,6 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_setcomp)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_string)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(anon_unknown)); - _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(class_dict)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(close_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_close_br)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_STR(dbl_open_br)); @@ -606,6 +605,8 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__class__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__class_getitem__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__classcell__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__classdict__)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__classdictcell__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__complex__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__contains__)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(__copy__)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index f988e4d7433a04..d6ec1f95f32c9f 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -36,7 +36,6 @@ struct _Py_global_strings { STRUCT_FOR_STR(anon_setcomp, "") STRUCT_FOR_STR(anon_string, "") STRUCT_FOR_STR(anon_unknown, "") - STRUCT_FOR_STR(class_dict, ".class_dict") STRUCT_FOR_STR(close_br, "}") STRUCT_FOR_STR(dbl_close_br, "}}") STRUCT_FOR_STR(dbl_open_br, "{{") @@ -94,6 +93,8 @@ struct _Py_global_strings { STRUCT_FOR_ID(__class__) STRUCT_FOR_ID(__class_getitem__) STRUCT_FOR_ID(__classcell__) + STRUCT_FOR_ID(__classdict__) + STRUCT_FOR_ID(__classdictcell__) STRUCT_FOR_ID(__complex__) STRUCT_FOR_ID(__contains__) STRUCT_FOR_ID(__copy__) diff --git a/Include/internal/pycore_intrinsics.h b/Include/internal/pycore_intrinsics.h index 4f921b78cfce8e..39f15681b7b24b 100644 --- a/Include/internal/pycore_intrinsics.h +++ b/Include/internal/pycore_intrinsics.h @@ -20,12 +20,11 @@ /* Binary Functions: */ #define INTRINSIC_2_INVALID 0 #define INTRINSIC_PREP_RERAISE_STAR 1 -#define INTRINSIC_SET_CLASS_DICT 2 -#define INTRINSIC_TYPEVAR_WITH_BOUND 3 -#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 4 -#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 5 +#define INTRINSIC_TYPEVAR_WITH_BOUND 2 +#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3 +#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 4 -#define MAX_INTRINSIC_2 5 +#define MAX_INTRINSIC_2 4 typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value); typedef PyObject *(*instrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2); diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index d9b478bae35dcb..8432067e8651c5 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -542,7 +542,6 @@ extern "C" { INIT_STR(anon_setcomp, ""), \ INIT_STR(anon_string, ""), \ INIT_STR(anon_unknown, ""), \ - INIT_STR(class_dict, ".class_dict"), \ INIT_STR(close_br, "}"), \ INIT_STR(dbl_close_br, "}}"), \ INIT_STR(dbl_open_br, "{{"), \ @@ -600,6 +599,8 @@ extern "C" { INIT_ID(__class__), \ INIT_ID(__class_getitem__), \ INIT_ID(__classcell__), \ + INIT_ID(__classdict__), \ + INIT_ID(__classdictcell__), \ INIT_ID(__complex__), \ INIT_ID(__contains__), \ INIT_ID(__copy__), \ diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 7ec9e6d2789d1e..800d0bafa8cb49 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -66,6 +66,8 @@ typedef struct _symtable_entry { unsigned ste_needs_class_closure : 1; /* for class scopes, true if a closure over __class__ should be created */ + unsigned ste_needs_classdict : 1; /* for class scopes, true if a closure + over the class dict should be created */ unsigned ste_comp_iter_target : 1; /* true if visiting comprehension target */ unsigned ste_type_params_in_class : 1; /* true if this is a type parameters block inside a class */ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 2ffb8ce7634f34..6076634dd4264a 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -120,6 +120,12 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(__classcell__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(__classdict__); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(__classdictcell__); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(__complex__); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Lib/opcode.py b/Lib/opcode.py index 7fe8b934dc138e..83f2e5b698e5b8 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -329,7 +329,6 @@ def pseudo_op(name, op, real_ops): _intrinsic_2_descs = [ "INTRINSIC_2_INVALID", "INTRINSIC_PREP_RERAISE_STAR", - "INTRINSIC_SET_CLASS_DICT", "INTRINSIC_TYPEVAR_WITH_BOUND", "INTRINSIC_TYPEVAR_WITH_CONSTRAINTS", "INTRINSIC_SET_FUNCTION_TYPE_PARAMS", diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index c266f94b51b5dc..64af630aa26f34 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1449,7 +1449,7 @@ def func(): check(x, size('3Pii3c7P2ic??2P')) # function def func(): pass - check(func, size('16Pi')) + check(func, size('15Pi')) class c(): @staticmethod def foo(): diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 74454d1ce078a9..a82cadb94ded96 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -347,6 +347,15 @@ def foo[T: glb, U: cls](self): ... assert U.__bound__ == "class" """) + def test_modified_later(self): + class X: + T = int + def foo[U: T](self): ... + type Alias = T + X.T = float + self.assertIs(X.foo.__type_params__[0].__bound__, float) + self.assertIs(X.Alias.__value__, float) + class ManglingTest(unittest.TestCase): def test_mangling(self): diff --git a/Objects/funcobject.c b/Objects/funcobject.c index df9f7c539f376b..82e221e43cc9ac 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -119,7 +119,6 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr) op->func_defaults = Py_XNewRef(constr->fc_defaults); op->func_kwdefaults = Py_XNewRef(constr->fc_kwdefaults); op->func_closure = Py_XNewRef(constr->fc_closure); - op->func_class_dict = NULL; op->func_doc = Py_NewRef(Py_None); op->func_dict = NULL; op->func_weakreflist = NULL; @@ -205,7 +204,6 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname op->func_module = module; op->func_annotations = NULL; op->func_typeparams = NULL; - op->func_class_dict = NULL; op->vectorcall = _PyFunction_Vectorcall; op->func_version = 0; _PyObject_GC_TRACK(op); @@ -266,16 +264,6 @@ PyFunction_GetGlobals(PyObject *op) return ((PyFunctionObject *) op) -> func_globals; } -PyObject * -PyFunction_GetClassDict(PyObject *op) -{ - if (!PyFunction_Check(op)) { - PyErr_BadInternalCall(); - return NULL; - } - return ((PyFunctionObject *) op) -> func_class_dict; -} - PyObject * PyFunction_GetModule(PyObject *op) { @@ -466,7 +454,6 @@ static PyMemberDef func_memberlist[] = { {"__globals__", T_OBJECT, OFF(func_globals), READONLY}, {"__module__", T_OBJECT, OFF(func_module), 0}, {"__builtins__", T_OBJECT, OFF(func_builtins), READONLY}, - {"__class_dict__",T_OBJECT, OFF(func_class_dict), READONLY}, {NULL} /* Sentinel */ }; @@ -689,17 +676,6 @@ _Py_set_function_type_params(PyThreadState *unused, PyObject *func, return Py_NewRef(func); } -PyObject * -_Py_set_function_class_dict(PyThreadState* unused, PyObject *func, - PyObject *class_dict) -{ - assert(PyFunction_Check(func)); - assert(PyDict_Check(class_dict)); - PyFunctionObject *f = (PyFunctionObject *)func; - Py_XSETREF(f->func_class_dict, Py_NewRef(class_dict)); - return Py_NewRef(func); -} - static PyGetSetDef func_getsetlist[] = { {"__code__", (getter)func_get_code, (setter)func_set_code}, {"__defaults__", (getter)func_get_defaults, @@ -833,7 +809,6 @@ func_clear(PyFunctionObject *op) Py_CLEAR(op->func_closure); Py_CLEAR(op->func_annotations); Py_CLEAR(op->func_typeparams); - Py_CLEAR(op->func_class_dict); // Don't Py_CLEAR(op->func_code), since code is always required // to be non-NULL. Similarly, name and qualname shouldn't be NULL. // However, name and qualname could be str subclasses, so they @@ -889,7 +864,6 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) Py_VISIT(f->func_closure); Py_VISIT(f->func_annotations); Py_VISIT(f->func_typeparams); - Py_VISIT(f->func_class_dict); Py_VISIT(f->func_qualname); return 0; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 58ff7e92ed62d1..519bdc5c1500ed 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3010,11 +3010,12 @@ type_new_copy_slots(type_new_ctx *ctx, PyObject *dict) goto error; } if (r > 0) { - /* CPython inserts __qualname__ and __classcell__ (when needed) + /* CPython inserts these names (when needed) into the namespace when creating a class. They will be deleted below so won't act as class variables. */ if (!_PyUnicode_Equal(slot, &_Py_ID(__qualname__)) && - !_PyUnicode_Equal(slot, &_Py_ID(__classcell__))) + !_PyUnicode_Equal(slot, &_Py_ID(__classcell__)) && + !_PyUnicode_Equal(slot, &_Py_ID(__classdictcell__))) { PyErr_Format(PyExc_ValueError, "%R in __slots__ conflicts with class variable", @@ -3465,6 +3466,32 @@ type_new_set_classcell(PyTypeObject *type) return 0; } +static int +type_new_set_classdictcell(PyTypeObject *type) +{ + PyObject *dict = lookup_tp_dict(type); + PyObject *cell = PyDict_GetItemWithError(dict, &_Py_ID(__classdictcell__)); + if (cell == NULL) { + if (PyErr_Occurred()) { + return -1; + } + return 0; + } + + /* At least one method requires a reference to its defining class */ + if (!PyCell_Check(cell)) { + PyErr_Format(PyExc_TypeError, + "__classdictcell__ must be a nonlocal cell, not %.200R", + Py_TYPE(cell)); + return -1; + } + + (void)PyCell_Set(cell, (PyObject *)dict); + if (PyDict_DelItem(dict, &_Py_ID(__classdictcell__)) < 0) { + return -1; + } + return 0; +} static int type_new_set_attrs(const type_new_ctx *ctx, PyTypeObject *type) @@ -3509,6 +3536,9 @@ type_new_set_attrs(const type_new_ctx *ctx, PyTypeObject *type) if (type_new_set_classcell(type) < 0) { return -1; } + if (type_new_set_classdictcell(type) < 0) { + return -1; + } return 0; } diff --git a/Python/bytecodes.c b/Python/bytecodes.c index b8c4fde64d0980..2e221c1107a142 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1170,20 +1170,8 @@ dummy_func( } } - op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (-- mad_or_class_dict, name)) { + op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (mad_or_class_dict -- mad_or_class_dict, name)) { name = GETITEM(frame->f_code->co_names, oparg); - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no function defined when loading %R from class dict", name); - goto error; - } - mad_or_class_dict = func->func_class_dict; - if (mad_or_class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no class dict set when loading %R", name); - goto error; - } } op(_LOAD_NAME_COMMON, (mad_or_class_dict, name -- v)) { @@ -1368,19 +1356,7 @@ dummy_func( class_dict = LOCALS(); } - op(_LOAD_CLASSDICT_OR_DEREF_INTRO, (-- class_dict)) { - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no function defined when loading from class dict"); - goto error; - } - class_dict = func->func_class_dict; - if (class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no class dict set when loading from class dict"); - goto error; - } + op(_LOAD_CLASSDICT_OR_DEREF_INTRO, (class_dict -- class_dict)) { } op(_LOAD_CLASSDEREF_COMMON, (class_dict -- value)) { diff --git a/Python/compile.c b/Python/compile.c index 8cf9c3e5620bfc..a0acf2a39334f3 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -232,6 +232,7 @@ instr_sequence_next_inst(instr_sequence *seq) { &seq->s_allocated, INITIAL_INSTR_SEQUENCE_SIZE, sizeof(instruction))); + assert(seq->s_allocated >= 0); assert(seq->s_used < seq->s_allocated); return seq->s_used++; } @@ -1263,6 +1264,18 @@ compiler_enter_scope(struct compiler *c, identifier name, return ERROR; } } + if (u->u_ste->ste_needs_classdict) { + /* Cook up an implicit __classdict__ cell. */ + int res; + assert(u->u_scope_type == COMPILER_SCOPE_CLASS); + PyObject *index = u->u_ste->ste_needs_class_closure ? _PyLong_GetOne() : _PyLong_GetZero(); + res = PyDict_SetItem(u->u_metadata.u_cellvars, &_Py_ID(__classdict__), + index); + if (res < 0) { + compiler_unit_free(u); + return ERROR; + } + } u->u_metadata.u_freevars = dictbytype(u->u_ste->ste_symbols, FREE, DEF_FREE_CLASS, PyDict_GET_SIZE(u->u_metadata.u_cellvars)); @@ -1723,8 +1736,10 @@ get_ref_type(struct compiler *c, PyObject *name) { int scope; if (c->u->u_scope_type == COMPILER_SCOPE_CLASS && - _PyUnicode_EqualToASCIIString(name, "__class__")) + (_PyUnicode_EqualToASCIIString(name, "__class__") || + _PyUnicode_EqualToASCIIString(name, "__classdict__"))) { return CELL; + } scope = _PyST_GetScope(c->u->u_ste, name); if (scope == 0) { PyErr_Format(PyExc_SystemError, @@ -2121,10 +2136,6 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) return ERROR; } Py_DECREF(co); - if (c->u->u_ste->ste_type_params_in_class) { - ADDOP_I(c, loc, LOAD_FAST, 0); - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); - } int intrinsic = bound->kind == Tuple_kind ? INTRINSIC_TYPEVAR_WITH_CONSTRAINTS @@ -2315,10 +2326,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); - if (is_typeparams_in_class) { - ADDOP(c, loc, LOAD_LOCALS); - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); - } ADDOP_I(c, loc, SWAP, num_typeparam_args + 2); ADDOP(c, loc, POP_TOP); ADDOP_I(c, loc, CALL, num_typeparam_args); @@ -2415,12 +2422,33 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } } + if (c->u->u_ste->ste_needs_classdict) { + ADDOP(c, loc, LOAD_LOCALS); + if (compiler_nameop(c, loc, &_Py_ID(__classdict__), Store) < 0) { + compiler_exit_scope(c); + return ERROR; + } + } /* compile the body proper */ if (compiler_body(c, loc, s->v.ClassDef.body) < 0) { compiler_exit_scope(c); return ERROR; } /* The following code is artificial */ + /* Set __classdictcell__ if necessary */ + if (c->u->u_ste->ste_needs_classdict) { + /* Store __classdictcell__ into class namespace */ + i = compiler_lookup_arg(c->u->u_metadata.u_cellvars, &_Py_ID(__classdict__)); + if (i < 0) { + compiler_exit_scope(c); + return ERROR; + } + ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); + if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store) < 0) { + compiler_exit_scope(c); + return ERROR; + } + } /* Return __classcell__ if it is referenced, otherwise return None */ if (c->u->u_ste->ste_needs_class_closure) { /* Store __classcell__ into class namespace & return it */ @@ -2439,7 +2467,8 @@ compiler_class(struct compiler *c, stmt_ty s) } else { /* No methods referenced __class__, so just return None */ - assert(PyDict_GET_SIZE(c->u->u_metadata.u_cellvars) == 0); + assert(PyDict_GET_SIZE(c->u->u_metadata.u_cellvars) == + c->u->u_ste->ste_needs_classdict ? 1 : 0); ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); } ADDOP_IN_SCOPE(c, NO_LOCATION, RETURN_VALUE); @@ -2493,9 +2522,6 @@ compiler_class(struct compiler *c, stmt_ty s) bases, s->v.ClassDef.keywords)); - // Must be before we exit the scope - int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; - c->u->u_metadata.u_argcount = is_typeparams_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2506,12 +2532,7 @@ compiler_class(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); - if (is_typeparams_in_class) { - ADDOP(c, loc, LOAD_LOCALS); - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); - ADDOP(c, loc, LOAD_LOCALS); - } - ADDOP_I(c, loc, CALL, is_typeparams_in_class); + ADDOP_I(c, loc, CALL, 0); } else { RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, s->v.ClassDef.bases, @@ -2560,7 +2581,6 @@ compiler_typealias(struct compiler *c, stmt_ty s) RETURN_IF_ERROR(compiler_add_const(c->c_const_cache, c->u, Py_None)); VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); - int is_in_class = c->u->u_ste->ste_type_params_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2571,21 +2591,9 @@ compiler_typealias(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); - if (is_in_class) { - if (is_generic) { - ADDOP_I(c, loc, LOAD_FAST, 0); - } - else { - ADDOP(c, loc, LOAD_LOCALS); - } - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); - } ADDOP_I(c, loc, BUILD_TUPLE, 3); ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); if (is_generic) { - // Must be before we exit the scope - int is_typeparams_in_class = c->u->u_ste->ste_type_params_in_class; - c->u->u_metadata.u_argcount = is_typeparams_in_class; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { @@ -2596,12 +2604,7 @@ compiler_typealias(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(co); - if (is_typeparams_in_class) { - ADDOP(c, loc, LOAD_LOCALS); - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_CLASS_DICT); - ADDOP(c, loc, LOAD_LOCALS); - } - ADDOP_I(c, loc, CALL, is_typeparams_in_class); + ADDOP_I(c, loc, CALL, 0); } RETURN_IF_ERROR(compiler_nameop(c, loc, name, Store)); return SUCCESS; @@ -4030,7 +4033,13 @@ compiler_nameop(struct compiler *c, location loc, op = 0; optype = OP_NAME; - scope = _PyST_GetScope(c->u->u_ste, mangled); + if (c->u->u_scope_type == COMPILER_SCOPE_CLASS && + _PyUnicode_EqualToASCIIString(name, "__classdict__")) { + scope = CELL; + } + else { + scope = _PyST_GetScope(c->u->u_ste, mangled); + } switch (scope) { case FREE: dict = c->u->u_metadata.u_freevars; @@ -4068,6 +4077,11 @@ compiler_nameop(struct compiler *c, location loc, } else if (c->u->u_ste->ste_type_params_in_class) { op = LOAD_CLASSDICT_OR_DEREF; + // First load the classdict + if (compiler_addop_o(c->u, loc, LOAD_DEREF, + c->u->u_metadata.u_freevars, &_Py_ID(__classdict__)) < 0) { + return ERROR; + } } else { op = LOAD_DEREF; @@ -4090,6 +4104,11 @@ compiler_nameop(struct compiler *c, location loc, case Load: if (c->u->u_ste->ste_type_params_in_class) { op = LOAD_CLASSDICT_OR_GLOBAL; + // First load the classdict + if (compiler_addop_o(c->u, loc, LOAD_DEREF, + c->u->u_metadata.u_freevars, &_Py_ID(__classdict__)) < 0) { + return ERROR; + } } else { op = LOAD_GLOBAL; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index fa7fa06a783275..70c80152c1eb20 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1634,7 +1634,7 @@ PyObject *name = _tmp_1; PyObject *mad_or_class_dict = _tmp_2; PyObject *v; - #line 1190 "Python/bytecodes.c" + #line 1178 "Python/bytecodes.c" if (PyDict_CheckExact(mad_or_class_dict)) { v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { @@ -1696,25 +1696,13 @@ TARGET(LOAD_CLASSDICT_OR_GLOBAL) { PyObject *_tmp_1; - PyObject *_tmp_2; + PyObject *_tmp_2 = stack_pointer[-1]; { - PyObject *mad_or_class_dict; + PyObject *mad_or_class_dict = _tmp_2; PyObject *name; #line 1174 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no function defined when loading %R from class dict", name); - goto error; - } - mad_or_class_dict = func->func_class_dict; - if (mad_or_class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no class dict set when loading %R", name); - goto error; - } - #line 1718 "Python/generated_cases.c.h" + #line 1706 "Python/generated_cases.c.h" _tmp_2 = mad_or_class_dict; _tmp_1 = name; } @@ -1722,7 +1710,7 @@ PyObject *name = _tmp_1; PyObject *mad_or_class_dict = _tmp_2; PyObject *v; - #line 1190 "Python/bytecodes.c" + #line 1178 "Python/bytecodes.c" if (PyDict_CheckExact(mad_or_class_dict)) { v = PyDict_GetItemWithError(mad_or_class_dict, name); if (v != NULL) { @@ -1774,10 +1762,9 @@ } } } - #line 1778 "Python/generated_cases.c.h" + #line 1766 "Python/generated_cases.c.h" _tmp_2 = v; } - STACK_GROW(1); stack_pointer[-1] = _tmp_2; DISPATCH(); } @@ -1787,7 +1774,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1254 "Python/bytecodes.c" + #line 1242 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1839,7 +1826,7 @@ } } null = NULL; - #line 1843 "Python/generated_cases.c.h" + #line 1830 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1853,7 +1840,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1308 "Python/bytecodes.c" + #line 1296 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1864,7 +1851,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1868 "Python/generated_cases.c.h" + #line 1855 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1879,7 +1866,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1321 "Python/bytecodes.c" + #line 1309 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1894,7 +1881,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1898 "Python/generated_cases.c.h" + #line 1885 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1904,16 +1891,16 @@ } TARGET(DELETE_FAST) { - #line 1338 "Python/bytecodes.c" + #line 1326 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1912 "Python/generated_cases.c.h" + #line 1899 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1344 "Python/bytecodes.c" + #line 1332 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1922,12 +1909,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1926 "Python/generated_cases.c.h" + #line 1913 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1355 "Python/bytecodes.c" + #line 1343 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1938,7 +1925,7 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1942 "Python/generated_cases.c.h" + #line 1929 "Python/generated_cases.c.h" DISPATCH(); } @@ -1946,15 +1933,15 @@ PyObject *_tmp_1; { PyObject *class_dict; - #line 1368 "Python/bytecodes.c" + #line 1356 "Python/bytecodes.c" class_dict = LOCALS(); - #line 1952 "Python/generated_cases.c.h" + #line 1939 "Python/generated_cases.c.h" _tmp_1 = class_dict; } { PyObject *class_dict = _tmp_1; PyObject *value; - #line 1387 "Python/bytecodes.c" + #line 1363 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1986,7 +1973,7 @@ } Py_INCREF(value); } - #line 1990 "Python/generated_cases.c.h" + #line 1977 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(1); @@ -1995,29 +1982,15 @@ } TARGET(LOAD_CLASSDICT_OR_DEREF) { - PyObject *_tmp_1; + PyObject *_tmp_1 = stack_pointer[-1]; { - PyObject *class_dict; - #line 1372 "Python/bytecodes.c" - PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; - if (func == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no function defined when loading from class dict"); - goto error; - } - class_dict = func->func_class_dict; - if (class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no class dict set when loading from class dict"); - goto error; - } - #line 2015 "Python/generated_cases.c.h" + PyObject *class_dict = _tmp_1; _tmp_1 = class_dict; } { PyObject *class_dict = _tmp_1; PyObject *value; - #line 1387 "Python/bytecodes.c" + #line 1363 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -2049,17 +2022,16 @@ } Py_INCREF(value); } - #line 2053 "Python/generated_cases.c.h" + #line 2026 "Python/generated_cases.c.h" _tmp_1 = value; } - STACK_GROW(1); stack_pointer[-1] = _tmp_1; DISPATCH(); } TARGET(LOAD_DEREF) { PyObject *value; - #line 1424 "Python/bytecodes.c" + #line 1400 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -2067,7 +2039,7 @@ if (true) goto error; } Py_INCREF(value); - #line 2071 "Python/generated_cases.c.h" + #line 2043 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -2075,18 +2047,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1434 "Python/bytecodes.c" + #line 1410 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2084 "Python/generated_cases.c.h" + #line 2056 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1441 "Python/bytecodes.c" + #line 1417 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2097,22 +2069,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2101 "Python/generated_cases.c.h" + #line 2073 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1454 "Python/bytecodes.c" + #line 1430 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2110 "Python/generated_cases.c.h" + #line 2082 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1456 "Python/bytecodes.c" + #line 1432 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2116 "Python/generated_cases.c.h" + #line 2088 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2122,10 +2094,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1460 "Python/bytecodes.c" + #line 1436 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2129 "Python/generated_cases.c.h" + #line 2101 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2135,10 +2107,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1465 "Python/bytecodes.c" + #line 1441 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2142 "Python/generated_cases.c.h" + #line 2114 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2148,7 +2120,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1470 "Python/bytecodes.c" + #line 1446 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2159,13 +2131,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2163 "Python/generated_cases.c.h" + #line 2135 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1481 "Python/bytecodes.c" + #line 1457 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2169 "Python/generated_cases.c.h" + #line 2141 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2174,13 +2146,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1488 "Python/bytecodes.c" + #line 1464 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2180 "Python/generated_cases.c.h" + #line 2152 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1490 "Python/bytecodes.c" + #line 1466 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2184 "Python/generated_cases.c.h" + #line 2156 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2188,7 +2160,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1494 "Python/bytecodes.c" + #line 1470 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2203,7 +2175,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2207 "Python/generated_cases.c.h" + #line 2179 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2213,7 +2185,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1511 "Python/bytecodes.c" + #line 1487 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2221,13 +2193,13 @@ if (map == NULL) goto error; - #line 2225 "Python/generated_cases.c.h" + #line 2197 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1519 "Python/bytecodes.c" + #line 1495 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2231 "Python/generated_cases.c.h" + #line 2203 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2235,7 +2207,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1523 "Python/bytecodes.c" + #line 1499 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2275,7 +2247,7 @@ Py_DECREF(ann_dict); } } - #line 2279 "Python/generated_cases.c.h" + #line 2251 "Python/generated_cases.c.h" DISPATCH(); } @@ -2283,7 +2255,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1565 "Python/bytecodes.c" + #line 1541 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2293,14 +2265,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2297 "Python/generated_cases.c.h" + #line 2269 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1575 "Python/bytecodes.c" + #line 1551 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2304 "Python/generated_cases.c.h" + #line 2276 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2308,7 +2280,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1579 "Python/bytecodes.c" + #line 1555 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2316,12 +2288,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2320 "Python/generated_cases.c.h" + #line 2292 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1587 "Python/bytecodes.c" + #line 1563 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2325 "Python/generated_cases.c.h" + #line 2297 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2329,17 +2301,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1593 "Python/bytecodes.c" + #line 1569 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2338 "Python/generated_cases.c.h" + #line 2310 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1598 "Python/bytecodes.c" + #line 1574 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2343 "Python/generated_cases.c.h" + #line 2315 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2349,13 +2321,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1605 "Python/bytecodes.c" + #line 1581 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2359 "Python/generated_cases.c.h" + #line 2331 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2369,7 +2341,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1619 "Python/bytecodes.c" + #line 1595 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2387,16 +2359,16 @@ // handle any case whose performance we care about PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2391 "Python/generated_cases.c.h" + #line 2363 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1637 "Python/bytecodes.c" + #line 1613 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2400 "Python/generated_cases.c.h" + #line 2372 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2414,7 +2386,7 @@ uint32_t class_version = read_u32(&next_instr[1].cache); uint32_t self_type_version = read_u32(&next_instr[3].cache); PyObject *method = read_obj(&next_instr[5].cache); - #line 1644 "Python/bytecodes.c" + #line 1620 "Python/bytecodes.c" DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); DEOPT_IF(((PyTypeObject *)class)->tp_version_tag != class_version, LOAD_SUPER_ATTR); @@ -2425,7 +2397,7 @@ Py_INCREF(res2); Py_DECREF(global_super); Py_DECREF(class); - #line 2429 "Python/generated_cases.c.h" + #line 2401 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2439,7 +2411,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1671 "Python/bytecodes.c" + #line 1647 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2473,9 +2445,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2477 "Python/generated_cases.c.h" + #line 2449 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1705 "Python/bytecodes.c" + #line 1681 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2484,12 +2456,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2488 "Python/generated_cases.c.h" + #line 2460 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1714 "Python/bytecodes.c" + #line 1690 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2493 "Python/generated_cases.c.h" + #line 2465 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2503,7 +2475,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1719 "Python/bytecodes.c" + #line 1695 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2516,7 +2488,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2520 "Python/generated_cases.c.h" + #line 2492 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2531,7 +2503,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1735 "Python/bytecodes.c" + #line 1711 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2544,7 +2516,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2548 "Python/generated_cases.c.h" + #line 2520 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2559,7 +2531,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1751 "Python/bytecodes.c" + #line 1727 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2586,7 +2558,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2590 "Python/generated_cases.c.h" + #line 2562 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2601,7 +2573,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1781 "Python/bytecodes.c" + #line 1757 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2611,7 +2583,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2615 "Python/generated_cases.c.h" + #line 2587 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2626,7 +2598,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1794 "Python/bytecodes.c" + #line 1770 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2638,7 +2610,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2642 "Python/generated_cases.c.h" + #line 2614 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2652,7 +2624,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1809 "Python/bytecodes.c" + #line 1785 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2676,7 +2648,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2680 "Python/generated_cases.c.h" + #line 2652 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2684,7 +2656,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1835 "Python/bytecodes.c" + #line 1811 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2710,7 +2682,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2714 "Python/generated_cases.c.h" + #line 2686 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2718,7 +2690,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1863 "Python/bytecodes.c" + #line 1839 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2736,7 +2708,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2740 "Python/generated_cases.c.h" + #line 2712 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2747,7 +2719,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1883 "Python/bytecodes.c" + #line 1859 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2786,7 +2758,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2790 "Python/generated_cases.c.h" + #line 2762 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2797,7 +2769,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1924 "Python/bytecodes.c" + #line 1900 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2807,7 +2779,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2811 "Python/generated_cases.c.h" + #line 2783 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2819,7 +2791,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1943 "Python/bytecodes.c" + #line 1919 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2832,12 +2804,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2836 "Python/generated_cases.c.h" + #line 2808 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1956 "Python/bytecodes.c" + #line 1932 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2841 "Python/generated_cases.c.h" + #line 2813 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2848,7 +2820,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1960 "Python/bytecodes.c" + #line 1936 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2860,7 +2832,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2864 "Python/generated_cases.c.h" + #line 2836 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2871,7 +2843,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1975 "Python/bytecodes.c" + #line 1951 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2887,7 +2859,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2891 "Python/generated_cases.c.h" + #line 2863 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2898,7 +2870,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1994 "Python/bytecodes.c" + #line 1970 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2911,7 +2883,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2915 "Python/generated_cases.c.h" + #line 2887 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2922,14 +2894,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2009 "Python/bytecodes.c" + #line 1985 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2928 "Python/generated_cases.c.h" + #line 2900 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2011 "Python/bytecodes.c" + #line 1987 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2933 "Python/generated_cases.c.h" + #line 2905 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2939,15 +2911,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2015 "Python/bytecodes.c" + #line 1991 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2945 "Python/generated_cases.c.h" + #line 2917 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2017 "Python/bytecodes.c" + #line 1993 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2951 "Python/generated_cases.c.h" + #line 2923 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2958,12 +2930,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2022 "Python/bytecodes.c" + #line 1998 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2964 "Python/generated_cases.c.h" + #line 2936 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2024 "Python/bytecodes.c" + #line 2000 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2971,10 +2943,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2975 "Python/generated_cases.c.h" + #line 2947 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2032 "Python/bytecodes.c" + #line 2008 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -2983,7 +2955,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 2987 "Python/generated_cases.c.h" + #line 2959 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -2993,21 +2965,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2043 "Python/bytecodes.c" + #line 2019 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 3000 "Python/generated_cases.c.h" + #line 2972 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2046 "Python/bytecodes.c" + #line 2022 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 3007 "Python/generated_cases.c.h" + #line 2979 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2051 "Python/bytecodes.c" + #line 2027 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 3011 "Python/generated_cases.c.h" + #line 2983 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -3016,15 +2988,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2055 "Python/bytecodes.c" + #line 2031 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 3023 "Python/generated_cases.c.h" + #line 2995 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2058 "Python/bytecodes.c" + #line 2034 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 3028 "Python/generated_cases.c.h" + #line 3000 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -3033,29 +3005,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2062 "Python/bytecodes.c" + #line 2038 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 3041 "Python/generated_cases.c.h" + #line 3013 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2068 "Python/bytecodes.c" + #line 2044 "Python/bytecodes.c" JUMPBY(oparg); - #line 3050 "Python/generated_cases.c.h" + #line 3022 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2072 "Python/bytecodes.c" + #line 2048 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 3059 "Python/generated_cases.c.h" + #line 3031 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -3063,7 +3035,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2078 "Python/bytecodes.c" + #line 2054 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3073,9 +3045,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3077 "Python/generated_cases.c.h" + #line 3049 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2088 "Python/bytecodes.c" + #line 2064 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3083,14 +3055,14 @@ if (err < 0) goto pop_1_error; } } - #line 3087 "Python/generated_cases.c.h" + #line 3059 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2098 "Python/bytecodes.c" + #line 2074 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3100,9 +3072,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3104 "Python/generated_cases.c.h" + #line 3076 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2108 "Python/bytecodes.c" + #line 2084 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3110,67 +3082,67 @@ if (err < 0) goto pop_1_error; } } - #line 3114 "Python/generated_cases.c.h" + #line 3086 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2118 "Python/bytecodes.c" + #line 2094 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3123 "Python/generated_cases.c.h" + #line 3095 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2120 "Python/bytecodes.c" + #line 2096 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3131 "Python/generated_cases.c.h" + #line 3103 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2128 "Python/bytecodes.c" + #line 2104 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3144 "Python/generated_cases.c.h" + #line 3116 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2134 "Python/bytecodes.c" + #line 2110 "Python/bytecodes.c" } - #line 3148 "Python/generated_cases.c.h" + #line 3120 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2138 "Python/bytecodes.c" + #line 2114 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3161 "Python/generated_cases.c.h" + #line 3133 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2147 "Python/bytecodes.c" + #line 2123 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3174 "Python/generated_cases.c.h" + #line 3146 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3181,16 +3153,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2155 "Python/bytecodes.c" + #line 2131 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3190 "Python/generated_cases.c.h" + #line 3162 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2160 "Python/bytecodes.c" + #line 2136 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3198,7 +3170,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3202 "Python/generated_cases.c.h" + #line 3174 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3207,10 +3179,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2170 "Python/bytecodes.c" + #line 2146 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3214 "Python/generated_cases.c.h" + #line 3186 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3220,10 +3192,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2176 "Python/bytecodes.c" + #line 2152 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3227 "Python/generated_cases.c.h" + #line 3199 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3234,11 +3206,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2182 "Python/bytecodes.c" + #line 2158 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3242 "Python/generated_cases.c.h" + #line 3214 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3247,14 +3219,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2188 "Python/bytecodes.c" + #line 2164 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3254 "Python/generated_cases.c.h" + #line 3226 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2191 "Python/bytecodes.c" + #line 2167 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3258 "Python/generated_cases.c.h" + #line 3230 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3262,7 +3234,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2195 "Python/bytecodes.c" + #line 2171 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3285,11 +3257,11 @@ if (iter == NULL) { goto error; } - #line 3289 "Python/generated_cases.c.h" + #line 3261 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2218 "Python/bytecodes.c" + #line 2194 "Python/bytecodes.c" } - #line 3293 "Python/generated_cases.c.h" + #line 3265 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3300,7 +3272,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2237 "Python/bytecodes.c" + #line 2213 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3331,7 +3303,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3335 "Python/generated_cases.c.h" + #line 3307 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3339,7 +3311,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2270 "Python/bytecodes.c" + #line 2246 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3365,14 +3337,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3369 "Python/generated_cases.c.h" + #line 3341 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2298 "Python/bytecodes.c" + #line 2274 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3392,7 +3364,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3396 "Python/generated_cases.c.h" + #line 3368 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3402,7 +3374,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2320 "Python/bytecodes.c" + #line 2296 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3422,7 +3394,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3426 "Python/generated_cases.c.h" + #line 3398 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3432,7 +3404,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2342 "Python/bytecodes.c" + #line 2318 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3450,7 +3422,7 @@ if (next == NULL) { goto error; } - #line 3454 "Python/generated_cases.c.h" + #line 3426 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3459,7 +3431,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2362 "Python/bytecodes.c" + #line 2338 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3474,14 +3446,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3478 "Python/generated_cases.c.h" + #line 3450 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2379 "Python/bytecodes.c" + #line 2355 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3504,16 +3476,16 @@ Py_DECREF(enter); goto error; } - #line 3508 "Python/generated_cases.c.h" + #line 3480 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2402 "Python/bytecodes.c" + #line 2378 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3517 "Python/generated_cases.c.h" + #line 3489 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3525,7 +3497,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2412 "Python/bytecodes.c" + #line 2388 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3551,16 +3523,16 @@ Py_DECREF(enter); goto error; } - #line 3555 "Python/generated_cases.c.h" + #line 3527 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2438 "Python/bytecodes.c" + #line 2414 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3564 "Python/generated_cases.c.h" + #line 3536 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3572,7 +3544,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2447 "Python/bytecodes.c" + #line 2423 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3593,7 +3565,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3597 "Python/generated_cases.c.h" + #line 3569 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3602,7 +3574,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2470 "Python/bytecodes.c" + #line 2446 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3612,7 +3584,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3616 "Python/generated_cases.c.h" + #line 3588 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3626,7 +3598,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2482 "Python/bytecodes.c" + #line 2458 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3643,7 +3615,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3647 "Python/generated_cases.c.h" + #line 3619 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3657,7 +3629,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2501 "Python/bytecodes.c" + #line 2477 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3667,7 +3639,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3671 "Python/generated_cases.c.h" + #line 3643 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3681,7 +3653,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2513 "Python/bytecodes.c" + #line 2489 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3695,7 +3667,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3699 "Python/generated_cases.c.h" + #line 3671 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3704,16 +3676,16 @@ } TARGET(KW_NAMES) { - #line 2529 "Python/bytecodes.c" + #line 2505 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3712 "Python/generated_cases.c.h" + #line 3684 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2535 "Python/bytecodes.c" + #line 2511 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3726,7 +3698,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3730 "Python/generated_cases.c.h" + #line 3702 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3736,7 +3708,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2580 "Python/bytecodes.c" + #line 2556 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3818,7 +3790,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3822 "Python/generated_cases.c.h" + #line 3794 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3830,7 +3802,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2668 "Python/bytecodes.c" + #line 2644 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3840,7 +3812,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3844 "Python/generated_cases.c.h" + #line 3816 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3849,7 +3821,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2680 "Python/bytecodes.c" + #line 2656 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3875,7 +3847,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3879 "Python/generated_cases.c.h" + #line 3851 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3883,7 +3855,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2708 "Python/bytecodes.c" + #line 2684 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3919,7 +3891,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3923 "Python/generated_cases.c.h" + #line 3895 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3927,7 +3899,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2746 "Python/bytecodes.c" + #line 2722 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3937,7 +3909,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3941 "Python/generated_cases.c.h" + #line 3913 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3950,7 +3922,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2758 "Python/bytecodes.c" + #line 2734 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3961,7 +3933,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3965 "Python/generated_cases.c.h" + #line 3937 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3975,7 +3947,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2772 "Python/bytecodes.c" + #line 2748 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3986,7 +3958,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3990 "Python/generated_cases.c.h" + #line 3962 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4000,7 +3972,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2786 "Python/bytecodes.c" + #line 2762 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4022,7 +3994,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4026 "Python/generated_cases.c.h" + #line 3998 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4036,7 +4008,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2811 "Python/bytecodes.c" + #line 2787 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4064,7 +4036,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4068 "Python/generated_cases.c.h" + #line 4040 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4078,7 +4050,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2842 "Python/bytecodes.c" + #line 2818 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4110,7 +4082,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4114 "Python/generated_cases.c.h" + #line 4086 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4124,7 +4096,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2877 "Python/bytecodes.c" + #line 2853 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4156,7 +4128,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4160 "Python/generated_cases.c.h" + #line 4132 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4170,7 +4142,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2912 "Python/bytecodes.c" + #line 2888 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4195,7 +4167,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4199 "Python/generated_cases.c.h" + #line 4171 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4208,7 +4180,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2939 "Python/bytecodes.c" + #line 2915 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4235,7 +4207,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4239 "Python/generated_cases.c.h" + #line 4211 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4247,7 +4219,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2969 "Python/bytecodes.c" + #line 2945 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4265,14 +4237,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4269 "Python/generated_cases.c.h" + #line 4241 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2989 "Python/bytecodes.c" + #line 2965 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4303,7 +4275,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4307 "Python/generated_cases.c.h" + #line 4279 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4316,7 +4288,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3023 "Python/bytecodes.c" + #line 2999 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4345,7 +4317,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4349 "Python/generated_cases.c.h" + #line 4321 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4358,7 +4330,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3055 "Python/bytecodes.c" + #line 3031 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4387,7 +4359,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4391 "Python/generated_cases.c.h" + #line 4363 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4400,7 +4372,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3087 "Python/bytecodes.c" + #line 3063 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4428,7 +4400,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4432 "Python/generated_cases.c.h" + #line 4404 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4438,9 +4410,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3118 "Python/bytecodes.c" + #line 3094 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4444 "Python/generated_cases.c.h" + #line 4416 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4449,7 +4421,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3122 "Python/bytecodes.c" + #line 3098 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4511,14 +4483,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4515 "Python/generated_cases.c.h" + #line 4487 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3184 "Python/bytecodes.c" + #line 3160 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4522 "Python/generated_cases.c.h" + #line 4494 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4533,7 +4505,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3194 "Python/bytecodes.c" + #line 3170 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4562,14 +4534,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4566 "Python/generated_cases.c.h" + #line 4538 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3225 "Python/bytecodes.c" + #line 3201 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4590,7 +4562,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4594 "Python/generated_cases.c.h" + #line 4566 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4598,15 +4570,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3248 "Python/bytecodes.c" + #line 3224 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4604 "Python/generated_cases.c.h" + #line 4576 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3250 "Python/bytecodes.c" + #line 3226 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4610 "Python/generated_cases.c.h" + #line 4582 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4617,7 +4589,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3254 "Python/bytecodes.c" + #line 3230 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4652,7 +4624,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4656 "Python/generated_cases.c.h" + #line 4628 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4661,10 +4633,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3291 "Python/bytecodes.c" + #line 3267 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4668 "Python/generated_cases.c.h" + #line 4640 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4676,7 +4648,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3296 "Python/bytecodes.c" + #line 3272 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4691,12 +4663,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4695 "Python/generated_cases.c.h" + #line 4667 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3311 "Python/bytecodes.c" + #line 3287 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4700 "Python/generated_cases.c.h" + #line 4672 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4706,16 +4678,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3316 "Python/bytecodes.c" + #line 3292 "Python/bytecodes.c" assert(oparg >= 2); - #line 4712 "Python/generated_cases.c.h" + #line 4684 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3320 "Python/bytecodes.c" + #line 3296 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4735,11 +4707,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4739 "Python/generated_cases.c.h" + #line 4711 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3342 "Python/bytecodes.c" + #line 3318 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4751,26 +4723,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4755 "Python/generated_cases.c.h" + #line 4727 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3356 "Python/bytecodes.c" + #line 3332 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4761 "Python/generated_cases.c.h" + #line 4733 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3360 "Python/bytecodes.c" + #line 3336 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4768 "Python/generated_cases.c.h" + #line 4740 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3365 "Python/bytecodes.c" + #line 3341 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4779,12 +4751,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4783 "Python/generated_cases.c.h" + #line 4755 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3376 "Python/bytecodes.c" + #line 3352 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4793,12 +4765,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4797 "Python/generated_cases.c.h" + #line 4769 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3387 "Python/bytecodes.c" + #line 3363 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4811,12 +4783,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4815 "Python/generated_cases.c.h" + #line 4787 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3402 "Python/bytecodes.c" + #line 3378 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4829,30 +4801,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4833 "Python/generated_cases.c.h" + #line 4805 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3417 "Python/bytecodes.c" + #line 3393 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4844 "Python/generated_cases.c.h" + #line 4816 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3425 "Python/bytecodes.c" + #line 3401 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4851 "Python/generated_cases.c.h" + #line 4823 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3430 "Python/bytecodes.c" + #line 3406 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4858 "Python/generated_cases.c.h" + #line 4830 "Python/generated_cases.c.h" } diff --git a/Python/intrinsics.c b/Python/intrinsics.c index f0bb75aa63b665..03d87cf1450699 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -258,5 +258,4 @@ _PyIntrinsics_BinaryFunctions[] = { [INTRINSIC_TYPEVAR_WITH_BOUND] = make_typevar_with_bound, [INTRINSIC_TYPEVAR_WITH_CONSTRAINTS] = make_typevar_with_constraints, [INTRINSIC_SET_FUNCTION_TYPE_PARAMS] = _Py_set_function_type_params, - [INTRINSIC_SET_CLASS_DICT] = _Py_set_function_class_dict, }; diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index ab61f6e1af1e31..1be57495a0779c 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -164,7 +164,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case LOAD_NAME: return 0+2; case LOAD_CLASSDICT_OR_GLOBAL: - return 0+2; + return 1+2; case LOAD_GLOBAL: return 0; case LOAD_GLOBAL_MODULE: @@ -180,7 +180,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { case LOAD_CLASSDEREF: return 0+1; case LOAD_CLASSDICT_OR_DEREF: - return 0+1; + return 1+1; case LOAD_DEREF: return 0; case STORE_DEREF: diff --git a/Python/symtable.c b/Python/symtable.c index 94094a11b30185..546ac86cfdcd40 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -118,6 +118,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_comp_iter_target = 0; ste->ste_type_params_in_class = 0; ste->ste_comp_iter_expr = 0; + ste->ste_needs_classdict = 0; ste->ste_symbols = PyDict_New(); ste->ste_varnames = PyList_New(0); @@ -650,6 +651,11 @@ drop_class_free(PySTEntryObject *ste, PyObject *free) return 0; if (res) ste->ste_needs_class_closure = 1; + res = PySet_Discard(free, &_Py_ID(__classdict__)); + if (res < 0) + return 0; + if (res) + ste->ste_needs_classdict = 1; return 1; } @@ -854,7 +860,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_DECREF(temp); } else { - /* Special-case __class__ */ + /* Special-case __class__ and __classdict__ */ PyObject *flags = PyLong_FromLong(0); if (flags == NULL) { goto error; @@ -863,6 +869,10 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_DECREF(flags); goto error; } + if (PyDict_SetItem(newbound, &_Py_ID(__classdict__), flags) < 0) { + Py_DECREF(flags); + goto error; + } Py_DECREF(flags); } @@ -1172,13 +1182,7 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, } if (current_type == ClassBlock) { st->st_cur->ste_type_params_in_class = 1; - _Py_DECLARE_STR(class_dict, ".class_dict"); - if (!symtable_add_def(st, &_Py_STR(class_dict), - DEF_PARAM, lineno, col_offset, end_lineno, end_col_offset)) { - return 0; - } - if (!symtable_add_def(st, &_Py_STR(class_dict), - USE, lineno, col_offset, end_lineno, end_col_offset)) { + if (!symtable_add_def(st, &_Py_ID(__classdict__), USE, lineno, col_offset, end_lineno, end_col_offset)) { return 0; } } @@ -1420,6 +1424,9 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) (void *)s, LOCATION(s))) VISIT_QUIT(st, 0); st->st_cur->ste_type_params_in_class = is_in_class; + if (is_in_class && !symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(s->v.TypeAlias.value))) { + VISIT_QUIT(st, 0); + } VISIT(st, expr, s->v.TypeAlias.value); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); @@ -1962,6 +1969,9 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) LOCATION(tp))) VISIT_QUIT(st, 0); st->st_cur->ste_type_params_in_class = is_in_class; + if (is_in_class && !symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(tp->v.TypeVar.bound))) { + VISIT_QUIT(st, 0); + } VISIT(st, expr, tp->v.TypeVar.bound); if (!symtable_exit_block(st)) VISIT_QUIT(st, 0); From e786382fadc037a1261adfd5e1bb22bd2dca4df2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 6 May 2023 18:56:54 -0700 Subject: [PATCH 149/200] Fix a test --- Objects/typeobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c486464727b72b..af02954fe7f0ad 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1458,7 +1458,7 @@ type_get_annotations(PyTypeObject *type, void *context) static PyObject * type_get_type_params(PyTypeObject *type, void *context) { - PyObject *params = PyDict_GetItem(type->tp_dict, &_Py_ID(__type_params__)); + PyObject *params = PyDict_GetItem(lookup_tp_dict(type), &_Py_ID(__type_params__)); if (params) { return Py_NewRef(params); From 2a8f0efca1528d6a1a12cc85e1a8a604985d0d71 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:06:28 -0700 Subject: [PATCH 150/200] Remove stray function declarations --- Include/cpython/funcobject.h | 1 - Include/internal/pycore_function.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index 4e5a3624addb9c..6f78f5868d0166 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -68,7 +68,6 @@ PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); -PyAPI_FUNC(PyObject *) PyFunction_GetClassDict(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); diff --git a/Include/internal/pycore_function.h b/Include/internal/pycore_function.h index 7287fd4a6a3e14..ecbb7001e7d840 100644 --- a/Include/internal/pycore_function.h +++ b/Include/internal/pycore_function.h @@ -19,8 +19,6 @@ extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr) extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func); extern PyObject *_Py_set_function_type_params( PyThreadState* unused, PyObject *func, PyObject *type_params); -extern PyObject *_Py_set_function_class_dict( - PyThreadState* unused, PyObject *func, PyObject *class_dict); #ifdef __cplusplus } From 967f1000cb8882360aaa4c6bdbf2238f66d447ca Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:06:36 -0700 Subject: [PATCH 151/200] More thorough tests --- Lib/test/test_type_aliases.py | 31 +++++- Lib/test/test_type_params.py | 178 ++++++++++++++++++++++++---------- 2 files changed, 152 insertions(+), 57 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index b1076bd6c84283..f8c8ee23ca08b5 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -2,7 +2,7 @@ import unittest from test.support import check_syntax_error -from typing import Callable, TypeAliasType, get_args, get_origin +from typing import Callable, TypeAliasType, get_args from .test_type_params import run_code @@ -12,14 +12,20 @@ def test_name_collision_01(self): check_syntax_error(self, """type TA1[A, **A] = None""", "duplicate type parameter 'A'") def test_name_non_collision_02(self): - run_code("""type TA1[A] = lambda A: None""") + ns = run_code("""type TA1[A] = lambda A: A""") + self.assertIsInstance(ns["TA1"], TypeAliasType) + self.assertTrue(callable(ns["TA1"].__value__)) + self.assertEqual("arg", ns["TA1"].__value__("arg")) def test_name_non_collision_03(self): - run_code("""\ + ns = run_code(""" class Outer[A]: type TA1[A] = None """ ) + outer_A, = ns["Outer"].__type_params__ + inner_A, = ns["Outer"].TA1.__type_params__ + self.assertIsNot(outer_A, inner_A) class TypeParamsAccessTest(unittest.TestCase): @@ -30,18 +36,33 @@ def test_alias_access_01(self): self.assertEqual(alias.__type_params__, get_args(alias.__value__)) def test_alias_access_02(self): - run_code("""\ + ns = run_code(""" type TA1[A, B] = TA1[A, B] | int """ ) + alias = ns["TA1"] + self.assertIsInstance(alias, TypeAliasType) + A, B = alias.__type_params__ + self.assertEqual(alias.__value__, alias[A, B] | int) def test_alias_access_03(self): - run_code("""\ + ns = run_code(""" class Outer[A]: def inner[B](self): type TA1[C] = TA1[A, B] | int + return TA1 """ ) + cls = ns["Outer"] + A, = cls.__type_params__ + B, = cls.inner.__type_params__ + alias = cls.inner(None) + self.assertIsInstance(alias, TypeAliasType) + alias2 = cls.inner(None) + self.assertIsNot(alias, alias2) + self.assertEqual(len(alias.__type_params__), 1) + + self.assertEqual(alias.__value__, alias[A, B] | int) class TypeParamsAliasValueTest(unittest.TestCase): diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index a82cadb94ded96..072d0774751743 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -1,9 +1,10 @@ import asyncio import textwrap +import types import unittest from test.support import requires_working_socket, check_syntax_error -from typing import Any, Sequence, TypeVar, TypeVarTuple, ParamSpec +from typing import Any, Generic, Sequence, TypeVar, TypeVarTuple, ParamSpec def run_code(code: str) -> dict[str, Any]: @@ -17,81 +18,128 @@ def test_name_collision_01(self): check_syntax_error(self, """def func[**A, A](): ...""") def test_name_non_collision_02(self): - run_code("""def func[A](A): ...""") + ns = run_code("""def func[A](A): return A""") + func = ns["func"] + self.assertEqual(func(1), 1) + A, = func.__type_params__ + self.assertEqual(A.__name__, "A") def test_name_non_collision_03(self): - run_code("""def func[A](*A): ...""") + ns = run_code("""def func[A](*A): return A""") + func = ns["func"] + self.assertEqual(func(1), (1,)) + A, = func.__type_params__ + self.assertEqual(A.__name__, "A") def test_name_non_collision_04(self): # Mangled names should not cause a conflict. - run_code("""\ + ns = run_code(""" class ClassA: - def func[__A](self, __A): ... + def func[__A](self, __A): return __A """ ) + cls = ns["ClassA"] + self.assertEqual(cls().func(1), 1) + A, = cls.func.__type_params__ + self.assertEqual(A.__name__, "__A") def test_name_non_collision_05(self): - run_code("""\ + ns = run_code(""" class ClassA: - def func[_ClassA__A](self, __A): ... + def func[_ClassA__A](self, __A): return __A """ ) + cls = ns["ClassA"] + self.assertEqual(cls().func(1), 1) + A, = cls.func.__type_params__ + self.assertEqual(A.__name__, "_ClassA__A") def test_name_non_collision_06(self): - run_code("""\ + ns = run_code(""" class ClassA[X]: - def func(self, X): ... + def func(self, X): return X """ ) + cls = ns["ClassA"] + self.assertEqual(cls().func(1), 1) + X, = cls.__type_params__ + self.assertEqual(X.__name__, "X") def test_name_non_collision_07(self): - run_code("""\ + ns = run_code(""" class ClassA[X]: def func(self): X = 1 + return X """ ) + cls = ns["ClassA"] + self.assertEqual(cls().func(), 1) + X, = cls.__type_params__ + self.assertEqual(X.__name__, "X") def test_name_non_collision_08(self): - run_code("""\ + ns = run_code(""" class ClassA[X]: def func(self): - a = [X for X in []] + return [X for X in [1, 2]] """ ) + cls = ns["ClassA"] + self.assertEqual(cls().func(), [1, 2]) + X, = cls.__type_params__ + self.assertEqual(X.__name__, "X") def test_name_non_collision_9(self): - run_code("""\ + ns = run_code(""" class ClassA[X]: def func[X](self): ... """ ) + cls = ns["ClassA"] + outer_X, = cls.__type_params__ + inner_X, = cls.func.__type_params__ + self.assertEqual(outer_X.__name__, "X") + self.assertEqual(inner_X.__name__, "X") + self.assertIsNot(outer_X, inner_X) def test_name_non_collision_10(self): - run_code("""\ + ns = run_code(""" class ClassA[X]: X: int """ ) + cls = ns["ClassA"] + X, = cls.__type_params__ + self.assertEqual(X.__name__, "X") + self.assertIs(cls.__annotations__["X"], int) def test_name_non_collision_11(self): - run_code("""\ + ns = run_code(""" def outer(): X = 1 def inner[X](): nonlocal X + return X """ ) + self.assertEqual(ns["outer"](), 1) def test_name_non_collision_13(self): - run_code("""\ + ns = run_code(""" X = 1 def outer(): def inner[X](): global X + X = 2 + return inner """ ) + self.assertEqual(ns["X"], 1) + outer = ns["outer"] + outer()() + self.assertEqual(ns["X"], 2) def test_disallowed_expressions(self): check_syntax_error(self, "type X = (yield)") @@ -109,22 +157,32 @@ def test_disallowed_expressions(self): class TypeParamsAccessTest(unittest.TestCase): def test_class_access_01(self): - run_code("""\ + ns = run_code(""" class ClassA[A, B](dict[A, B]): ... """ ) + cls = ns["ClassA"] + A, B = cls.__type_params__ + self.assertEqual(types.get_original_bases(cls), (dict[A, B], Generic[A, B])) def test_class_access_02(self): - run_code("""\ + ns = run_code(""" class MyMeta[A, B](type): ... class ClassA[A, B](metaclass=MyMeta[A, B]): ... """ ) + meta = ns["MyMeta"] + cls = ns["ClassA"] + A1, B1 = meta.__type_params__ + A2, B2 = cls.__type_params__ + self.assertIsNot(A1, A2) + self.assertIsNot(B1, B2) + self.assertIs(type(cls), meta) def test_class_access_03(self): - code = """\ + code = """ def my_decorator(a): ... @my_decorator(A) @@ -136,14 +194,17 @@ class ClassA[A, B](): run_code(code) def test_function_access_01(self): - run_code("""\ + ns = run_code(""" def func[A, B](a: dict[A, B]): ... """ ) + func = ns["func"] + A, B = func.__type_params__ + self.assertEqual(func.__annotations__["a"], dict[A, B]) def test_function_access_02(self): - code = """\ + code = """ def func[A](a = list[A]()): ... """ @@ -152,7 +213,7 @@ def func[A](a = list[A]()): run_code(code) def test_function_access_03(self): - code = """\ + code = """ def my_decorator(a): ... @my_decorator(A) @@ -164,7 +225,7 @@ def func[A](): run_code(code) def test_method_access_01(self): - run_code("""\ + ns = run_code(""" class ClassA: x = int def func[T](self, a: x, b: T): @@ -173,19 +234,31 @@ def func[T](self, a: x, b: T): assert ClassA.func.__annotations__["a"] is int """ ) + cls = ns["ClassA"] + self.assertIs(cls.func.__annotations__["a"], int) + T, = cls.func.__type_params__ + self.assertIs(cls.func.__annotations__["b"], T) def test_nested_access_01(self): - run_code("""\ + ns = run_code(""" class ClassA[A]: def funcB[B](self): class ClassC[C]: def funcD[D](self): - lambda : (A, B, C, D) + return lambda: (A, B, C, D) + return ClassC """ ) + cls = ns["ClassA"] + A, = cls.__type_params__ + B, = cls.funcB.__type_params__ + classC = cls().funcB() + C, = classC.__type_params__ + D, = classC.funcD.__type_params__ + self.assertEqual(classC().funcD()(), (A, B, C, D)) def test_out_of_scope_01(self): - code = """\ + code = """ class ClassA[T]: ... x = T """ @@ -194,7 +267,7 @@ class ClassA[T]: ... run_code(code) def test_out_of_scope_02(self): - code = """\ + code = """ class ClassA[A]: def funcB[B](self): ... @@ -205,35 +278,36 @@ def funcB[B](self): ... run_code(code) def test_class_scope_interaction_01(self): - run_code("""\ + ns = run_code(""" class C: x = 1 def method[T](self, arg: x): pass - - assert C.method.__annotations__["arg"] == 1 """) + cls = ns["C"] + self.assertEqual(cls.method.__annotations__["arg"], 1) def test_class_scope_interaction_02(self): - run_code("""\ - from typing import Generic + ns = run_code(""" class C: class Base: pass class Child[T](Base): pass - - assert C.Child.__bases__ == (C.Base, Generic) """) + cls = ns["C"] + self.assertEqual(cls.Child.__bases__, (cls.Base, Generic)) + T, = cls.Child.__type_params__ + self.assertEqual(types.get_original_bases(cls.Child), (cls.Base, Generic[T])) def test_class_deref(self): - run_code("""\ + ns = run_code(""" class C[T]: T = "class" type Alias = T - - assert C.Alias.__value__ == "class", repr(C.Alias) """) + cls = ns["C"] + self.assertEqual(cls.Alias.__value__, "class") def test_nonlocal(self): - code = """\ + code = """ def outer2[T](): def inner1(): nonlocal T @@ -321,14 +395,14 @@ class X: type U = T self.assertIs(X.U.__value__, int) - run_code("""\ + ns = run_code(""" glb = "global" class X: cls = "class" type U = (glb, cls) - - assert X.U.__value__ == ("global", "class"), X.U.__value__ """) + cls = ns["X"] + self.assertEqual(cls.U.__value__, ("global", "class")) def test_bound(self): class X: @@ -336,16 +410,16 @@ class X: def foo[U: T](self): ... self.assertIs(X.foo.__type_params__[0].__bound__, int) - run_code("""\ + ns = run_code(""" glb = "global" class X: cls = "class" def foo[T: glb, U: cls](self): ... - - T, U = X.foo.__type_params__ - assert T.__bound__ == "global" - assert U.__bound__ == "class" """) + cls = ns["X"] + T, U = cls.foo.__type_params__ + self.assertEqual(T.__bound__, "global") + self.assertEqual(U.__bound__, "class") def test_modified_later(self): class X: @@ -382,10 +456,10 @@ def meth[__U](self, arg: __T, arg2: __U): class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): - code = """\ + code = """ from typing import Generic class ClassA[T](Generic[T]): ... - """ + """ with self.assertRaisesRegex(TypeError, r"Cannot inherit from Generic\[...\] multiple types."): run_code(code) @@ -542,11 +616,11 @@ class ClassA: self.assertEqual(ClassA.__type_params__, ()) def test_typeparams_dunder_class_03(self): - code = """\ + code = """ class ClassA[A](): pass ClassA.__type_params__ = () - """ + """ with self.assertRaisesRegex(AttributeError, "attribute '__type_params__' of 'type' objects is not writable"): run_code(code) @@ -570,11 +644,11 @@ def func1(): self.assertEqual(func1.__type_params__, ()) def test_typeparams_dunder_function_03(self): - code = """\ + code = """ def func[A](): pass func.__type_params__ = () - """ + """ with self.assertRaisesRegex(AttributeError, "attribute '__type_params__' of 'function' objects is not writable"): run_code(code) From 4cbbd24e2fc9f7ff02c5798c80ef0aca4fc2e401 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:10:01 -0700 Subject: [PATCH 152/200] More CR on tests --- Lib/test/test_type_aliases.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index f8c8ee23ca08b5..9b17b8a89d7d93 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -92,7 +92,7 @@ class Parent[A]: self.assertEqual(len(Parent.__parameters__), 1) a, = Parent.__parameters__ b, = Parent.TA1.__parameters__ - self.assertEqual(Parent.__parameters__, (a,)) + self.assertEqual(Parent.__type_params__, (a,)) self.assertEqual(Parent.TA1.__type_params__, (b,)) self.assertEqual(Parent.TA1.__value__, dict[a, b]) @@ -108,6 +108,7 @@ def outer[A](): b = o.__parameters__[0] self.assertEqual(o.__type_params__, (b,)) + def test_alias_value_04(self): def more_generic[T, *Ts, **P](): type TA[T2, *Ts2, **P2] = tuple[Callable[P, tuple[T, *Ts]], Callable[P2, tuple[T2, *Ts2]]] return TA From 8dfb93d589764c5563977921cd00f56718a543bc Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:10:36 -0700 Subject: [PATCH 153/200] Update comment --- Objects/typeobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index af02954fe7f0ad..94f60353bce806 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3606,7 +3606,7 @@ type_new_set_classdictcell(PyTypeObject *type) return 0; } - /* At least one method requires a reference to its defining class */ + /* At least one method requires a reference to the dict of its defining class */ if (!PyCell_Check(cell)) { PyErr_Format(PyExc_TypeError, "__classdictcell__ must be a nonlocal cell, not %.200R", From 43f02704d8709d64c2ea965f9c9d1d2f893dfcc4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:15:26 -0700 Subject: [PATCH 154/200] Real error for type_check --- Lib/test/test_typing.py | 3 +++ Objects/typevarobject.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index d3a77d6babdf60..2f819fdc1ca1ca 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -443,6 +443,9 @@ def test_bound_errors(self): TypeVar('X', bound=Union) with self.assertRaises(TypeError): TypeVar('X', str, float, bound=Employee) + with self.assertRaisesRegex(TypeError, + r"Bound must be a type\. Got \(1, 2\)\."): + TypeVar('X', bound=(1, 2)) def test_missing__name__(self): # See bpo-39942 diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 1b2909d396bab6..14e9cf212f2b65 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -71,14 +71,17 @@ call_typing_func_object(const char *name, PyObject *args) } static PyObject * -type_check(PyObject *arg) +type_check(PyObject *arg, const char *msg) { // Calling typing.py here leads to bootstrapping problems if (Py_IsNone(arg)) { return Py_NewRef(Py_TYPE(arg)); } - // TODO: real error message - PyObject *args = PyTuple_Pack(2, arg, Py_None); + PyObject *message_str = PyUnicode_FromString(msg); + if (message_str == NULL) { + return NULL; + } + PyObject *args = PyTuple_Pack(2, arg, message_str); if (args == NULL) { return NULL; } @@ -365,7 +368,7 @@ typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, bound = NULL; } if (bound != NULL) { - bound = type_check(bound); + bound = type_check(bound, "Bound must be a type."); if (bound == NULL) { return NULL; } @@ -876,7 +879,7 @@ paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, return NULL; } if (bound != NULL) { - bound = type_check(bound); + bound = type_check(bound, "Bound must be a type."); if (bound == NULL) { return NULL; } From 0b35c6c3c9ab5580671c29d48b7ac17d4b16b7c7 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:25:19 -0700 Subject: [PATCH 155/200] Use vectorcall --- Objects/typevarobject.c | 62 ++++++++++++----------------------------- 1 file changed, 18 insertions(+), 44 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 14e9cf212f2b65..048dcc926c4846 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -53,7 +53,7 @@ typedef struct { #include "clinic/typevarobject.c.h" static PyObject * -call_typing_func_object(const char *name, PyObject *args) +call_typing_func_object(const char *name, PyObject **args, size_t nargs) { PyObject *typing = PyImport_ImportModule("typing"); if (typing == NULL) { @@ -64,7 +64,7 @@ call_typing_func_object(const char *name, PyObject *args) Py_DECREF(typing); return NULL; } - PyObject *result = PyObject_CallObject(func, args); + PyObject *result = PyObject_Vectorcall(func, args, nargs, NULL); Py_DECREF(func); Py_DECREF(typing); return result; @@ -81,12 +81,8 @@ type_check(PyObject *arg, const char *msg) if (message_str == NULL) { return NULL; } - PyObject *args = PyTuple_Pack(2, arg, message_str); - if (args == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_type_check", args); - Py_DECREF(args); + PyObject *args[2] = {arg, message_str}; + PyObject *result = call_typing_func_object("_type_check", args, 2); return result; } @@ -101,12 +97,8 @@ type_check(PyObject *arg, const char *msg) static PyObject * make_union(PyObject *self, PyObject *other) { - PyObject *args = PyTuple_Pack(2, self, other); - if (args == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_make_union", args); - Py_DECREF(args); + PyObject *args[2] = {self, other}; + PyObject *result = call_typing_func_object("_make_union", args, 2); return result; } @@ -419,12 +411,8 @@ static PyObject * typevar_typing_subst_impl(typevarobject *self, PyObject *arg) /*[clinic end generated code: output=c76ced134ed8f4e1 input=6b70a4bb2da838de]*/ { - PyObject *args = PyTuple_Pack(2, self, arg); - if (args == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_typevar_subst", args); - Py_DECREF(args); + PyObject *args[2] = {(PyObject *)self, arg}; + PyObject *result = call_typing_func_object("_typevar_subst", args, 2); return result; } @@ -908,12 +896,8 @@ static PyObject * paramspec_typing_subst_impl(paramspecobject *self, PyObject *arg) /*[clinic end generated code: output=803e1ade3f13b57d input=4e0005d24023e896]*/ { - PyObject *args = PyTuple_Pack(2, self, arg); - if (args == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_paramspec_subst", args); - Py_DECREF(args); + PyObject *args[2] = {(PyObject *)self, arg}; + PyObject *result = call_typing_func_object("_paramspec_subst", args, 2); return result; } @@ -930,12 +914,9 @@ paramspec_typing_prepare_subst_impl(paramspecobject *self, PyObject *alias, PyObject *args) /*[clinic end generated code: output=95449d630a2adb9a input=4375e2ffcb2ad635]*/ { - PyObject *args_tuple = PyTuple_Pack(3, self, alias, args); - if (args_tuple == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_paramspec_prepare_subst", args_tuple); - Py_DECREF(args_tuple); + PyObject *args_array[3] = {(PyObject *)self, alias, args}; + PyObject *result = call_typing_func_object( + "_paramspec_prepare_subst", args_array, 3); return result; } @@ -1159,12 +1140,9 @@ typevartuple_typing_prepare_subst_impl(typevartupleobject *self, PyObject *alias, PyObject *args) /*[clinic end generated code: output=ff999bc5b02036c1 input=a211b05f2eeb4306]*/ { - PyObject *args_tuple = PyTuple_Pack(3, self, alias, args); - if (args_tuple == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_typevartuple_prepare_subst", args_tuple); - Py_DECREF(args_tuple); + PyObject *args_array[3] = {(PyObject *)self, alias, args}; + PyObject *result = call_typing_func_object( + "_typevartuple_prepare_subst", args_array, 3); return result; } @@ -1640,12 +1618,8 @@ _Py_subscript_generic(PyThreadState* unused, PyObject *params) PyErr_SetString(PyExc_SystemError, "Cannot find Generic type"); return NULL; } - PyObject *args = PyTuple_Pack(2, interp->cached_objects.generic_type, params); - if (args == NULL) { - return NULL; - } - PyObject *result = call_typing_func_object("_generic_class_getitem", args); - Py_DECREF(args); + PyObject *args[2] = {(PyObject *)interp->cached_objects.generic_type, params}; + PyObject *result = call_typing_func_object("_generic_class_getitem", args, 2); Py_DECREF(params); return result; } From a2f3c756436d34e24a625b008ba64db6c6d7943c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:35:14 -0700 Subject: [PATCH 156/200] Small fixes to typevarobject.c --- Objects/typevarobject.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 048dcc926c4846..f5c4ab605137eb 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -90,9 +90,9 @@ type_check(PyObject *arg, const char *msg) * Return a typing.Union. This is used as the nb_or (|) operator for * TypeVar and ParamSpec. We use this rather than _Py_union_type_or * (which would produce a types.Union) because historically TypeVar - * supported unions with forward references, and we want to preserve - * that behavior. _Py_union_type_or only allows a small set of - * types. + * supported unions with string forward references, and we want to + * preserve that behavior. _Py_union_type_or only allows a small set + * of types. */ static PyObject * make_union(PyObject *self, PyObject *other) @@ -1273,7 +1273,7 @@ typealias_dealloc(PyObject *self) } static PyObject * -typealias_evaluate(typealiasobject *ta) +typealias_get_value(typealiasobject *ta) { if (ta->value != NULL) { return Py_NewRef(ta->value); @@ -1299,11 +1299,12 @@ typealias_repr(PyObject *self) typealiasobject *ta = (typealiasobject *)self; PyObject *value_repr = NULL; - PyObject *value = typealias_evaluate(ta); + PyObject *value = typealias_get_value(ta); if (value == NULL) { PyErr_Clear(); value_repr = PyUnicode_FromString(""); } + // Show "int" instead of "" else if (PyType_Check(value) && Py_TYPE(value)->tp_repr == PyType_Type.tp_repr && ((PyTypeObject *)value)->tp_name != NULL) { value_repr = PyUnicode_FromString(((PyTypeObject *)value)->tp_name); @@ -1384,7 +1385,7 @@ static PyObject * typealias_value(PyObject *self, void *unused) { typealiasobject *ta = (typealiasobject *)self; - return typealias_evaluate(ta); + return typealias_get_value(ta); } static PyObject * From c51b9fc3a72455677d7d907e23aca2742990dcf4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:37:25 -0700 Subject: [PATCH 157/200] mod, not mad --- Python/bytecodes.c | 16 ++++++++-------- Python/generated_cases.c.h | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 2e221c1107a142..599cdab0ef99fe 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1160,23 +1160,23 @@ dummy_func( } } - op(_LOAD_NAME_INTRO, (-- mad_or_class_dict, name)) { + op(_LOAD_NAME_INTRO, (-- mod_or_class_dict, name)) { name = GETITEM(frame->f_code->co_names, oparg); - mad_or_class_dict = LOCALS(); - if (mad_or_class_dict == NULL) { + mod_or_class_dict = LOCALS(); + if (mod_or_class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals when loading %R", name); goto error; } } - op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (mad_or_class_dict -- mad_or_class_dict, name)) { + op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (mod_or_class_dict -- mod_or_class_dict, name)) { name = GETITEM(frame->f_code->co_names, oparg); } - op(_LOAD_NAME_COMMON, (mad_or_class_dict, name -- v)) { - if (PyDict_CheckExact(mad_or_class_dict)) { - v = PyDict_GetItemWithError(mad_or_class_dict, name); + op(_LOAD_NAME_COMMON, (mod_or_class_dict, name -- v)) { + if (PyDict_CheckExact(mod_or_class_dict)) { + v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } @@ -1185,7 +1185,7 @@ dummy_func( } } else { - v = PyObject_GetItem(mad_or_class_dict, name); + v = PyObject_GetItem(mod_or_class_dict, name); if (v == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 70c80152c1eb20..0abf581d665957 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1616,27 +1616,27 @@ PyObject *_tmp_1; PyObject *_tmp_2; { - PyObject *mad_or_class_dict; + PyObject *mod_or_class_dict; PyObject *name; #line 1164 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); - mad_or_class_dict = LOCALS(); - if (mad_or_class_dict == NULL) { + mod_or_class_dict = LOCALS(); + if (mod_or_class_dict == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals when loading %R", name); goto error; } #line 1630 "Python/generated_cases.c.h" - _tmp_2 = mad_or_class_dict; + _tmp_2 = mod_or_class_dict; _tmp_1 = name; } { PyObject *name = _tmp_1; - PyObject *mad_or_class_dict = _tmp_2; + PyObject *mod_or_class_dict = _tmp_2; PyObject *v; #line 1178 "Python/bytecodes.c" - if (PyDict_CheckExact(mad_or_class_dict)) { - v = PyDict_GetItemWithError(mad_or_class_dict, name); + if (PyDict_CheckExact(mod_or_class_dict)) { + v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } @@ -1645,7 +1645,7 @@ } } else { - v = PyObject_GetItem(mad_or_class_dict, name); + v = PyObject_GetItem(mod_or_class_dict, name); if (v == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; @@ -1698,21 +1698,21 @@ PyObject *_tmp_1; PyObject *_tmp_2 = stack_pointer[-1]; { - PyObject *mad_or_class_dict = _tmp_2; + PyObject *mod_or_class_dict = _tmp_2; PyObject *name; #line 1174 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); #line 1706 "Python/generated_cases.c.h" - _tmp_2 = mad_or_class_dict; + _tmp_2 = mod_or_class_dict; _tmp_1 = name; } { PyObject *name = _tmp_1; - PyObject *mad_or_class_dict = _tmp_2; + PyObject *mod_or_class_dict = _tmp_2; PyObject *v; #line 1178 "Python/bytecodes.c" - if (PyDict_CheckExact(mad_or_class_dict)) { - v = PyDict_GetItemWithError(mad_or_class_dict, name); + if (PyDict_CheckExact(mod_or_class_dict)) { + v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } @@ -1721,7 +1721,7 @@ } } else { - v = PyObject_GetItem(mad_or_class_dict, name); + v = PyObject_GetItem(mod_or_class_dict, name); if (v == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) goto error; From 047abba87cb9852e8779426a42105e4d5da888b2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:41:26 -0700 Subject: [PATCH 158/200] Use dict_add_o for class cells --- Python/compile.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index a0acf2a39334f3..235da90a8ed7dc 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1254,11 +1254,9 @@ compiler_enter_scope(struct compiler *c, identifier name, } if (u->u_ste->ste_needs_class_closure) { /* Cook up an implicit __class__ cell. */ - int res; + Py_ssize_t res; assert(u->u_scope_type == COMPILER_SCOPE_CLASS); - assert(PyDict_GET_SIZE(u->u_metadata.u_cellvars) == 0); - res = PyDict_SetItem(u->u_metadata.u_cellvars, &_Py_ID(__class__), - _PyLong_GetZero()); + res = dict_add_o(u->u_metadata.u_cellvars, &_Py_ID(__class__)); if (res < 0) { compiler_unit_free(u); return ERROR; @@ -1266,11 +1264,9 @@ compiler_enter_scope(struct compiler *c, identifier name, } if (u->u_ste->ste_needs_classdict) { /* Cook up an implicit __classdict__ cell. */ - int res; + Py_ssize_t res; assert(u->u_scope_type == COMPILER_SCOPE_CLASS); - PyObject *index = u->u_ste->ste_needs_class_closure ? _PyLong_GetOne() : _PyLong_GetZero(); - res = PyDict_SetItem(u->u_metadata.u_cellvars, &_Py_ID(__classdict__), - index); + res = dict_add_o(u->u_metadata.u_cellvars, &_Py_ID(__classdict__)); if (res < 0) { compiler_unit_free(u); return ERROR; From 51a4655c951767a35853124a42a854162fd01e4c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 07:46:35 -0700 Subject: [PATCH 159/200] Small compiler fixes --- Python/compile.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 235da90a8ed7dc..85f5809cdd9fdf 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2120,7 +2120,7 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) (void *)typeparam, bound->lineno) == -1) { return ERROR; } - VISIT(c, expr, bound); + VISIT_IN_SCOPE(c, expr, bound); ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); PyCodeObject *co = optimize_and_assemble(c, 1); compiler_exit_scope(c); @@ -2212,14 +2212,14 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) location loc = LOC(s); - int is_typeparams_in_class = c->u->u_ste->ste_type == ClassBlock; + int is_in_class = c->u->u_ste->ste_type == ClassBlock; int is_generic = asdl_seq_LEN(typeparams) > 0; if (is_generic) { ADDOP(c, loc, PUSH_NULL); // We'll swap in the callable here later. ADDOP_LOAD_CONST(c, loc, Py_None); - if (is_typeparams_in_class) { + if (is_in_class) { ADDOP(c, loc, LOAD_LOCALS); } } @@ -2243,15 +2243,15 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(typeparams_name); - if (is_typeparams_in_class) { + if (is_in_class) { num_typeparam_args += 1; } if ((funcflags & 0x01) || (funcflags & 0x02)) { - ADDOP_I(c, loc, LOAD_FAST, 0 + is_typeparams_in_class); + ADDOP_I(c, loc, LOAD_FAST, 0 + is_in_class); num_typeparam_args += 1; } if ((funcflags & 0x01) && (funcflags & 0x02)) { - ADDOP_I(c, loc, LOAD_FAST, 1 + is_typeparams_in_class); + ADDOP_I(c, loc, LOAD_FAST, 1 + is_in_class); num_typeparam_args += 1; } RETURN_IF_ERROR(compiler_type_params(c, typeparams)); @@ -2303,15 +2303,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS); - if (is_typeparams_in_class) { - c->u->u_metadata.u_argcount += 1; - } - if (funcflags & 0x02) { - c->u->u_metadata.u_argcount += 1; - } - if (funcflags & 0x01) { - c->u->u_metadata.u_argcount += 1; - } + c->u->u_metadata.u_argcount = num_typeparam_args; PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); if (co == NULL) { From 5e68cd8f264075fab2bf16fda3b0f1479c7e9dbc Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 08:15:23 -0700 Subject: [PATCH 160/200] Refactor compiler_function for correct scope handling --- Python/compile.c | 154 +++++++++++++++++++++++++++-------------------- 1 file changed, 90 insertions(+), 64 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 85f5809cdd9fdf..3369bd562fdf1b 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1124,16 +1124,18 @@ codegen_addop_j(instr_sequence *seq, location loc, return instr_sequence_addop(seq, opcode, target.id, loc); } -#define ADDOP(C, LOC, OP) \ - RETURN_IF_ERROR(codegen_addop_noarg(INSTR_SEQUENCE(C), (OP), (LOC))) - -#define ADDOP_IN_SCOPE(C, LOC, OP) { \ - if (codegen_addop_noarg(INSTR_SEQUENCE(C), (OP), (LOC)) < 0) { \ - compiler_exit_scope(C); \ +#define RETURN_IF_ERROR_IN_SCOPE(C, CALL) { \ + if ((CALL) < 0) { \ + compiler_exit_scope((C)); \ return ERROR; \ } \ } +#define ADDOP(C, LOC, OP) \ + RETURN_IF_ERROR(codegen_addop_noarg(INSTR_SEQUENCE(C), (OP), (LOC))) + +#define ADDOP_IN_SCOPE(C, LOC, OP) RETURN_IF_ERROR_IN_SCOPE((C), codegen_addop_noarg(INSTR_SEQUENCE(C), (OP), (LOC))) + #define ADDOP_LOAD_CONST(C, LOC, O) \ RETURN_IF_ERROR(compiler_addop_load_const((C)->c_const_cache, (C)->u, (LOC), (O))) @@ -1193,12 +1195,8 @@ codegen_addop_j(instr_sequence *seq, location loc, #define VISIT(C, TYPE, V) \ RETURN_IF_ERROR(compiler_visit_ ## TYPE((C), (V))); -#define VISIT_IN_SCOPE(C, TYPE, V) {\ - if (compiler_visit_ ## TYPE((C), (V)) < 0) { \ - compiler_exit_scope(C); \ - return ERROR; \ - } \ -} +#define VISIT_IN_SCOPE(C, TYPE, V) \ + RETURN_IF_ERROR_IN_SCOPE((C), compiler_visit_ ## TYPE((C), (V))) #define VISIT_SEQ(C, TYPE, SEQ) { \ int _i; \ @@ -2163,19 +2161,82 @@ compiler_type_params(struct compiler *c, asdl_typeparam_seq *typeparams) } static int -compiler_function(struct compiler *c, stmt_ty s, int is_async) +compiler_function_body(struct compiler *c, stmt_ty s, int is_async, Py_ssize_t funcflags, + int firstlineno) { - PyCodeObject *co; PyObject *docstring = NULL; + arguments_ty args; + identifier name; + asdl_stmt_seq *body; + int scope_type; + + if (is_async) { + assert(s->kind == AsyncFunctionDef_kind); + + args = s->v.AsyncFunctionDef.args; + name = s->v.AsyncFunctionDef.name; + body = s->v.AsyncFunctionDef.body; + + scope_type = COMPILER_SCOPE_ASYNC_FUNCTION; + } else { + assert(s->kind == FunctionDef_kind); + + args = s->v.FunctionDef.args; + name = s->v.FunctionDef.name; + body = s->v.FunctionDef.body; + + scope_type = COMPILER_SCOPE_FUNCTION; + } + + RETURN_IF_ERROR( + compiler_enter_scope(c, name, scope_type, (void *)s, firstlineno)); + + /* if not -OO mode, add docstring */ + if (c->c_optimize < 2) { + docstring = _PyAST_GetDocString(body); + } + if (compiler_add_const(c->c_const_cache, c->u, docstring ? docstring : Py_None) < 0) { + compiler_exit_scope(c); + return ERROR; + } + + c->u->u_metadata.u_argcount = asdl_seq_LEN(args->args); + c->u->u_metadata.u_posonlyargcount = asdl_seq_LEN(args->posonlyargs); + c->u->u_metadata.u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs); + for (Py_ssize_t i = docstring ? 1 : 0; i < asdl_seq_LEN(body); i++) { + VISIT_IN_SCOPE(c, stmt, (stmt_ty)asdl_seq_GET(body, i)); + } + if (c->u->u_ste->ste_coroutine || c->u->u_ste->ste_generator) { + if (wrap_in_stopiteration_handler(c) < 0) { + compiler_exit_scope(c); + return ERROR; + } + } + PyCodeObject *co = optimize_and_assemble(c, 1); + compiler_exit_scope(c); + if (co == NULL) { + Py_XDECREF(co); + return ERROR; + } + location loc = LOC(s); + if (compiler_make_closure(c, loc, co, funcflags) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + return SUCCESS; +} + +static int +compiler_function(struct compiler *c, stmt_ty s, int is_async) +{ arguments_ty args; expr_ty returns; identifier name; asdl_expr_seq *decos; - asdl_stmt_seq *body; asdl_typeparam_seq *typeparams; - Py_ssize_t i, funcflags; + Py_ssize_t funcflags; int annotations; - int scope_type; int firstlineno; if (is_async) { @@ -2185,10 +2246,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) returns = s->v.AsyncFunctionDef.returns; decos = s->v.AsyncFunctionDef.decorator_list; name = s->v.AsyncFunctionDef.name; - body = s->v.AsyncFunctionDef.body; typeparams = s->v.AsyncFunctionDef.typeparams; - - scope_type = COMPILER_SCOPE_ASYNC_FUNCTION; } else { assert(s->kind == FunctionDef_kind); @@ -2196,10 +2254,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) returns = s->v.FunctionDef.returns; decos = s->v.FunctionDef.decorator_list; name = s->v.FunctionDef.name; - body = s->v.FunctionDef.body; typeparams = s->v.FunctionDef.typeparams; - - scope_type = COMPILER_SCOPE_FUNCTION; } RETURN_IF_ERROR(compiler_check_debug_args(c, args)); @@ -2247,61 +2302,32 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) num_typeparam_args += 1; } if ((funcflags & 0x01) || (funcflags & 0x02)) { - ADDOP_I(c, loc, LOAD_FAST, 0 + is_in_class); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 0 + is_in_class, loc)); num_typeparam_args += 1; } if ((funcflags & 0x01) && (funcflags & 0x02)) { - ADDOP_I(c, loc, LOAD_FAST, 1 + is_in_class); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 1 + is_in_class, loc)); num_typeparam_args += 1; } - RETURN_IF_ERROR(compiler_type_params(c, typeparams)); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Store)); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Store)); } annotations = compiler_visit_annotations(c, loc, args, returns); - RETURN_IF_ERROR(annotations); + if (annotations < 0) { + compiler_exit_scope(c); + return ERROR; + } if (annotations > 0) { funcflags |= 0x04; } - RETURN_IF_ERROR( - compiler_enter_scope(c, name, scope_type, (void *)s, firstlineno)); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_function_body(c, s, is_async, funcflags, firstlineno)); - /* if not -OO mode, add docstring */ - if (c->c_optimize < 2) { - docstring = _PyAST_GetDocString(body); - } - if (compiler_add_const(c->c_const_cache, c->u, docstring ? docstring : Py_None) < 0) { - compiler_exit_scope(c); - return ERROR; - } - - c->u->u_metadata.u_argcount = asdl_seq_LEN(args->args); - c->u->u_metadata.u_posonlyargcount = asdl_seq_LEN(args->posonlyargs); - c->u->u_metadata.u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs); - for (i = docstring ? 1 : 0; i < asdl_seq_LEN(body); i++) { - VISIT_IN_SCOPE(c, stmt, (stmt_ty)asdl_seq_GET(body, i)); - } - if (c->u->u_ste->ste_coroutine || c->u->u_ste->ste_generator) { - if (wrap_in_stopiteration_handler(c) < 0) { - compiler_exit_scope(c); - return ERROR; - } - } - co = optimize_and_assemble(c, 1); - compiler_exit_scope(c); - if (co == NULL) { - Py_XDECREF(co); - return ERROR; - } - if (compiler_make_closure(c, loc, co, funcflags) < 0) { - Py_DECREF(co); - return ERROR; - } - Py_DECREF(co); if (is_generic) { - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); - ADDOP_I(c, loc, CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Load)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i( + INSTR_SEQUENCE(c), CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS, loc)); c->u->u_metadata.u_argcount = num_typeparam_args; PyCodeObject *co = optimize_and_assemble(c, 0); From 3b63b761e95ba46951a29456b06528df74376bc3 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 08:26:30 -0700 Subject: [PATCH 161/200] Same for classes --- Python/compile.c | 237 ++++++++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 107 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 3369bd562fdf1b..6823b9d5ff0599 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2322,7 +2322,12 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) funcflags |= 0x04; } - RETURN_IF_ERROR_IN_SCOPE(c, compiler_function_body(c, s, is_async, funcflags, firstlineno)); + if (compiler_function_body(c, s, is_async, funcflags, firstlineno) < 0) { + if (is_generic) { + compiler_exit_scope(c); + } + return ERROR; + } if (is_generic) { RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Load)); @@ -2359,41 +2364,8 @@ compiler_set_type_params_in_class(struct compiler *c, location loc) } static int -compiler_class(struct compiler *c, stmt_ty s) +compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) { - PyCodeObject *co; - int i, firstlineno; - asdl_expr_seq *decos = s->v.ClassDef.decorator_list; - - RETURN_IF_ERROR(compiler_decorators(c, decos)); - - firstlineno = s->lineno; - if (asdl_seq_LEN(decos)) { - firstlineno = ((expr_ty)asdl_seq_GET(decos, 0))->lineno; - } - location loc = LOC(s); - - asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; - int is_generic = asdl_seq_LEN(typeparams) > 0; - if (is_generic) { - Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); - ADDOP(c, loc, PUSH_NULL); - PyObject *typeparams_name = PyUnicode_FromFormat("", - s->v.ClassDef.name); - if (!typeparams_name) { - return ERROR; - } - if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_TYPEPARAMS, - (void *)typeparams, firstlineno) == -1) { - Py_DECREF(typeparams_name); - return ERROR; - } - Py_DECREF(typeparams_name); - RETURN_IF_ERROR(compiler_type_params(c, typeparams)); - _Py_DECLARE_STR(type_params, ".type_params"); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Store)); - } - /* ultimately generate code for: = __build_class__(, , *, **) where: @@ -2404,91 +2376,91 @@ compiler_class(struct compiler *c, stmt_ty s) is the keyword arguments and **kwds argument This borrows from compiler_call. */ + /* 1. compile the class body into a code object */ RETURN_IF_ERROR( compiler_enter_scope(c, s->v.ClassDef.name, COMPILER_SCOPE_CLASS, (void *)s, firstlineno)); - /* this block represents what we do in the new scope */ - { - location loc = LOCATION(firstlineno, firstlineno, 0, 0); - /* use the class name for name mangling */ - Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); - /* load (global) __name__ ... */ - if (compiler_nameop(c, loc, &_Py_ID(__name__), Load) < 0) { + location loc = LOCATION(firstlineno, firstlineno, 0, 0); + /* use the class name for name mangling */ + Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); + /* load (global) __name__ ... */ + if (compiler_nameop(c, loc, &_Py_ID(__name__), Load) < 0) { + compiler_exit_scope(c); + return ERROR; + } + /* ... and store it as __module__ */ + if (compiler_nameop(c, loc, &_Py_ID(__module__), Store) < 0) { + compiler_exit_scope(c); + return ERROR; + } + assert(c->u->u_metadata.u_qualname); + ADDOP_LOAD_CONST(c, loc, c->u->u_metadata.u_qualname); + if (compiler_nameop(c, loc, &_Py_ID(__qualname__), Store) < 0) { + compiler_exit_scope(c); + return ERROR; + } + asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; + if (asdl_seq_LEN(typeparams) > 0) { + if (!compiler_set_type_params_in_class(c, loc)) { compiler_exit_scope(c); return ERROR; } - /* ... and store it as __module__ */ - if (compiler_nameop(c, loc, &_Py_ID(__module__), Store) < 0) { + } + if (c->u->u_ste->ste_needs_classdict) { + ADDOP(c, loc, LOAD_LOCALS); + if (compiler_nameop(c, loc, &_Py_ID(__classdict__), Store) < 0) { compiler_exit_scope(c); return ERROR; } - assert(c->u->u_metadata.u_qualname); - ADDOP_LOAD_CONST(c, loc, c->u->u_metadata.u_qualname); - if (compiler_nameop(c, loc, &_Py_ID(__qualname__), Store) < 0) { + } + /* compile the body proper */ + if (compiler_body(c, loc, s->v.ClassDef.body) < 0) { + compiler_exit_scope(c); + return ERROR; + } + /* The following code is artificial */ + /* Set __classdictcell__ if necessary */ + if (c->u->u_ste->ste_needs_classdict) { + /* Store __classdictcell__ into class namespace */ + int i = compiler_lookup_arg(c->u->u_metadata.u_cellvars, &_Py_ID(__classdict__)); + if (i < 0) { compiler_exit_scope(c); return ERROR; } - if (asdl_seq_LEN(typeparams) > 0) { - if (!compiler_set_type_params_in_class(c, loc)) { - compiler_exit_scope(c); - return ERROR; - } - } - if (c->u->u_ste->ste_needs_classdict) { - ADDOP(c, loc, LOAD_LOCALS); - if (compiler_nameop(c, loc, &_Py_ID(__classdict__), Store) < 0) { - compiler_exit_scope(c); - return ERROR; - } - } - /* compile the body proper */ - if (compiler_body(c, loc, s->v.ClassDef.body) < 0) { + ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); + if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store) < 0) { compiler_exit_scope(c); return ERROR; } - /* The following code is artificial */ - /* Set __classdictcell__ if necessary */ - if (c->u->u_ste->ste_needs_classdict) { - /* Store __classdictcell__ into class namespace */ - i = compiler_lookup_arg(c->u->u_metadata.u_cellvars, &_Py_ID(__classdict__)); - if (i < 0) { - compiler_exit_scope(c); - return ERROR; - } - ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); - if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classdictcell__), Store) < 0) { - compiler_exit_scope(c); - return ERROR; - } - } - /* Return __classcell__ if it is referenced, otherwise return None */ - if (c->u->u_ste->ste_needs_class_closure) { - /* Store __classcell__ into class namespace & return it */ - i = compiler_lookup_arg(c->u->u_metadata.u_cellvars, &_Py_ID(__class__)); - if (i < 0) { - compiler_exit_scope(c); - return ERROR; - } - assert(i == 0); - ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); - ADDOP_I(c, NO_LOCATION, COPY, 1); - if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store) < 0) { - compiler_exit_scope(c); - return ERROR; - } + } + /* Return __classcell__ if it is referenced, otherwise return None */ + if (c->u->u_ste->ste_needs_class_closure) { + /* Store __classcell__ into class namespace & return it */ + int i = compiler_lookup_arg(c->u->u_metadata.u_cellvars, &_Py_ID(__class__)); + if (i < 0) { + compiler_exit_scope(c); + return ERROR; } - else { - /* No methods referenced __class__, so just return None */ - assert(PyDict_GET_SIZE(c->u->u_metadata.u_cellvars) == - c->u->u_ste->ste_needs_classdict ? 1 : 0); - ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); + assert(i == 0); + ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); + ADDOP_I(c, NO_LOCATION, COPY, 1); + if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store) < 0) { + compiler_exit_scope(c); + return ERROR; } - ADDOP_IN_SCOPE(c, NO_LOCATION, RETURN_VALUE); - /* create the code object */ - co = optimize_and_assemble(c, 1); } + else { + /* No methods referenced __class__, so just return None */ + assert(PyDict_GET_SIZE(c->u->u_metadata.u_cellvars) == + c->u->u_ste->ste_needs_classdict ? 1 : 0); + ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); + } + ADDOP_IN_SCOPE(c, NO_LOCATION, RETURN_VALUE); + /* create the code object */ + PyCodeObject *co = optimize_and_assemble(c, 1); + /* leave the new scope */ compiler_exit_scope(c); if (co == NULL) { @@ -2509,18 +2481,68 @@ compiler_class(struct compiler *c, stmt_ty s) /* 4. load class name */ ADDOP_LOAD_CONST(c, loc, s->v.ClassDef.name); - /* 5. generate the rest of the code for the call */ + return SUCCESS; +} + +static int +compiler_class(struct compiler *c, stmt_ty s) +{ + asdl_expr_seq *decos = s->v.ClassDef.decorator_list; + + RETURN_IF_ERROR(compiler_decorators(c, decos)); + + int firstlineno = s->lineno; + if (asdl_seq_LEN(decos)) { + firstlineno = ((expr_ty)asdl_seq_GET(decos, 0))->lineno; + } + location loc = LOC(s); + + asdl_typeparam_seq *typeparams = s->v.ClassDef.typeparams; + int is_generic = asdl_seq_LEN(typeparams) > 0; + if (is_generic) { + Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name)); + ADDOP(c, loc, PUSH_NULL); + PyObject *typeparams_name = PyUnicode_FromFormat("", + s->v.ClassDef.name); + if (!typeparams_name) { + return ERROR; + } + if (compiler_enter_scope(c, typeparams_name, COMPILER_SCOPE_TYPEPARAMS, + (void *)typeparams, firstlineno) == -1) { + Py_DECREF(typeparams_name); + return ERROR; + } + Py_DECREF(typeparams_name); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); + _Py_DECLARE_STR(type_params, ".type_params"); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Store)); + } + + if (compiler_class_body(c, s, firstlineno) < 0) { + if (is_generic) { + compiler_exit_scope(c); + } + return ERROR; + } + + /* generate the rest of the code for the call */ if (is_generic) { _Py_DECLARE_STR(type_params, ".type_params"); _Py_DECLARE_STR(generic_base, ".generic_base"); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(type_params), Load)); - ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC); - RETURN_IF_ERROR(compiler_nameop(c, loc, &_Py_STR(generic_base), Store)); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Load)); + RETURN_IF_ERROR_IN_SCOPE( + c, codegen_addop_i(INSTR_SEQUENCE(c), CALL_INTRINSIC_1, INTRINSIC_SUBSCRIPT_GENERIC, loc) + ) + RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(generic_base), Store)); Py_ssize_t original_len = asdl_seq_LEN(s->v.ClassDef.bases); asdl_expr_seq *bases = _Py_asdl_expr_seq_new( original_len + 1, c->c_arena); + if (bases == NULL) { + compiler_exit_scope(c); + return ERROR; + } for (Py_ssize_t i = 0; i < original_len; i++) { asdl_seq_SET(bases, i, asdl_seq_GET(s->v.ClassDef.bases, i)); } @@ -2529,12 +2551,13 @@ compiler_class(struct compiler *c, stmt_ty s) loc.lineno, loc.col_offset, loc.end_lineno, loc.end_col_offset, c->c_arena ); if (name_node == NULL) { + compiler_exit_scope(c); return ERROR; } asdl_seq_SET(bases, original_len, name_node); - RETURN_IF_ERROR(compiler_call_helper(c, loc, 2, - bases, - s->v.ClassDef.keywords)); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_call_helper(c, loc, 2, + bases, + s->v.ClassDef.keywords)); PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); From 281f575a948f210930af089dfb155e6f9f636021 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 08:31:16 -0700 Subject: [PATCH 162/200] And for type aliases --- Python/compile.c | 56 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 6823b9d5ff0599..fdca6f9c143a4f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2584,6 +2584,33 @@ compiler_class(struct compiler *c, stmt_ty s) return SUCCESS; } +static int +compiler_typealias_body(struct compiler *c, stmt_ty s) +{ + location loc = LOC(s); + PyObject *name = s->v.TypeAlias.name->v.Name.id; + RETURN_IF_ERROR( + compiler_enter_scope(c, name, COMPILER_SCOPE_FUNCTION, s, loc.lineno)); + /* Make None the first constant, so the evaluate function can't have a + docstring. */ + RETURN_IF_ERROR(compiler_add_const(c->c_const_cache, c->u, Py_None)); + VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); + ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); + PyCodeObject *co = optimize_and_assemble(c, 0); + compiler_exit_scope(c); + if (co == NULL) { + return ERROR; + } + if (compiler_make_closure(c, loc, co, 0) < 0) { + Py_DECREF(co); + return ERROR; + } + Py_DECREF(co); + ADDOP_I(c, loc, BUILD_TUPLE, 3); + ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); + return SUCCESS; +} + static int compiler_typealias(struct compiler *c, stmt_ty s) { @@ -2604,32 +2631,23 @@ compiler_typealias(struct compiler *c, stmt_ty s) return ERROR; } Py_DECREF(typeparams_name); - ADDOP_LOAD_CONST(c, loc, name); - RETURN_IF_ERROR(compiler_type_params(c, typeparams)); + RETURN_IF_ERROR_IN_SCOPE( + c, compiler_addop_load_const(c->c_const_cache, c->u, loc, name) + ); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); } else { ADDOP_LOAD_CONST(c, loc, name); ADDOP_LOAD_CONST(c, loc, Py_None); } - RETURN_IF_ERROR( - compiler_enter_scope(c, name, COMPILER_SCOPE_FUNCTION, s, loc.lineno)); - /* Make None the first constant, so the evaluate function can't have a - docstring. */ - RETURN_IF_ERROR(compiler_add_const(c->c_const_cache, c->u, Py_None)); - VISIT_IN_SCOPE(c, expr, s->v.TypeAlias.value); - ADDOP_IN_SCOPE(c, loc, RETURN_VALUE); - PyCodeObject *co = optimize_and_assemble(c, 0); - compiler_exit_scope(c); - if (co == NULL) { - return ERROR; - } - if (compiler_make_closure(c, loc, co, 0) < 0) { - Py_DECREF(co); + + if (compiler_typealias_body(c, s) < 0) { + if (is_generic) { + compiler_exit_scope(c); + } return ERROR; } - Py_DECREF(co); - ADDOP_I(c, loc, BUILD_TUPLE, 3); - ADDOP_I(c, loc, CALL_INTRINSIC_1, INTRINSIC_TYPEALIAS); + if (is_generic) { PyCodeObject *co = optimize_and_assemble(c, 0); compiler_exit_scope(c); From a3cd2e770e55f1c6690d691da97e49ebbb3c2816 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 08:33:55 -0700 Subject: [PATCH 163/200] fixup --- Python/compile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/compile.c b/Python/compile.c index fdca6f9c143a4f..a06817566c6aa7 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2315,7 +2315,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) annotations = compiler_visit_annotations(c, loc, args, returns); if (annotations < 0) { - compiler_exit_scope(c); + if (is_generic) { + compiler_exit_scope(c); + } return ERROR; } if (annotations > 0) { From a4f60762cadcdf868c0bd5fd5cdbece849d2a9ca Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 08:40:13 -0700 Subject: [PATCH 164/200] Remove unnecessary LOAD_LOCALS --- Python/compile.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index a06817566c6aa7..7717b9dc8958a5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2267,16 +2267,12 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) location loc = LOC(s); - int is_in_class = c->u->u_ste->ste_type == ClassBlock; int is_generic = asdl_seq_LEN(typeparams) > 0; if (is_generic) { ADDOP(c, loc, PUSH_NULL); // We'll swap in the callable here later. ADDOP_LOAD_CONST(c, loc, Py_None); - if (is_in_class) { - ADDOP(c, loc, LOAD_LOCALS); - } } funcflags = compiler_default_arguments(c, loc, args); @@ -2298,15 +2294,12 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(typeparams_name); - if (is_in_class) { - num_typeparam_args += 1; - } if ((funcflags & 0x01) || (funcflags & 0x02)) { - RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 0 + is_in_class, loc)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 0, loc)); num_typeparam_args += 1; } if ((funcflags & 0x01) && (funcflags & 0x02)) { - RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 1 + is_in_class, loc)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 1, loc)); num_typeparam_args += 1; } RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); From 88ac5dc837c96e696dac43e0757966469be1abe2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 08:58:32 -0700 Subject: [PATCH 165/200] Remove .type_params for functions --- Python/compile.c | 7 +++---- Python/symtable.c | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 7717b9dc8958a5..8178247224c079 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2281,7 +2281,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } int num_typeparam_args = 0; - _Py_DECLARE_STR(type_params, ".type_params"); if (is_generic) { PyObject *typeparams_name = PyUnicode_FromFormat("", name); @@ -2294,6 +2293,7 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(typeparams_name); + RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); if ((funcflags & 0x01) || (funcflags & 0x02)) { RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 0, loc)); num_typeparam_args += 1; @@ -2302,8 +2302,6 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 1, loc)); num_typeparam_args += 1; } - RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); - RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Store)); } annotations = compiler_visit_annotations(c, loc, args, returns); @@ -2325,7 +2323,8 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) } if (is_generic) { - RETURN_IF_ERROR_IN_SCOPE(c, compiler_nameop(c, loc, &_Py_STR(type_params), Load)); + RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i( + INSTR_SEQUENCE(c), SWAP, 2, loc)); RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i( INSTR_SEQUENCE(c), CALL_INTRINSIC_2, INTRINSIC_SET_FUNCTION_TYPE_PARAMS, loc)); diff --git a/Python/symtable.c b/Python/symtable.c index 546ac86cfdcd40..a67e72d6f5fb06 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1186,11 +1186,10 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, return 0; } } - if (kind == AsyncFunctionDef_kind || kind == FunctionDef_kind || kind == ClassDef_kind) { + if (kind == ClassDef_kind) { _Py_DECLARE_STR(type_params, ".type_params"); // It gets "set" when we create the type params tuple and - // "used" when we build up the bases (for classes) or set the - // type_params attribute (for functions). + // "used" when we build up the bases. if (!symtable_add_def(st, &_Py_STR(type_params), DEF_LOCAL, lineno, col_offset, end_lineno, end_col_offset)) { return 0; From 02f1fca94b8216690e0cbd261d594e8c7794361d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 10:21:47 -0700 Subject: [PATCH 166/200] Forgot one regen --- Python/opcode_targets.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 7896eb15c39850..b608ac45d08b7c 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -142,11 +142,7 @@ static void *opcode_targets[256] = { &&TARGET_JUMP_BACKWARD, &&TARGET_LOAD_SUPER_ATTR, &&TARGET_CALL_FUNCTION_EX, -<<<<<<< HEAD - &&TARGET_STORE_ATTR_WITH_HINT, -======= &&TARGET_LOAD_FAST_AND_CLEAR, ->>>>>>> upstream/main &&TARGET_EXTENDED_ARG, &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, @@ -156,24 +152,24 @@ static void *opcode_targets[256] = { &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, + &&TARGET_STORE_ATTR_WITH_HINT, &&TARGET_STORE_FAST__LOAD_FAST, - &&TARGET_STORE_FAST__STORE_FAST, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, + &&TARGET_STORE_FAST__STORE_FAST, &&TARGET_STORE_SUBSCR_DICT, &&TARGET_STORE_SUBSCR_LIST_INT, &&TARGET_UNPACK_SEQUENCE_LIST, - &&TARGET_UNPACK_SEQUENCE_TUPLE, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, + &&TARGET_UNPACK_SEQUENCE_TUPLE, &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, &&_unknown_opcode, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_CALL, &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, From 249ca436e43029ebb8d85caca1fccf52cc3cb99a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 16:18:05 -0700 Subject: [PATCH 167/200] Simplify bytecode as suggested by Carl --- Python/compile.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 80f42443a81108..20d17b34e842aa 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2280,9 +2280,8 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int is_generic = asdl_seq_LEN(typeparams) > 0; if (is_generic) { + // Used by the CALL to the type parameters function. ADDOP(c, loc, PUSH_NULL); - // We'll swap in the callable here later. - ADDOP_LOAD_CONST(c, loc, Py_None); } funcflags = compiler_default_arguments(c, loc, args); @@ -2293,6 +2292,15 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) int num_typeparam_args = 0; if (is_generic) { + if (funcflags & 0x01) { + num_typeparam_args += 1; + } + if (funcflags & 0x02) { + num_typeparam_args += 1; + } + if (num_typeparam_args == 2) { + ADDOP_I(c, loc, SWAP, 2); + } PyObject *typeparams_name = PyUnicode_FromFormat("", name); if (!typeparams_name) { return ERROR; @@ -2306,11 +2314,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) RETURN_IF_ERROR_IN_SCOPE(c, compiler_type_params(c, typeparams)); if ((funcflags & 0x01) || (funcflags & 0x02)) { RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 0, loc)); - num_typeparam_args += 1; } if ((funcflags & 0x01) && (funcflags & 0x02)) { RETURN_IF_ERROR_IN_SCOPE(c, codegen_addop_i(INSTR_SEQUENCE(c), LOAD_FAST, 1, loc)); - num_typeparam_args += 1; } } @@ -2349,8 +2355,9 @@ compiler_function(struct compiler *c, stmt_ty s, int is_async) return ERROR; } Py_DECREF(co); - ADDOP_I(c, loc, SWAP, num_typeparam_args + 2); - ADDOP(c, loc, POP_TOP); + if (num_typeparam_args > 0) { + ADDOP_I(c, loc, SWAP, num_typeparam_args + 1); + } ADDOP_I(c, loc, CALL, num_typeparam_args); } From 645b08b8365e5f71b2d288c10028bdaa8aaf9efa Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 16:33:45 -0700 Subject: [PATCH 168/200] Add some test cases for unusual calls --- Lib/test/test_type_params.py | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 072d0774751743..c27a42d30225d9 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -454,6 +454,43 @@ def meth[__U](self, arg: __T, arg2: __U): self.assertEqual(Foo.Alias.__value__, (T, V)) +class ComplexCallsTest(unittest.TestCase): + def test_defaults(self): + # Generic functions with both defaults and kwdefaults trigger a specific code path + # in the compiler. + def func[T](a: T = "a", *, b: T = "b"): + return (a, b) + + T, = func.__type_params__ + self.assertIs(func.__annotations__["a"], T) + self.assertIs(func.__annotations__["b"], T) + self.assertEqual(func(), ("a", "b")) + self.assertEqual(func(1), (1, "b")) + self.assertEqual(func(b=2), ("a", 2)) + + def test_complex_base(self): + class Base: + def __init_subclass__(cls, **kwargs) -> None: + cls.kwargs = kwargs + + kwargs = {"c": 3} + # Base classes with **kwargs trigger a different code path in the compiler. + class C[T](Base, a=1, b=2, **kwargs): + pass + + T, = C.__type_params__ + self.assertEqual(T.__name__, "T") + self.assertEqual(C.kwargs, {"a": 1, "b": 2, "c": 3}) + + bases = (Base,) + class C2[T](*bases, **kwargs): + pass + + T, = C2.__type_params__ + self.assertEqual(T.__name__, "T") + self.assertEqual(C2.kwargs, {"c": 3}) + + class TypeParamsTraditionalTypeVars(unittest.TestCase): def test_traditional_01(self): code = """ From 17c30f699570d7a14accd4ad76891a9bb421c997 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 16:49:36 -0700 Subject: [PATCH 169/200] Avoid compiler_nameop change --- Python/compile.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 20d17b34e842aa..ca012236cb803f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2421,7 +2421,17 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) } if (c->u->u_ste->ste_needs_classdict) { ADDOP(c, loc, LOAD_LOCALS); - if (compiler_nameop(c, loc, &_Py_ID(__classdict__), Store) < 0) { + + // We can't use compiler_nameop here because we need to generate a + // STORE_DEREF in a class namespace, and compiler_nameop() won't do + // that by default. + PyObject *cellvars = c->u->u_metadata.u_cellvars; + int arg = dict_add_o(cellvars, &_Py_ID(__classdict__)); + if (arg < 0) { + compiler_exit_scope(c); + return ERROR; + } + if (codegen_addop_i(INSTR_SEQUENCE(c), STORE_DEREF, arg, loc) < 0) { compiler_exit_scope(c); return ERROR; } @@ -4099,13 +4109,7 @@ compiler_nameop(struct compiler *c, location loc, op = 0; optype = OP_NAME; - if (c->u->u_scope_type == COMPILER_SCOPE_CLASS && - _PyUnicode_EqualToASCIIString(name, "__classdict__")) { - scope = CELL; - } - else { - scope = _PyST_GetScope(c->u->u_ste, mangled); - } + scope = _PyST_GetScope(c->u->u_ste, mangled); switch (scope) { case FREE: dict = c->u->u_metadata.u_freevars; From 39ace716a57a4448ba72057728f6a8cce73bdf4b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 17:14:46 -0700 Subject: [PATCH 170/200] Rip out making bound a set --- Python/symtable.c | 64 ++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/Python/symtable.c b/Python/symtable.c index 6d5e320145dd4d..18266b948a563c 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -531,11 +531,7 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); if (PySet_Add(global, name) < 0) return 0; - if (!bound) - return 1; - if (!PyDict_Contains(bound, name)) - return 1; - if (PyDict_DelItem(bound, name) < 0) + if (bound && (PySet_Discard(bound, name) < 0)) return 0; return 1; } @@ -545,34 +541,27 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, "nonlocal declaration not allowed at module level"); return error_at_directive(ste, name); } - PyObject *flags = PyDict_GetItem(bound, name); - if (flags == NULL) { + if (!PySet_Contains(bound, name)) { PyErr_Format(PyExc_SyntaxError, "no binding for nonlocal '%U' found", name); return error_at_directive(ste, name); } - if (PyLong_AsLong(flags) & DEF_TYPE_PARAM) { - PyErr_Format(PyExc_SyntaxError, - "nonlocal binding not allowed for type parameter '%U'", - name); - return error_at_directive(ste, name); - } + // if (PyLong_AsLong(flags) & DEF_TYPE_PARAM) { + // PyErr_Format(PyExc_SyntaxError, + // "nonlocal binding not allowed for type parameter '%U'", + // name); + // return error_at_directive(ste, name); + // } SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; } if (flags & DEF_BOUND) { SET_SCOPE(scopes, name, LOCAL); - PyObject *flags_obj = PyLong_FromLong(flags); - if (flags_obj == NULL) + if (PySet_Add(local, name) < 0) return 0; - if (PyDict_SetItem(local, name, flags_obj) < 0) { - Py_DECREF(flags_obj); - return 0; - } - Py_DECREF(flags_obj); if (PySet_Discard(global, name) < 0) return 0; return 1; @@ -582,7 +571,7 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, Note that having a non-NULL bound implies that the block is nested. */ - if (bound && PyDict_Contains(bound, name)) { + if (bound && PySet_Contains(bound, name)) { SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; @@ -793,7 +782,7 @@ update_symbols(PyObject *symbols, PyObject *scopes, goto error; } /* Handle global symbol */ - if (bound && !PyDict_Contains(bound, name)) { + if (bound && !PySet_Contains(bound, name)) { Py_DECREF(name); continue; /* it's a global */ } @@ -847,7 +836,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, int success = 0; Py_ssize_t i, pos = 0; - local = PyDict_New(); /* collect new names bound in block */ + local = PySet_New(NULL); /* collect new names bound in block */ if (!local) goto error; scopes = PyDict_New(); /* collect scopes defined for each name */ @@ -871,7 +860,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, newfree = PySet_New(NULL); if (!newfree) goto error; - newbound = PyDict_New(); + newbound = PySet_New(NULL); if (!newbound) goto error; @@ -888,9 +877,11 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, Py_DECREF(temp); /* Pass down previously bound symbols */ if (bound) { - if (PyDict_Update(newbound, bound) < 0) { + temp = PyNumber_InPlaceOr(newbound, bound); + if (!temp) { goto error; } + Py_DECREF(temp); } } @@ -905,15 +896,19 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, if (ste->ste_type != ClassBlock) { /* Add function locals to bound set */ if (_PyST_IsFunctionLike(ste)) { - if (PyDict_Update(newbound, local) < 0) { + temp = PyNumber_InPlaceOr(newbound, local); + if (!temp) { goto error; } + Py_DECREF(temp); } /* Pass down previously bound symbols */ if (bound) { - if (PyDict_Update(newbound, bound) < 0) { + temp = PyNumber_InPlaceOr(newbound, bound); + if (!temp) { goto error; } + Py_DECREF(temp); } /* Pass down known globals */ temp = PyNumber_InPlaceOr(newglobal, global); @@ -923,19 +918,10 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, } else { /* Special-case __class__ and __classdict__ */ - PyObject *flags = PyLong_FromLong(0); - if (flags == NULL) { - goto error; - } - if (PyDict_SetItem(newbound, &_Py_ID(__class__), flags) < 0) { - Py_DECREF(flags); + if (PySet_Add(newbound, &_Py_ID(__class__)) < 0) goto error; - } - if (PyDict_SetItem(newbound, &_Py_ID(__classdict__), flags) < 0) { - Py_DECREF(flags); + if (PySet_Add(newbound, &_Py_ID(__classdict__)) < 0) goto error; - } - Py_DECREF(flags); } /* Recursively call analyze_child_block() on each child block. @@ -1031,7 +1017,7 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, sets. */ - temp_bound = PyDict_Copy(bound); + temp_bound = PySet_New(bound); if (!temp_bound) goto error; temp_free = PySet_New(free); From a1c59f7ed93e09b57b0406b599d8147ca61820a2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 17:29:32 -0700 Subject: [PATCH 171/200] New solution for nonlocal --- Lib/test/test_type_params.py | 23 ++++++++++++++--- Python/symtable.c | 50 +++++++++++++++++++++++++----------- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 6d1b93eb74f6a9..aa1b203e7e083e 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -116,15 +116,14 @@ class ClassA[X]: self.assertIs(cls.__annotations__["X"], int) def test_name_non_collision_11(self): - ns = run_code(""" + code = """ def outer(): X = 1 def inner[X](): nonlocal X return X """ - ) - self.assertEqual(ns["outer"](), 1) + check_syntax_error(self, code) def test_name_non_collision_13(self): ns = run_code(""" @@ -314,6 +313,24 @@ def inner1(): """ check_syntax_error(self, textwrap.dedent(code)) + def test_shadowing_nonlocal(self): + ns = run_code(""" + def outer[T](): + T = "outer" + def inner(): + nonlocal T + T = "inner" + return T + return lambda: T, inner + """) + outer = ns["outer"] + T, = outer.__type_params__ + self.assertEqual(T.__name__, "T") + getter, inner = outer() + self.assertEqual(getter(), "outer") + self.assertEqual(inner(), "inner") + self.assertEqual(getter(), "inner") + def test_reference_previous_typevar(self): def func[S, T: Sequence[S]](): pass diff --git a/Python/symtable.c b/Python/symtable.c index 18266b948a563c..36d0e82d8be29d 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -519,7 +519,7 @@ error_at_directive(PySTEntryObject *ste, PyObject *name) static int analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, PyObject *bound, PyObject *local, PyObject *free, - PyObject *global) + PyObject *global, PyObject *typeparams) { if (flags & DEF_GLOBAL) { if (flags & DEF_NONLOCAL) { @@ -548,12 +548,12 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, return error_at_directive(ste, name); } - // if (PyLong_AsLong(flags) & DEF_TYPE_PARAM) { - // PyErr_Format(PyExc_SyntaxError, - // "nonlocal binding not allowed for type parameter '%U'", - // name); - // return error_at_directive(ste, name); - // } + if (PySet_Contains(typeparams, name)) { + PyErr_Format(PyExc_SyntaxError, + "nonlocal binding not allowed for type parameter '%U'", + name); + return error_at_directive(ste, name); + } SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; @@ -564,6 +564,14 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, return 0; if (PySet_Discard(global, name) < 0) return 0; + if (flags & DEF_TYPE_PARAM) { + if (PySet_Add(typeparams, name) < 0) + return 0; + } + else { + if (PySet_Discard(typeparams, name) < 0) + return 0; + } return 1; } /* If an enclosing block has a binding for this name, it @@ -824,11 +832,11 @@ update_symbols(PyObject *symbols, PyObject *scopes, static int analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, - PyObject *global, PyObject **child_free); + PyObject *global, PyObject *typeparams, PyObject **child_free); static int analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, - PyObject *global) + PyObject *global, PyObject *typeparams) { PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL; PyObject *newglobal = NULL, *newfree = NULL; @@ -888,7 +896,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { long flags = PyLong_AS_LONG(v); if (!analyze_name(ste, scopes, name, flags, - bound, local, free, global)) + bound, local, free, global, typeparams)) goto error; } @@ -943,7 +951,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, !entry->ste_generator; if (!analyze_child_block(entry, newbound, newfree, newglobal, - &child_free)) + typeparams, &child_free)) { goto error; } @@ -1006,9 +1014,10 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, static int analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, - PyObject *global, PyObject** child_free) + PyObject *global, PyObject *typeparams, PyObject** child_free) { PyObject *temp_bound = NULL, *temp_global = NULL, *temp_free = NULL; + PyObject *temp_typeparams = NULL; /* Copy the bound/global/free sets. @@ -1026,8 +1035,11 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, temp_global = PySet_New(global); if (!temp_global) goto error; + temp_typeparams = PySet_New(typeparams); + if (!temp_typeparams) + goto error; - if (!analyze_block(entry, temp_bound, temp_free, temp_global)) + if (!analyze_block(entry, temp_bound, temp_free, temp_global, temp_typeparams)) goto error; *child_free = temp_free; Py_DECREF(temp_bound); @@ -1037,13 +1049,14 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, Py_XDECREF(temp_bound); Py_XDECREF(temp_free); Py_XDECREF(temp_global); + Py_XDECREF(temp_typeparams); return 0; } static int symtable_analyze(struct symtable *st) { - PyObject *free, *global; + PyObject *free, *global, *typeparams; int r; free = PySet_New(NULL); @@ -1054,9 +1067,16 @@ symtable_analyze(struct symtable *st) Py_DECREF(free); return 0; } - r = analyze_block(st->st_top, NULL, free, global); + typeparams = PySet_New(NULL); + if (!typeparams) { + Py_DECREF(free); + Py_DECREF(global); + return 0; + } + r = analyze_block(st->st_top, NULL, free, global, typeparams); Py_DECREF(free); Py_DECREF(global); + Py_DECREF(typeparams); return r; } From f7e62197927ffb7fb0b54a62788884b9e7e471c8 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 17:54:51 -0700 Subject: [PATCH 172/200] Simplify TypeAliasType.__repr__ --- Lib/test/test_type_aliases.py | 32 ++----------- Objects/typevarobject.c | 85 +---------------------------------- 2 files changed, 4 insertions(+), 113 deletions(-) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 9b17b8a89d7d93..0ce3f42eb29df3 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -140,38 +140,12 @@ def test_subscripting(self): def test_repr(self): type Simple = int - self.assertEqual(repr(Simple), "") - - class FancyRepr: - def __repr__(self): - return "" - type Fancy = FancyRepr() - self.assertEqual(repr(Fancy), ">") - - class FancyMeta(type): - def __repr__(self): - return f"" - class FancyCls(metaclass=FancyMeta): - pass - type Fancy2 = FancyCls - self.assertEqual(repr(Fancy2), ">") - - type NoRepr = 1 / 0 - self.assertEqual(repr(NoRepr), ">") - - class FailingRepr: - def __repr__(self): - raise ValueError("nope") - type Failing = FailingRepr() - self.assertEqual(repr(Failing), ">") - - type Generic[T, *Ts, **P] = int - self.assertEqual(repr(Generic), "") + self.assertEqual(repr(Simple), "Simple") def test_recursive_repr(self): type Recursive = Recursive - self.assertEqual(repr(Recursive), "") + self.assertEqual(repr(Recursive), "Recursive") type X = list[Y] type Y = list[X] - self.assertEqual(repr(X), "]>") + self.assertEqual(repr(X), "X") diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index f5c4ab605137eb..6e4626c1e8903f 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1289,91 +1289,8 @@ typealias_get_value(typealiasobject *ta) static PyObject * typealias_repr(PyObject *self) { - Py_ssize_t res = Py_ReprEnter(self); - if (res > 0) { - return PyUnicode_FromString("..."); - } - else if (res < 0) { - return NULL; - } - typealiasobject *ta = (typealiasobject *)self; - PyObject *value_repr = NULL; - PyObject *value = typealias_get_value(ta); - if (value == NULL) { - PyErr_Clear(); - value_repr = PyUnicode_FromString(""); - } - // Show "int" instead of "" - else if (PyType_Check(value) && Py_TYPE(value)->tp_repr == PyType_Type.tp_repr - && ((PyTypeObject *)value)->tp_name != NULL) { - value_repr = PyUnicode_FromString(((PyTypeObject *)value)->tp_name); - Py_DECREF(value); - } - else { - value_repr = PyObject_Repr(value); - Py_DECREF(value); - if (value_repr == NULL) { - PyErr_Clear(); - value_repr = PyUnicode_FromString(""); - } - } - if (value_repr == NULL) { - // PyUnicode_FromString failed - Py_ReprLeave(self); - return NULL; - } - PyObject *result = NULL; - if (ta->type_params != NULL) { - _PyUnicodeWriter writer; - _PyUnicodeWriter_Init(&writer); - PyTupleObject *type_params = (PyTupleObject *)ta->type_params; - Py_ssize_t count = PyTuple_GET_SIZE(type_params); - PyInterpreterState *interp = PyInterpreterState_Get(); - for (Py_ssize_t i = 0; i < count; i++) { - PyObject *type_param = PyTuple_GET_ITEM(type_params, i); - if (i > 0 && _PyUnicodeWriter_WriteASCIIString(&writer, ", ", 2) < 0) { - _PyUnicodeWriter_Dealloc(&writer); - goto error; - } - if (Py_IS_TYPE(type_param, interp->cached_objects.paramspec_type)) { - if (_PyUnicodeWriter_WriteASCIIString(&writer, "**", 2) < 0) { - _PyUnicodeWriter_Dealloc(&writer); - goto error; - } - } - else if (Py_IS_TYPE(type_param, interp->cached_objects.typevartuple_type)) { - if (_PyUnicodeWriter_WriteASCIIString(&writer, "*", 1) < 0) { - _PyUnicodeWriter_Dealloc(&writer); - goto error; - } - } - PyObject *type_param_repr = PyObject_Repr(type_param); - if (type_param_repr == NULL) { - _PyUnicodeWriter_Dealloc(&writer); - goto error; - } - if (_PyUnicodeWriter_WriteStr(&writer, type_param_repr) < 0) { - Py_DECREF(type_param_repr); - _PyUnicodeWriter_Dealloc(&writer); - goto error; - } - Py_DECREF(type_param_repr); - } - PyObject *params_repr = _PyUnicodeWriter_Finish(&writer); - if (params_repr == NULL) { - goto error; - } - result = PyUnicode_FromFormat("", ta->name, params_repr, value_repr); - Py_DECREF(params_repr); - } - else { - result = PyUnicode_FromFormat("", ta->name, value_repr); - } -error: - Py_ReprLeave(self); - Py_DECREF(value_repr); - return result; + return PyUnicode_FromString(ta->name); } static PyMemberDef typealias_members[] = { From 8f54b029dc84a2fa9660fc9a3148ecb3bdac7e0f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 18:35:43 -0700 Subject: [PATCH 173/200] Remove bogus assertions --- Lib/test/test_type_params.py | 6 ++++-- Python/compile.c | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index aa1b203e7e083e..4337472cf0dbfd 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -344,11 +344,13 @@ def meth(self): return "base" class Child(Base): - def meth[T](self) -> T: + # Having int in the annotation ensures the class gets cells for both + # __class__ and __classdict__ + def meth[T](self, arg: int) -> T: return super().meth() + "child" c = Child() - self.assertEqual(c.meth(), "basechild") + self.assertEqual(c.meth(1), "basechild") def global_generic_func[T](): diff --git a/Python/compile.c b/Python/compile.c index ca012236cb803f..615e3b7bd6d7cb 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2464,7 +2464,6 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) compiler_exit_scope(c); return ERROR; } - assert(i == 0); ADDOP_I(c, NO_LOCATION, LOAD_CLOSURE, i); ADDOP_I(c, NO_LOCATION, COPY, 1); if (compiler_nameop(c, NO_LOCATION, &_Py_ID(__classcell__), Store) < 0) { @@ -2474,8 +2473,6 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) } else { /* No methods referenced __class__, so just return None */ - assert(PyDict_GET_SIZE(c->u->u_metadata.u_cellvars) == - c->u->u_ste->ste_needs_classdict ? 1 : 0); ADDOP_LOAD_CONST(c, NO_LOCATION, Py_None); } ADDOP_IN_SCOPE(c, NO_LOCATION, RETURN_VALUE); From bb2df6139a1701aa5d46372ec9616e9c817ca692 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 20:02:36 -0700 Subject: [PATCH 174/200] Remove redundant condition --- Python/symtable.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Python/symtable.c b/Python/symtable.c index 36d0e82d8be29d..6cf259ef9ab07c 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1287,8 +1287,6 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, lineno, col_offset, end_lineno, end_col_offset)) { return 0; } - } - if (kind == ClassDef_kind) { st->st_private = name; // This is used for setting the generic base _Py_DECLARE_STR(generic_base, ".generic_base"); From fdf65ad04bd5bc8e016a58f404530cdac0a2bd1f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 9 May 2023 20:08:48 -0700 Subject: [PATCH 175/200] Use compiler_addop_o --- Python/compile.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Python/compile.c b/Python/compile.c index 615e3b7bd6d7cb..120274c1be42e9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2426,12 +2426,8 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) // STORE_DEREF in a class namespace, and compiler_nameop() won't do // that by default. PyObject *cellvars = c->u->u_metadata.u_cellvars; - int arg = dict_add_o(cellvars, &_Py_ID(__classdict__)); - if (arg < 0) { - compiler_exit_scope(c); - return ERROR; - } - if (codegen_addop_i(INSTR_SEQUENCE(c), STORE_DEREF, arg, loc) < 0) { + if (compiler_addop_o(c->u, loc, STORE_DEREF, cellvars, + &_Py_ID(__classdict__)) < 0) { compiler_exit_scope(c); return ERROR; } From f8406cecd12460d09a484ae76276b72902da9339 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 May 2023 17:12:30 -0700 Subject: [PATCH 176/200] Undo unnecessary bracing changes --- Python/symtable.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Python/symtable.c b/Python/symtable.c index 6cf259ef9ab07c..970d4fd0cceeaf 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -886,9 +886,8 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, /* Pass down previously bound symbols */ if (bound) { temp = PyNumber_InPlaceOr(newbound, bound); - if (!temp) { + if (!temp) goto error; - } Py_DECREF(temp); } } @@ -905,17 +904,15 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, /* Add function locals to bound set */ if (_PyST_IsFunctionLike(ste)) { temp = PyNumber_InPlaceOr(newbound, local); - if (!temp) { + if (!temp) goto error; - } Py_DECREF(temp); } /* Pass down previously bound symbols */ if (bound) { temp = PyNumber_InPlaceOr(newbound, bound); - if (!temp) { + if (!temp) goto error; - } Py_DECREF(temp); } /* Pass down known globals */ From fd4fe5ce1474481c4465dd8d1d4d433618803066 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 May 2023 17:12:43 -0700 Subject: [PATCH 177/200] Separate out and expand nonlocal tests --- Lib/test/test_type_params.py | 61 +++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 4337472cf0dbfd..f651e18779c2f4 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -115,16 +115,6 @@ class ClassA[X]: self.assertEqual(X.__name__, "X") self.assertIs(cls.__annotations__["X"], int) - def test_name_non_collision_11(self): - code = """ - def outer(): - X = 1 - def inner[X](): - nonlocal X - return X - """ - check_syntax_error(self, code) - def test_name_non_collision_13(self): ns = run_code(""" X = 1 @@ -154,6 +144,49 @@ def test_disallowed_expressions(self): check_syntax_error(self, "def f[T](y: (x := Sequence[T])): pass") +class NonlocalTest(unittest.TestCase): + + def test_nonlocal_disallowed_01(self): + code = """ + def outer(): + X = 1 + def inner[X](): + nonlocal X + return X + """ + check_syntax_error(self, code) + + def test_nonlocal_disallowed_02(self): + code = """ + def outer2[T](): + def inner1(): + nonlocal T + """ + check_syntax_error(self, textwrap.dedent(code)) + + def test_nonlocal_disallowed_03(self): + code = """ + class Cls[T]: + nonlocal T + """ + check_syntax_error(self, textwrap.dedent(code)) + + def test_nonlocal_allowed(self): + code = """ + def func[T](): + T = "func" + def inner(): + nonlocal T + T = "inner" + inner() + assert T == "inner" + """ + ns = run_code(code) + func = ns["func"] + T, = func.__type_params__ + self.assertEqual(T.__name__, "T") + + class TypeParamsAccessTest(unittest.TestCase): def test_class_access_01(self): ns = run_code(""" @@ -305,14 +338,6 @@ class C[T]: cls = ns["C"] self.assertEqual(cls.Alias.__value__, "class") - def test_nonlocal(self): - code = """ - def outer2[T](): - def inner1(): - nonlocal T - """ - check_syntax_error(self, textwrap.dedent(code)) - def test_shadowing_nonlocal(self): ns = run_code(""" def outer[T](): From 0b945809f4ccd8c7987bd6d1ee6109ed4f783ece Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 May 2023 17:19:04 -0700 Subject: [PATCH 178/200] Add comments to the enum --- Include/internal/pycore_symtable.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 824210d6e16bfa..e5a3ad27e0c1f8 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -10,10 +10,17 @@ extern "C" { struct _mod; // Type defined in pycore_ast.h -typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock, - AnnotationBlock, TypeVarBoundBlock, TypeAliasBlock, - TypeParamBlock } - _Py_block_ty; +typedef enum _block_type { + FunctionBlock, ClassBlock, ModuleBlock, + // Used for annotations if 'from __future__ import annotations' is active. + // Annotation blocks cannot bind names and are not evaluated. + AnnotationBlock, + // Used for generics and type aliases. These work mostly like functions + // (see PEP 695 for details). The three different blocks function identically; + // they are different enum entries only so that error messages can be more + // precise. + TypeVarBoundBlock, TypeAliasBlock, TypeParamBlock +} _Py_block_ty; typedef enum _comprehension_type { NoComprehension = 0, From e952d61d0c82cf70874753eb222f725a8abf5bc5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 May 2023 18:05:53 -0700 Subject: [PATCH 179/200] Some more tests and consistent naming --- Lib/test/test_type_params.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index f651e18779c2f4..e3d4d5585762a4 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -4,7 +4,7 @@ import unittest from test.support import requires_working_socket, check_syntax_error -from typing import Any, Generic, Sequence, TypeVar, TypeVarTuple, ParamSpec +from typing import Any, Generic, Sequence, TypeVar, TypeVarTuple, ParamSpec, get_args def run_code(code: str) -> dict[str, Any]: @@ -144,8 +144,7 @@ def test_disallowed_expressions(self): check_syntax_error(self, "def f[T](y: (x := Sequence[T])): pass") -class NonlocalTest(unittest.TestCase): - +class TypeParamsNonlocalTest(unittest.TestCase): def test_nonlocal_disallowed_01(self): code = """ def outer(): @@ -377,6 +376,21 @@ def meth[T](self, arg: int) -> T: c = Child() self.assertEqual(c.meth(1), "basechild") + def test_type_alias_containing_lambda(self): + type Alias[T] = lambda: T + T, = Alias.__type_params__ + self.assertIs(Alias.__value__(), T) + + def test_class_base_containing_lambda(self): + # Test that scopes nested inside hidden functions work correctly + outer_var = "outer" + class Base[T]: ... + class Child[T](Base[lambda: (int, outer_var, T)]): ... + base, _ = types.get_original_bases(Child) + func, = get_args(base) + T, = Child.__type_params__ + self.assertEqual(func(), (int, "outer", T)) + def global_generic_func[T](): pass @@ -475,7 +489,7 @@ def foo[U: T](self): ... self.assertIs(X.Alias.__value__, float) -class ManglingTest(unittest.TestCase): +class TypeParamsManglingTest(unittest.TestCase): def test_mangling(self): class Foo[__T]: param = __T @@ -498,7 +512,7 @@ def meth[__U](self, arg: __T, arg2: __U): self.assertEqual(Foo.Alias.__value__, (T, V)) -class ComplexCallsTest(unittest.TestCase): +class TypeParamsComplexCallsTest(unittest.TestCase): def test_defaults(self): # Generic functions with both defaults and kwdefaults trigger a specific code path # in the compiler. @@ -535,7 +549,7 @@ class C2[T](*bases, **kwargs): self.assertEqual(C2.kwargs, {"c": 3}) -class TypeParamsTraditionalTypeVars(unittest.TestCase): +class TypeParamsTraditionalTypeVarsTest(unittest.TestCase): def test_traditional_01(self): code = """ from typing import Generic @@ -649,7 +663,7 @@ def func1[*A](): self.assertIsInstance(a, TypeVarTuple) -class TypeParamsTypeVarParamSpec(unittest.TestCase): +class TypeParamsTypeVarParamSpecTest(unittest.TestCase): def test_paramspec_01(self): code = """def func1[**A: str](): pass""" check_syntax_error(self, code, "cannot use bound with ParamSpec") From be70e3cd91f74d0397d1844cf3df7909b5f08e2e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 May 2023 18:30:11 -0700 Subject: [PATCH 180/200] Use _PyST_IsFunctionLike in comprehension inlining code --- Lib/test/test_type_params.py | 6 ++++++ Python/compile.c | 2 +- Python/symtable.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index e3d4d5585762a4..98e8f231e52039 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -391,6 +391,12 @@ class Child[T](Base[lambda: (int, outer_var, T)]): ... T, = Child.__type_params__ self.assertEqual(func(), (int, "outer", T)) + def test_comprehension_01(self): + type Alias[T: ([T for T in (T, [1])[1]], T)] = [T for T in T.__name__] + self.assertEqual(Alias.__value__, ["T"]) + T, = Alias.__type_params__ + self.assertEqual(T.__constraints__, ([1], T)) + def global_generic_func[T](): pass diff --git a/Python/compile.c b/Python/compile.c index 120274c1be42e9..47e82f8a85b38f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -5420,7 +5420,7 @@ push_inlined_comprehension_state(struct compiler *c, location loc, // assignment expression to a nonlocal in the comprehension, these don't // need handling here since they shouldn't be isolated if (symbol & DEF_LOCAL && !(symbol & DEF_NONLOCAL)) { - if (c->u->u_ste->ste_type != FunctionBlock) { + if (!_PyST_IsFunctionLike(c->u->u_ste)) { // non-function scope: override this name to use fast locals PyObject *orig = PyDict_GetItem(c->u->u_metadata.u_fasthidden, k); if (orig != Py_True) { diff --git a/Python/symtable.c b/Python/symtable.c index aa6fff200353a7..d3001424ff1fa8 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -648,7 +648,7 @@ inline_comprehension(PySTEntryObject *ste, PySTEntryObject *comp, if (PyLong_AsLong(existing) & DEF_BOUND) { // cell vars in comprehension that are locals in outer scope // must be promoted to cell so u_cellvars isn't wrong - if (scope == CELL && ste->ste_type == FunctionBlock) { + if (scope == CELL && _PyST_IsFunctionLike(ste)) { SET_SCOPE(scopes, k, scope); } From 92c29e74a26b7576a3c01af0a2b17b1641f52609 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 10 May 2023 21:36:43 -0700 Subject: [PATCH 181/200] Simplify Generic creation --- Objects/typevarobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 6e4626c1e8903f..2594e0c4ba7767 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1537,7 +1537,7 @@ _Py_subscript_generic(PyThreadState* unused, PyObject *params) return NULL; } PyObject *args[2] = {(PyObject *)interp->cached_objects.generic_type, params}; - PyObject *result = call_typing_func_object("_generic_class_getitem", args, 2); + PyObject *result = call_typing_func_object("_GenericAlias", args, 2); Py_DECREF(params); return result; } From 529c74da887ab89c0e60884e214bc3a7c183649e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 11 May 2023 18:38:40 -0700 Subject: [PATCH 182/200] Public constructor for TypeAlias --- .../pycore_global_objects_fini_generated.h | 1 + Include/internal/pycore_global_strings.h | 1 + .../internal/pycore_runtime_init_generated.h | 1 + .../internal/pycore_unicodeobject_generated.h | 3 + Lib/test/test_type_aliases.py | 33 +++++++- Objects/clinic/typevarobject.c.h | 78 ++++++++++++++++++- Objects/typevarobject.c | 35 ++++++++- 7 files changed, 146 insertions(+), 6 deletions(-) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index 470180a9c68da5..24a268ac8c43ec 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -1228,6 +1228,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(twice)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(txt)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(type)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(type_params)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tz)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzname)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(uid)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index 31db4505ad3b7c..c1005d05155271 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -716,6 +716,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(twice) STRUCT_FOR_ID(txt) STRUCT_FOR_ID(type) + STRUCT_FOR_ID(type_params) STRUCT_FOR_ID(tz) STRUCT_FOR_ID(tzname) STRUCT_FOR_ID(uid) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 45938d0ae851dc..ff1dee6eacfe5d 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -1222,6 +1222,7 @@ extern "C" { INIT_ID(twice), \ INIT_ID(txt), \ INIT_ID(type), \ + INIT_ID(type_params), \ INIT_ID(tz), \ INIT_ID(tzname), \ INIT_ID(uid), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index 4680004c798ea2..ba6b37f1bf55b3 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1989,6 +1989,9 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { string = &_Py_ID(type); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); + string = &_Py_ID(type_params); + assert(_PyUnicode_CheckConsistency(string, 1)); + _PyUnicode_InternInPlace(interp, &string); string = &_Py_ID(tz); assert(_PyUnicode_CheckConsistency(string, 1)); _PyUnicode_InternInPlace(interp, &string); diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 0ce3f42eb29df3..18bfbefe165042 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -2,7 +2,7 @@ import unittest from test.support import check_syntax_error -from typing import Callable, TypeAliasType, get_args +from typing import Callable, TypeAliasType, TypeVar, get_args from .test_type_params import run_code @@ -149,3 +149,34 @@ def test_recursive_repr(self): type X = list[Y] type Y = list[X] self.assertEqual(repr(X), "X") + + +class TypeAliasConstructorTest(unittest.TestCase): + def test_basic(self): + TA = TypeAliasType("TA", int) + self.assertEqual(TA.__name__, "TA") + self.assertIs(TA.__value__, int) + self.assertEqual(TA.__type_params__, ()) + + def test_generic(self): + T = TypeVar("T") + TA = TypeAliasType("TA", list[T], type_params=(T,)) + self.assertEqual(TA.__name__, "TA") + self.assertEqual(TA.__value__, list[T]) + self.assertEqual(TA.__type_params__, (T,)) + + def test_keywords(self): + TA = TypeAliasType(name="TA", value=int) + self.assertEqual(TA.__name__, "TA") + self.assertIs(TA.__value__, int) + self.assertEqual(TA.__type_params__, ()) + + def test_errors(self): + with self.assertRaises(TypeError): + TypeAliasType() + with self.assertRaises(TypeError): + TypeAliasType("TA") + with self.assertRaises(TypeError): + TypeAliasType("TA", list, ()) + with self.assertRaises(TypeError): + TypeAliasType("TA", list, type_params=42) diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index f677d208cff898..9efdedc7944c34 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -739,4 +739,80 @@ typealias_reduce(typealiasobject *self, PyObject *Py_UNUSED(ignored)) { return typealias_reduce_impl(self); } -/*[clinic end generated code: output=468f0011fd3e47d8 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(typealias_new__doc__, +"typealias(name, value, *, type_params=)\n" +"--\n" +"\n" +"Create a TypeAliasType."); + +static PyObject * +typealias_new_impl(PyTypeObject *type, const char *name, PyObject *value, + PyObject *type_params); + +static PyObject * +typealias_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_item = { &_Py_ID(name), &_Py_ID(value), &_Py_ID(type_params), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"name", "value", "type_params", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "typealias", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + PyObject * const *fastargs; + Py_ssize_t nargs = PyTuple_GET_SIZE(args); + Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; + const char *name; + PyObject *value; + PyObject *type_params = NULL; + + fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 2, 2, 0, argsbuf); + if (!fastargs) { + goto exit; + } + if (!PyUnicode_Check(fastargs[0])) { + _PyArg_BadArgument("typealias", "argument 'name'", "str", fastargs[0]); + goto exit; + } + Py_ssize_t name_length; + name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); + if (name == NULL) { + goto exit; + } + if (strlen(name) != (size_t)name_length) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + goto exit; + } + value = fastargs[1]; + if (!noptargs) { + goto skip_optional_kwonly; + } + type_params = fastargs[2]; +skip_optional_kwonly: + return_value = typealias_new_impl(type, name, value, type_params); + +exit: + return return_value; +} +/*[clinic end generated code: output=61f317e6bb78de3b input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 2594e0c4ba7767..bc232c01a6d32a 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1333,7 +1333,8 @@ static PyGetSetDef typealias_getset[] = { }; static typealiasobject * -typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value) +typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value, + PyObject *value) { char *owned_name = strdup(name); if (owned_name == NULL) { @@ -1348,8 +1349,8 @@ typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value } ta->name = owned_name; ta->type_params = Py_IsNone(type_params) ? NULL : Py_XNewRef(type_params); - ta->compute_value = Py_NewRef(compute_value); - ta->value = NULL; + ta->compute_value = Py_XNewRef(compute_value); + ta->value = Py_XNewRef(value); _PyObject_GC_TRACK(ta); return ta; } @@ -1400,6 +1401,31 @@ static PyMethodDef typealias_methods[] = { {0} }; + +/*[clinic input] +@classmethod +typealias.__new__ as typealias_new + + name: str + value: object + * + type_params: object = NULL + +Create a TypeAliasType. +[clinic start generated code]*/ + +static PyObject * +typealias_new_impl(PyTypeObject *type, const char *name, PyObject *value, + PyObject *type_params) +/*[clinic end generated code: output=a49732e3a327545c input=fe542c90292dbd35]*/ +{ + if (type_params != NULL && !PyTuple_Check(type_params)) { + PyErr_SetString(PyExc_TypeError, "type_params must be a tuple"); + return NULL; + } + return (PyObject *)typealias_alloc(name, type_params, NULL, value); +} + PyDoc_STRVAR(typealias_doc, "Type alias.\n\ \n\ @@ -1416,6 +1442,7 @@ static PyType_Slot typealias_slots[] = { {Py_mp_subscript, typealias_subscript}, {Py_tp_dealloc, typealias_dealloc}, {Py_tp_alloc, PyType_GenericAlloc}, + {Py_tp_new, typealias_new}, {Py_tp_free, PyObject_GC_Del}, {Py_tp_traverse, (traverseproc)typealias_traverse}, {Py_tp_clear, (inquiry)typealias_clear}, @@ -1444,7 +1471,7 @@ _Py_make_typealias(PyThreadState* unused, PyObject *args) } PyObject *type_params = PyTuple_GET_ITEM(args, 1); PyObject *compute_value = PyTuple_GET_ITEM(args, 2); - return (PyObject *)typealias_alloc(name_str, type_params, compute_value); + return (PyObject *)typealias_alloc(name_str, type_params, compute_value, NULL); } PyDoc_STRVAR(generic_doc, From 497e22abf0d2773fc0a90b423cf5dfdcad12e565 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 11 May 2023 18:44:52 -0700 Subject: [PATCH 183/200] regen opcode_targets.h --- Python/opcode_targets.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index ad3956dd6896f8..9076be52763e20 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -86,9 +86,8 @@ static void *opcode_targets[256] = { &&TARGET_LOAD_CONST__LOAD_FAST, &&TARGET_SETUP_ANNOTATIONS, &&TARGET_LOAD_FAST__LOAD_CONST, - &&TARGET_LOAD_FAST__LOAD_FAST, &&TARGET_LOAD_LOCALS, - &&TARGET_LOAD_GLOBAL_BUILTIN, + &&TARGET_LOAD_FAST__LOAD_FAST, &&TARGET_POP_EXCEPT, &&TARGET_STORE_NAME, &&TARGET_DELETE_NAME, @@ -111,9 +110,9 @@ static void *opcode_targets[256] = { &&TARGET_IMPORT_NAME, &&TARGET_IMPORT_FROM, &&TARGET_JUMP_FORWARD, + &&TARGET_LOAD_GLOBAL_BUILTIN, &&TARGET_LOAD_GLOBAL_MODULE, &&TARGET_STORE_ATTR_INSTANCE_VALUE, - &&TARGET_STORE_ATTR_SLOT, &&TARGET_POP_JUMP_IF_FALSE, &&TARGET_POP_JUMP_IF_TRUE, &&TARGET_LOAD_GLOBAL, @@ -153,24 +152,24 @@ static void *opcode_targets[256] = { &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, + &&TARGET_STORE_ATTR_SLOT, &&TARGET_STORE_ATTR_WITH_HINT, - &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, + &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_STORE_FAST__STORE_FAST, &&TARGET_STORE_SUBSCR_DICT, &&TARGET_STORE_SUBSCR_LIST_INT, - &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, + &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_UNPACK_SEQUENCE_TUPLE, &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, &&_unknown_opcode, - &&_unknown_opcode, &&TARGET_CALL, &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, From bfb5ac06b60a06aab37fd021fce3098ee75a274a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 11 May 2023 18:45:02 -0700 Subject: [PATCH 184/200] Add test now that it no longer crashes --- Lib/test/test_type_params.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 98e8f231e52039..10c2c71534e737 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -397,6 +397,14 @@ def test_comprehension_01(self): T, = Alias.__type_params__ self.assertEqual(T.__constraints__, ([1], T)) + def test_comprehension_02(self): + type Alias[T: [lambda: T for T in (T, [1])[1]]] = [lambda: T for T in T.__name__] + func, = Alias.__value__ + self.assertEqual(func(), "T") + T, = Alias.__type_params__ + func, = T.__bound__ + self.assertEqual(func(), 1) + def global_generic_func[T](): pass From a1be61d7abedf6f17d419d3e5906aa586ced0f7a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 11 May 2023 20:23:05 -0700 Subject: [PATCH 185/200] Fix one refleak --- Python/symtable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/symtable.c b/Python/symtable.c index d3001424ff1fa8..45c9894b305908 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1048,6 +1048,7 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, *child_free = temp_free; Py_DECREF(temp_bound); Py_DECREF(temp_global); + Py_DECREF(temp_typeparams); return 1; error: Py_XDECREF(temp_bound); From 1e9273c725a51261cc372822638a5f8a73493851 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 11 May 2023 21:08:38 -0700 Subject: [PATCH 186/200] Fix the other refleak --- Python/bytecodes.c | 12 +- Python/generated_cases.c.h | 615 +++++++++++++++++++------------------ 2 files changed, 325 insertions(+), 302 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 78411871d506b9..8fc78b54a0b46d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1174,6 +1174,7 @@ dummy_func( "no locals when loading %R", name); goto error; } + Py_INCREF(mod_or_class_dict); } op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (mod_or_class_dict -- mod_or_class_dict, name)) { @@ -1187,17 +1188,21 @@ dummy_func( Py_INCREF(v); } else if (_PyErr_Occurred(tstate)) { + Py_DECREF(mod_or_class_dict); goto error; } } else { v = PyObject_GetItem(mod_or_class_dict, name); if (v == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + Py_DECREF(mod_or_class_dict); goto error; + } _PyErr_Clear(tstate); } } + Py_DECREF(mod_or_class_dict); if (v == NULL) { v = PyDict_GetItemWithError(GLOBALS(), name); if (v != NULL) { @@ -1359,7 +1364,7 @@ dummy_func( } op(_LOAD_CLASSDEREF_INTRO, (-- class_dict)) { - class_dict = LOCALS(); + class_dict = Py_NewRef(LOCALS()); } op(_LOAD_CLASSDICT_OR_DEREF_INTRO, (class_dict -- class_dict)) { @@ -1376,6 +1381,7 @@ dummy_func( Py_INCREF(value); } else if (_PyErr_Occurred(tstate)) { + Py_DECREF(class_dict); goto error; } } @@ -1383,11 +1389,13 @@ dummy_func( value = PyObject_GetItem(class_dict, name); if (value == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + Py_DECREF(class_dict); goto error; } _PyErr_Clear(tstate); } } + Py_DECREF(class_dict); if (!value) { PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index df920e375b1ca8..6669d2e0919a4b 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1639,7 +1639,8 @@ "no locals when loading %R", name); goto error; } - #line 1643 "Python/generated_cases.c.h" + Py_INCREF(mod_or_class_dict); + #line 1644 "Python/generated_cases.c.h" _tmp_2 = mod_or_class_dict; _tmp_1 = name; } @@ -1647,24 +1648,28 @@ PyObject *name = _tmp_1; PyObject *mod_or_class_dict = _tmp_2; PyObject *v; - #line 1184 "Python/bytecodes.c" + #line 1185 "Python/bytecodes.c" if (PyDict_CheckExact(mod_or_class_dict)) { v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } else if (_PyErr_Occurred(tstate)) { + Py_DECREF(mod_or_class_dict); goto error; } } else { v = PyObject_GetItem(mod_or_class_dict, name); if (v == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + Py_DECREF(mod_or_class_dict); goto error; + } _PyErr_Clear(tstate); } } + Py_DECREF(mod_or_class_dict); if (v == NULL) { v = PyDict_GetItemWithError(GLOBALS(), name); if (v != NULL) { @@ -1699,7 +1704,7 @@ } } } - #line 1703 "Python/generated_cases.c.h" + #line 1708 "Python/generated_cases.c.h" _tmp_2 = v; } STACK_GROW(1); @@ -1713,9 +1718,9 @@ { PyObject *mod_or_class_dict = _tmp_2; PyObject *name; - #line 1180 "Python/bytecodes.c" + #line 1181 "Python/bytecodes.c" name = GETITEM(frame->f_code->co_names, oparg); - #line 1719 "Python/generated_cases.c.h" + #line 1724 "Python/generated_cases.c.h" _tmp_2 = mod_or_class_dict; _tmp_1 = name; } @@ -1723,24 +1728,28 @@ PyObject *name = _tmp_1; PyObject *mod_or_class_dict = _tmp_2; PyObject *v; - #line 1184 "Python/bytecodes.c" + #line 1185 "Python/bytecodes.c" if (PyDict_CheckExact(mod_or_class_dict)) { v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { Py_INCREF(v); } else if (_PyErr_Occurred(tstate)) { + Py_DECREF(mod_or_class_dict); goto error; } } else { v = PyObject_GetItem(mod_or_class_dict, name); if (v == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + Py_DECREF(mod_or_class_dict); goto error; + } _PyErr_Clear(tstate); } } + Py_DECREF(mod_or_class_dict); if (v == NULL) { v = PyDict_GetItemWithError(GLOBALS(), name); if (v != NULL) { @@ -1775,7 +1784,7 @@ } } } - #line 1779 "Python/generated_cases.c.h" + #line 1788 "Python/generated_cases.c.h" _tmp_2 = v; } stack_pointer[-1] = _tmp_2; @@ -1787,7 +1796,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1248 "Python/bytecodes.c" + #line 1253 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1839,7 +1848,7 @@ } } null = NULL; - #line 1843 "Python/generated_cases.c.h" + #line 1852 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1853,7 +1862,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1302 "Python/bytecodes.c" + #line 1307 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1864,7 +1873,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1868 "Python/generated_cases.c.h" + #line 1877 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1879,7 +1888,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1315 "Python/bytecodes.c" + #line 1320 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1894,7 +1903,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1898 "Python/generated_cases.c.h" + #line 1907 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1904,16 +1913,16 @@ } TARGET(DELETE_FAST) { - #line 1332 "Python/bytecodes.c" + #line 1337 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1912 "Python/generated_cases.c.h" + #line 1921 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1338 "Python/bytecodes.c" + #line 1343 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1922,12 +1931,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1926 "Python/generated_cases.c.h" + #line 1935 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1349 "Python/bytecodes.c" + #line 1354 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1938,7 +1947,7 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1942 "Python/generated_cases.c.h" + #line 1951 "Python/generated_cases.c.h" DISPATCH(); } @@ -1946,15 +1955,15 @@ PyObject *_tmp_1; { PyObject *class_dict; - #line 1362 "Python/bytecodes.c" - class_dict = LOCALS(); - #line 1952 "Python/generated_cases.c.h" + #line 1367 "Python/bytecodes.c" + class_dict = Py_NewRef(LOCALS()); + #line 1961 "Python/generated_cases.c.h" _tmp_1 = class_dict; } { PyObject *class_dict = _tmp_1; PyObject *value; - #line 1369 "Python/bytecodes.c" + #line 1374 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1965,6 +1974,7 @@ Py_INCREF(value); } else if (_PyErr_Occurred(tstate)) { + Py_DECREF(class_dict); goto error; } } @@ -1972,11 +1982,13 @@ value = PyObject_GetItem(class_dict, name); if (value == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + Py_DECREF(class_dict); goto error; } _PyErr_Clear(tstate); } } + Py_DECREF(class_dict); if (!value) { PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); @@ -1986,7 +1998,7 @@ } Py_INCREF(value); } - #line 1990 "Python/generated_cases.c.h" + #line 2002 "Python/generated_cases.c.h" _tmp_1 = value; } STACK_GROW(1); @@ -2003,7 +2015,7 @@ { PyObject *class_dict = _tmp_1; PyObject *value; - #line 1369 "Python/bytecodes.c" + #line 1374 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -2014,6 +2026,7 @@ Py_INCREF(value); } else if (_PyErr_Occurred(tstate)) { + Py_DECREF(class_dict); goto error; } } @@ -2021,11 +2034,13 @@ value = PyObject_GetItem(class_dict, name); if (value == NULL) { if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { + Py_DECREF(class_dict); goto error; } _PyErr_Clear(tstate); } } + Py_DECREF(class_dict); if (!value) { PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); @@ -2035,7 +2050,7 @@ } Py_INCREF(value); } - #line 2039 "Python/generated_cases.c.h" + #line 2054 "Python/generated_cases.c.h" _tmp_1 = value; } stack_pointer[-1] = _tmp_1; @@ -2044,7 +2059,7 @@ TARGET(LOAD_DEREF) { PyObject *value; - #line 1406 "Python/bytecodes.c" + #line 1414 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -2052,7 +2067,7 @@ if (true) goto error; } Py_INCREF(value); - #line 2056 "Python/generated_cases.c.h" + #line 2071 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -2060,18 +2075,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1416 "Python/bytecodes.c" + #line 1424 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2069 "Python/generated_cases.c.h" + #line 2084 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1423 "Python/bytecodes.c" + #line 1431 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2082,22 +2097,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2086 "Python/generated_cases.c.h" + #line 2101 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1436 "Python/bytecodes.c" + #line 1444 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2095 "Python/generated_cases.c.h" + #line 2110 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1438 "Python/bytecodes.c" + #line 1446 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2101 "Python/generated_cases.c.h" + #line 2116 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2107,10 +2122,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1442 "Python/bytecodes.c" + #line 1450 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2114 "Python/generated_cases.c.h" + #line 2129 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2120,10 +2135,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1447 "Python/bytecodes.c" + #line 1455 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2127 "Python/generated_cases.c.h" + #line 2142 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2133,7 +2148,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1452 "Python/bytecodes.c" + #line 1460 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2144,13 +2159,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2148 "Python/generated_cases.c.h" + #line 2163 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1463 "Python/bytecodes.c" + #line 1471 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2154 "Python/generated_cases.c.h" + #line 2169 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2159,13 +2174,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1470 "Python/bytecodes.c" + #line 1478 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2165 "Python/generated_cases.c.h" + #line 2180 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1472 "Python/bytecodes.c" + #line 1480 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2169 "Python/generated_cases.c.h" + #line 2184 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2173,7 +2188,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1476 "Python/bytecodes.c" + #line 1484 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2188,7 +2203,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2192 "Python/generated_cases.c.h" + #line 2207 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2198,7 +2213,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1493 "Python/bytecodes.c" + #line 1501 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2206,13 +2221,13 @@ if (map == NULL) goto error; - #line 2210 "Python/generated_cases.c.h" + #line 2225 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1501 "Python/bytecodes.c" + #line 1509 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2216 "Python/generated_cases.c.h" + #line 2231 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2220,7 +2235,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1505 "Python/bytecodes.c" + #line 1513 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2260,7 +2275,7 @@ Py_DECREF(ann_dict); } } - #line 2264 "Python/generated_cases.c.h" + #line 2279 "Python/generated_cases.c.h" DISPATCH(); } @@ -2268,7 +2283,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1547 "Python/bytecodes.c" + #line 1555 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2278,14 +2293,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2282 "Python/generated_cases.c.h" + #line 2297 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1557 "Python/bytecodes.c" + #line 1565 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2289 "Python/generated_cases.c.h" + #line 2304 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2293,7 +2308,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1561 "Python/bytecodes.c" + #line 1569 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2301,12 +2316,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2305 "Python/generated_cases.c.h" + #line 2320 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1569 "Python/bytecodes.c" + #line 1577 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2310 "Python/generated_cases.c.h" + #line 2325 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2314,17 +2329,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1575 "Python/bytecodes.c" + #line 1583 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2323 "Python/generated_cases.c.h" + #line 2338 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1580 "Python/bytecodes.c" + #line 1588 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2328 "Python/generated_cases.c.h" + #line 2343 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2334,13 +2349,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1587 "Python/bytecodes.c" + #line 1595 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2344 "Python/generated_cases.c.h" + #line 2359 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2354,7 +2369,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1602 "Python/bytecodes.c" + #line 1610 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2372,16 +2387,16 @@ // handle any case whose performance we care about PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2376 "Python/generated_cases.c.h" + #line 2391 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1620 "Python/bytecodes.c" + #line 1628 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2385 "Python/generated_cases.c.h" + #line 2400 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2396,7 +2411,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1627 "Python/bytecodes.c" + #line 1635 "Python/bytecodes.c" assert(!(oparg & 1)); DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); @@ -2404,7 +2419,7 @@ PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL); if (res == NULL) goto pop_3_error; - #line 2408 "Python/generated_cases.c.h" + #line 2423 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); @@ -2422,7 +2437,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2; PyObject *res; - #line 1638 "Python/bytecodes.c" + #line 1646 "Python/bytecodes.c" assert(oparg & 1); DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); @@ -2443,7 +2458,7 @@ res = res2; res2 = NULL; } - #line 2447 "Python/generated_cases.c.h" + #line 2462 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2457,7 +2472,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1675 "Python/bytecodes.c" + #line 1683 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2491,9 +2506,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2495 "Python/generated_cases.c.h" + #line 2510 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1709 "Python/bytecodes.c" + #line 1717 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2502,12 +2517,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2506 "Python/generated_cases.c.h" + #line 2521 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1718 "Python/bytecodes.c" + #line 1726 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2511 "Python/generated_cases.c.h" + #line 2526 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2521,7 +2536,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1723 "Python/bytecodes.c" + #line 1731 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2534,7 +2549,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2538 "Python/generated_cases.c.h" + #line 2553 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2549,7 +2564,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1739 "Python/bytecodes.c" + #line 1747 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2562,7 +2577,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2566 "Python/generated_cases.c.h" + #line 2581 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2577,7 +2592,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1755 "Python/bytecodes.c" + #line 1763 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2604,7 +2619,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2608 "Python/generated_cases.c.h" + #line 2623 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2619,7 +2634,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1785 "Python/bytecodes.c" + #line 1793 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2629,7 +2644,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2633 "Python/generated_cases.c.h" + #line 2648 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2644,7 +2659,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1798 "Python/bytecodes.c" + #line 1806 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2656,7 +2671,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2660 "Python/generated_cases.c.h" + #line 2675 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2670,7 +2685,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1813 "Python/bytecodes.c" + #line 1821 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2694,7 +2709,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2698 "Python/generated_cases.c.h" + #line 2713 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2702,7 +2717,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1839 "Python/bytecodes.c" + #line 1847 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2728,7 +2743,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2732 "Python/generated_cases.c.h" + #line 2747 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2736,7 +2751,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1867 "Python/bytecodes.c" + #line 1875 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2754,7 +2769,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2758 "Python/generated_cases.c.h" + #line 2773 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2765,7 +2780,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1887 "Python/bytecodes.c" + #line 1895 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2804,7 +2819,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2808 "Python/generated_cases.c.h" + #line 2823 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2815,7 +2830,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1928 "Python/bytecodes.c" + #line 1936 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2825,7 +2840,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2829 "Python/generated_cases.c.h" + #line 2844 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2837,7 +2852,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1947 "Python/bytecodes.c" + #line 1955 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2850,12 +2865,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2854 "Python/generated_cases.c.h" + #line 2869 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1960 "Python/bytecodes.c" + #line 1968 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2859 "Python/generated_cases.c.h" + #line 2874 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2866,7 +2881,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1964 "Python/bytecodes.c" + #line 1972 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2878,7 +2893,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2882 "Python/generated_cases.c.h" + #line 2897 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2889,7 +2904,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1979 "Python/bytecodes.c" + #line 1987 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2905,7 +2920,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2909 "Python/generated_cases.c.h" + #line 2924 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2916,7 +2931,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1998 "Python/bytecodes.c" + #line 2006 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2929,7 +2944,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2933 "Python/generated_cases.c.h" + #line 2948 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2940,14 +2955,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2013 "Python/bytecodes.c" + #line 2021 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2946 "Python/generated_cases.c.h" + #line 2961 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2015 "Python/bytecodes.c" + #line 2023 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2951 "Python/generated_cases.c.h" + #line 2966 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2957,15 +2972,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2019 "Python/bytecodes.c" + #line 2027 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2963 "Python/generated_cases.c.h" + #line 2978 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2021 "Python/bytecodes.c" + #line 2029 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2969 "Python/generated_cases.c.h" + #line 2984 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2976,12 +2991,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2026 "Python/bytecodes.c" + #line 2034 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2982 "Python/generated_cases.c.h" + #line 2997 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2028 "Python/bytecodes.c" + #line 2036 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2989,10 +3004,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2993 "Python/generated_cases.c.h" + #line 3008 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2036 "Python/bytecodes.c" + #line 2044 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -3001,7 +3016,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 3005 "Python/generated_cases.c.h" + #line 3020 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -3011,21 +3026,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2047 "Python/bytecodes.c" + #line 2055 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 3018 "Python/generated_cases.c.h" + #line 3033 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2050 "Python/bytecodes.c" + #line 2058 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 3025 "Python/generated_cases.c.h" + #line 3040 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2055 "Python/bytecodes.c" + #line 2063 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 3029 "Python/generated_cases.c.h" + #line 3044 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -3034,15 +3049,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2059 "Python/bytecodes.c" + #line 2067 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 3041 "Python/generated_cases.c.h" + #line 3056 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2062 "Python/bytecodes.c" + #line 2070 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 3046 "Python/generated_cases.c.h" + #line 3061 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -3051,29 +3066,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2066 "Python/bytecodes.c" + #line 2074 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 3059 "Python/generated_cases.c.h" + #line 3074 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2072 "Python/bytecodes.c" + #line 2080 "Python/bytecodes.c" JUMPBY(oparg); - #line 3068 "Python/generated_cases.c.h" + #line 3083 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2076 "Python/bytecodes.c" + #line 2084 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 3077 "Python/generated_cases.c.h" + #line 3092 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -3081,7 +3096,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2082 "Python/bytecodes.c" + #line 2090 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3091,9 +3106,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3095 "Python/generated_cases.c.h" + #line 3110 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2092 "Python/bytecodes.c" + #line 2100 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3101,14 +3116,14 @@ if (err < 0) goto pop_1_error; } } - #line 3105 "Python/generated_cases.c.h" + #line 3120 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2102 "Python/bytecodes.c" + #line 2110 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3118,9 +3133,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3122 "Python/generated_cases.c.h" + #line 3137 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2112 "Python/bytecodes.c" + #line 2120 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3128,67 +3143,67 @@ if (err < 0) goto pop_1_error; } } - #line 3132 "Python/generated_cases.c.h" + #line 3147 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2122 "Python/bytecodes.c" + #line 2130 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3141 "Python/generated_cases.c.h" + #line 3156 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2124 "Python/bytecodes.c" + #line 2132 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3149 "Python/generated_cases.c.h" + #line 3164 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2132 "Python/bytecodes.c" + #line 2140 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3162 "Python/generated_cases.c.h" + #line 3177 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2138 "Python/bytecodes.c" + #line 2146 "Python/bytecodes.c" } - #line 3166 "Python/generated_cases.c.h" + #line 3181 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2142 "Python/bytecodes.c" + #line 2150 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3179 "Python/generated_cases.c.h" + #line 3194 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2151 "Python/bytecodes.c" + #line 2159 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3192 "Python/generated_cases.c.h" + #line 3207 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3199,16 +3214,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2159 "Python/bytecodes.c" + #line 2167 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3208 "Python/generated_cases.c.h" + #line 3223 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2164 "Python/bytecodes.c" + #line 2172 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3216,7 +3231,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3220 "Python/generated_cases.c.h" + #line 3235 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3225,10 +3240,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2174 "Python/bytecodes.c" + #line 2182 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3232 "Python/generated_cases.c.h" + #line 3247 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3238,10 +3253,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2180 "Python/bytecodes.c" + #line 2188 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3245 "Python/generated_cases.c.h" + #line 3260 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3252,11 +3267,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2186 "Python/bytecodes.c" + #line 2194 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3260 "Python/generated_cases.c.h" + #line 3275 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3265,14 +3280,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2192 "Python/bytecodes.c" + #line 2200 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3272 "Python/generated_cases.c.h" + #line 3287 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2195 "Python/bytecodes.c" + #line 2203 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3276 "Python/generated_cases.c.h" + #line 3291 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3280,7 +3295,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2199 "Python/bytecodes.c" + #line 2207 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3303,11 +3318,11 @@ if (iter == NULL) { goto error; } - #line 3307 "Python/generated_cases.c.h" + #line 3322 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2222 "Python/bytecodes.c" + #line 2230 "Python/bytecodes.c" } - #line 3311 "Python/generated_cases.c.h" + #line 3326 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3318,7 +3333,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2241 "Python/bytecodes.c" + #line 2249 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3349,7 +3364,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3353 "Python/generated_cases.c.h" + #line 3368 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3357,7 +3372,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2274 "Python/bytecodes.c" + #line 2282 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3383,14 +3398,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3387 "Python/generated_cases.c.h" + #line 3402 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2302 "Python/bytecodes.c" + #line 2310 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3410,7 +3425,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3414 "Python/generated_cases.c.h" + #line 3429 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3420,7 +3435,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2324 "Python/bytecodes.c" + #line 2332 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3440,7 +3455,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3444 "Python/generated_cases.c.h" + #line 3459 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3450,7 +3465,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2346 "Python/bytecodes.c" + #line 2354 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3468,7 +3483,7 @@ if (next == NULL) { goto error; } - #line 3472 "Python/generated_cases.c.h" + #line 3487 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3477,7 +3492,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2366 "Python/bytecodes.c" + #line 2374 "Python/bytecodes.c" PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING, FOR_ITER); @@ -3492,14 +3507,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3496 "Python/generated_cases.c.h" + #line 3511 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2383 "Python/bytecodes.c" + #line 2391 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3522,16 +3537,16 @@ Py_DECREF(enter); goto error; } - #line 3526 "Python/generated_cases.c.h" + #line 3541 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2406 "Python/bytecodes.c" + #line 2414 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3535 "Python/generated_cases.c.h" + #line 3550 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3543,7 +3558,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2416 "Python/bytecodes.c" + #line 2424 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3569,16 +3584,16 @@ Py_DECREF(enter); goto error; } - #line 3573 "Python/generated_cases.c.h" + #line 3588 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2442 "Python/bytecodes.c" + #line 2450 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3582 "Python/generated_cases.c.h" + #line 3597 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3590,7 +3605,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2451 "Python/bytecodes.c" + #line 2459 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3611,7 +3626,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3615 "Python/generated_cases.c.h" + #line 3630 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3620,7 +3635,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2474 "Python/bytecodes.c" + #line 2482 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3630,7 +3645,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3634 "Python/generated_cases.c.h" + #line 3649 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3644,7 +3659,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2486 "Python/bytecodes.c" + #line 2494 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3661,7 +3676,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3665 "Python/generated_cases.c.h" + #line 3680 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3675,7 +3690,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2505 "Python/bytecodes.c" + #line 2513 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3685,7 +3700,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3689 "Python/generated_cases.c.h" + #line 3704 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3699,7 +3714,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2517 "Python/bytecodes.c" + #line 2525 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3713,7 +3728,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3717 "Python/generated_cases.c.h" + #line 3732 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3722,16 +3737,16 @@ } TARGET(KW_NAMES) { - #line 2533 "Python/bytecodes.c" + #line 2541 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3730 "Python/generated_cases.c.h" + #line 3745 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2539 "Python/bytecodes.c" + #line 2547 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3744,7 +3759,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3748 "Python/generated_cases.c.h" + #line 3763 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3754,7 +3769,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2584 "Python/bytecodes.c" + #line 2592 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3836,7 +3851,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3840 "Python/generated_cases.c.h" + #line 3855 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3848,7 +3863,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2672 "Python/bytecodes.c" + #line 2680 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3858,7 +3873,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3862 "Python/generated_cases.c.h" + #line 3877 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3867,7 +3882,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2684 "Python/bytecodes.c" + #line 2692 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3893,7 +3908,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3897 "Python/generated_cases.c.h" + #line 3912 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3901,7 +3916,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2712 "Python/bytecodes.c" + #line 2720 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3937,7 +3952,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3941 "Python/generated_cases.c.h" + #line 3956 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3945,7 +3960,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2750 "Python/bytecodes.c" + #line 2758 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3955,7 +3970,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3959 "Python/generated_cases.c.h" + #line 3974 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3968,7 +3983,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2762 "Python/bytecodes.c" + #line 2770 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3979,7 +3994,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3983 "Python/generated_cases.c.h" + #line 3998 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3993,7 +4008,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2776 "Python/bytecodes.c" + #line 2784 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4004,7 +4019,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4008 "Python/generated_cases.c.h" + #line 4023 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4018,7 +4033,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2790 "Python/bytecodes.c" + #line 2798 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4040,7 +4055,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4044 "Python/generated_cases.c.h" + #line 4059 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4054,7 +4069,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2815 "Python/bytecodes.c" + #line 2823 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4082,7 +4097,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4086 "Python/generated_cases.c.h" + #line 4101 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4096,7 +4111,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2846 "Python/bytecodes.c" + #line 2854 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4128,7 +4143,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4132 "Python/generated_cases.c.h" + #line 4147 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4142,7 +4157,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2881 "Python/bytecodes.c" + #line 2889 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4174,7 +4189,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4178 "Python/generated_cases.c.h" + #line 4193 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4188,7 +4203,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2916 "Python/bytecodes.c" + #line 2924 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4213,7 +4228,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4217 "Python/generated_cases.c.h" + #line 4232 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4226,7 +4241,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2943 "Python/bytecodes.c" + #line 2951 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4253,7 +4268,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4257 "Python/generated_cases.c.h" + #line 4272 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4265,7 +4280,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2973 "Python/bytecodes.c" + #line 2981 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4283,14 +4298,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4287 "Python/generated_cases.c.h" + #line 4302 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2993 "Python/bytecodes.c" + #line 3001 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4321,7 +4336,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4325 "Python/generated_cases.c.h" + #line 4340 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4334,7 +4349,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3027 "Python/bytecodes.c" + #line 3035 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4363,7 +4378,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4367 "Python/generated_cases.c.h" + #line 4382 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4376,7 +4391,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3059 "Python/bytecodes.c" + #line 3067 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4405,7 +4420,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4409 "Python/generated_cases.c.h" + #line 4424 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4418,7 +4433,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3091 "Python/bytecodes.c" + #line 3099 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4446,7 +4461,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4450 "Python/generated_cases.c.h" + #line 4465 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4456,9 +4471,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3122 "Python/bytecodes.c" + #line 3130 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4462 "Python/generated_cases.c.h" + #line 4477 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4467,7 +4482,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3126 "Python/bytecodes.c" + #line 3134 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4529,14 +4544,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4533 "Python/generated_cases.c.h" + #line 4548 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3188 "Python/bytecodes.c" + #line 3196 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4540 "Python/generated_cases.c.h" + #line 4555 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4551,7 +4566,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3198 "Python/bytecodes.c" + #line 3206 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4580,14 +4595,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4584 "Python/generated_cases.c.h" + #line 4599 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3229 "Python/bytecodes.c" + #line 3237 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4608,7 +4623,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4612 "Python/generated_cases.c.h" + #line 4627 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4616,15 +4631,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3252 "Python/bytecodes.c" + #line 3260 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4622 "Python/generated_cases.c.h" + #line 4637 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3254 "Python/bytecodes.c" + #line 3262 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4628 "Python/generated_cases.c.h" + #line 4643 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4635,7 +4650,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3258 "Python/bytecodes.c" + #line 3266 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4670,7 +4685,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4674 "Python/generated_cases.c.h" + #line 4689 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4679,10 +4694,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3295 "Python/bytecodes.c" + #line 3303 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4686 "Python/generated_cases.c.h" + #line 4701 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4694,7 +4709,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3300 "Python/bytecodes.c" + #line 3308 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4709,12 +4724,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4713 "Python/generated_cases.c.h" + #line 4728 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3315 "Python/bytecodes.c" + #line 3323 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4718 "Python/generated_cases.c.h" + #line 4733 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4724,16 +4739,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3320 "Python/bytecodes.c" + #line 3328 "Python/bytecodes.c" assert(oparg >= 2); - #line 4730 "Python/generated_cases.c.h" + #line 4745 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_LINE) { - #line 3324 "Python/bytecodes.c" + #line 3332 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _PyFrame_SetStackPointer(frame, stack_pointer); int original_opcode = _Py_call_instrumentation_line( @@ -4753,11 +4768,11 @@ } opcode = original_opcode; DISPATCH_GOTO(); - #line 4757 "Python/generated_cases.c.h" + #line 4772 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3346 "Python/bytecodes.c" + #line 3354 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4769,26 +4784,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4773 "Python/generated_cases.c.h" + #line 4788 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3360 "Python/bytecodes.c" + #line 3368 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4779 "Python/generated_cases.c.h" + #line 4794 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3364 "Python/bytecodes.c" + #line 3372 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4786 "Python/generated_cases.c.h" + #line 4801 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3369 "Python/bytecodes.c" + #line 3377 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4797,12 +4812,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4801 "Python/generated_cases.c.h" + #line 4816 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3380 "Python/bytecodes.c" + #line 3388 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4811,12 +4826,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4815 "Python/generated_cases.c.h" + #line 4830 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3391 "Python/bytecodes.c" + #line 3399 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4829,12 +4844,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4833 "Python/generated_cases.c.h" + #line 4848 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3406 "Python/bytecodes.c" + #line 3414 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4847,30 +4862,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4851 "Python/generated_cases.c.h" + #line 4866 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3421 "Python/bytecodes.c" + #line 3429 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4862 "Python/generated_cases.c.h" + #line 4877 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3429 "Python/bytecodes.c" + #line 3437 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4869 "Python/generated_cases.c.h" + #line 4884 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3434 "Python/bytecodes.c" + #line 3442 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4876 "Python/generated_cases.c.h" + #line 4891 "Python/generated_cases.c.h" } From 3817ab4d2a3b5240f4f4777776910be604951b08 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 May 2023 06:51:41 -0700 Subject: [PATCH 187/200] Fix one more refleak --- Lib/test/test_typing.py | 2 ++ Objects/typevarobject.c | 1 + 2 files changed, 3 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index d77542cd991460..bada2edfd81ba6 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -6004,6 +6004,8 @@ def test_mutablesequence(self): self.assertNotIsInstance((), typing.MutableSequence) def test_bytestring(self): + # ensure it's not already imported + typing._remove_cached_ByteString_from_globals() with self.assertWarns(DeprecationWarning): from typing import ByteString with self.assertWarns(DeprecationWarning): diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index bc232c01a6d32a..10205e479b9827 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -83,6 +83,7 @@ type_check(PyObject *arg, const char *msg) } PyObject *args[2] = {arg, message_str}; PyObject *result = call_typing_func_object("_type_check", args, 2); + Py_DECREF(message_str); return result; } From f2a939349fc4c194f447f20a94c859dbe39b968a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 May 2023 06:57:50 -0700 Subject: [PATCH 188/200] Remove unrelated change --- Lib/test/test_typing.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index bada2edfd81ba6..d77542cd991460 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -6004,8 +6004,6 @@ def test_mutablesequence(self): self.assertNotIsInstance((), typing.MutableSequence) def test_bytestring(self): - # ensure it's not already imported - typing._remove_cached_ByteString_from_globals() with self.assertWarns(DeprecationWarning): from typing import ByteString with self.assertWarns(DeprecationWarning): From 4f1223e9a91f53d37d3a2a680f88807401cc9d7f Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 May 2023 07:01:24 -0700 Subject: [PATCH 189/200] remove stray raw assert --- Lib/test/test_type_params.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 10c2c71534e737..fbf809d8e59d29 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -261,8 +261,6 @@ class ClassA: x = int def func[T](self, a: x, b: T): ... - - assert ClassA.func.__annotations__["a"] is int """ ) cls = ns["ClassA"] From 33f4c12d7a56b9aef7b86ccaa6255231166c5dff Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 May 2023 11:35:00 -0700 Subject: [PATCH 190/200] Update typevarobject.c: use Py_RETURN_NONE --- Objects/typevarobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 10205e479b9827..19da4cb514c734 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -116,7 +116,7 @@ caller(void) PyObject *r = PyFunction_GetModule(f->f_funcobj); if (!r) { PyErr_Clear(); - r = Py_None; + Py_RETURN_NONE; } return Py_NewRef(r); } From b9f454070a88b7ac02cfef7ae9cafc751a542515 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 May 2023 12:28:42 -0700 Subject: [PATCH 191/200] Review feedback --- Lib/test/support/__init__.py | 7 +++++++ Lib/test/test_type_aliases.py | 4 +--- Lib/test/test_type_params.py | 10 ++-------- Objects/funcobject.c | 2 +- Objects/typevarobject.c | 8 ++++---- Python/intrinsics.c | 6 +++--- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index d063837baee2de..cd7167bd6898ef 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -12,6 +12,7 @@ import stat import sys import sysconfig +import textwrap import time import types import unittest @@ -619,6 +620,12 @@ def sortdict(dict): withcommas = ", ".join(reprpairs) return "{%s}" % withcommas +def run_code(code: str) -> dict[str, object]: + """Run a piece of code after dedenting it, and return its global namespace.""" + ns = {} + exec(textwrap.dedent(code), ns) + return ns + def check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None): with testcase.assertRaisesRegex(SyntaxError, errtext) as cm: compile(statement, '', 'exec') diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index 18bfbefe165042..dcf167991ec5f0 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -1,11 +1,9 @@ import types import unittest -from test.support import check_syntax_error +from test.support import check_syntax_error, run_code from typing import Callable, TypeAliasType, TypeVar, get_args -from .test_type_params import run_code - class TypeParamsInvalidTest(unittest.TestCase): def test_name_collision_01(self): diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index fbf809d8e59d29..734c769d4ee1b2 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -2,15 +2,9 @@ import textwrap import types import unittest -from test.support import requires_working_socket, check_syntax_error +from test.support import requires_working_socket, check_syntax_error, run_code -from typing import Any, Generic, Sequence, TypeVar, TypeVarTuple, ParamSpec, get_args - - -def run_code(code: str) -> dict[str, Any]: - ns = {} - exec(textwrap.dedent(code), ns) - return ns +from typing import Generic, Sequence, TypeVar, TypeVarTuple, ParamSpec, get_args class TypeParamsInvalidTest(unittest.TestCase): diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 82e221e43cc9ac..69898bf722d61f 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -666,7 +666,7 @@ func_get_type_params(PyFunctionObject *op, void *Py_UNUSED(ignored)) } PyObject * -_Py_set_function_type_params(PyThreadState *unused, PyObject *func, +_Py_set_function_type_params(PyThreadState *Py_UNUSED(ignored), PyObject *func, PyObject *type_params) { assert(PyFunction_Check(func)); diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 19da4cb514c734..6c7bb2d4e3b655 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -248,7 +248,7 @@ static PyMemberDef typevar_members[] = { }; static PyObject * -typevar_bound(typevarobject *self, void *unused) +typevar_bound(typevarobject *self, void *Py_UNUSED(ignored)) { if (self->bound != NULL) { return Py_NewRef(self->bound); @@ -262,7 +262,7 @@ typevar_bound(typevarobject *self, void *unused) } static PyObject * -typevar_constraints(typevarobject *self, void *unused) +typevar_constraints(typevarobject *self, void *Py_UNUSED(ignored)) { if (self->constraints != NULL) { return Py_NewRef(self->constraints); @@ -1246,14 +1246,14 @@ _Py_make_typevar(const char *name, PyObject *evaluate_bound, PyObject *evaluate_ } PyObject * -_Py_make_paramspec(PyThreadState *unused, PyObject *v) +_Py_make_paramspec(PyThreadState *Py_UNUSED(ignored), PyObject *v) { assert(PyUnicode_Check(v)); return (PyObject *)paramspec_alloc(PyUnicode_AsUTF8(v), NULL, false, false, true, NULL); } PyObject * -_Py_make_typevartuple(PyThreadState *unused, PyObject *v) +_Py_make_typevartuple(PyThreadState *Py_UNUSED(ignored), PyObject *v) { assert(PyUnicode_Check(v)); return (PyObject *)typevartuple_alloc(PyUnicode_AsUTF8(v), NULL); diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 03d87cf1450699..e2787312a67681 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -202,7 +202,7 @@ list_to_tuple(PyThreadState* unused, PyObject *v) } static PyObject * -make_typevar(PyThreadState* unused, PyObject *v) +make_typevar(PyThreadState* Py_UNUSED(ignored), PyObject *v) { assert(PyUnicode_Check(v)); return _Py_make_typevar(PyUnicode_AsUTF8(v), NULL, NULL); @@ -236,7 +236,7 @@ prep_reraise_star(PyThreadState* unused, PyObject *orig, PyObject *excs) } static PyObject * -make_typevar_with_bound(PyThreadState* unused, PyObject *name, +make_typevar_with_bound(PyThreadState* Py_UNUSED(ignored), PyObject *name, PyObject *evaluate_bound) { assert(PyUnicode_Check(name)); @@ -244,7 +244,7 @@ make_typevar_with_bound(PyThreadState* unused, PyObject *name, } static PyObject * -make_typevar_with_constraints(PyThreadState* unused, PyObject *name, +make_typevar_with_constraints(PyThreadState* Py_UNUSED(ignored), PyObject *name, PyObject *evaluate_constraints) { assert(PyUnicode_Check(name)); From 8a783b33edda441fb851d2d7ea80e3587db13c6a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 12 May 2023 12:35:38 -0700 Subject: [PATCH 192/200] Update Lib/test/support/__init__.py Co-authored-by: Alex Waygood --- Lib/test/support/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index cd7167bd6898ef..d555c53fee50a2 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -620,12 +620,14 @@ def sortdict(dict): withcommas = ", ".join(reprpairs) return "{%s}" % withcommas + def run_code(code: str) -> dict[str, object]: """Run a piece of code after dedenting it, and return its global namespace.""" ns = {} exec(textwrap.dedent(code), ns) return ns + def check_syntax_error(testcase, statement, errtext='', *, lineno=None, offset=None): with testcase.assertRaisesRegex(SyntaxError, errtext) as cm: compile(statement, '', 'exec') From 0aad1f49ee5ff039bc42f4b89911071ff9b9d4be Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 13 May 2023 19:24:23 -0700 Subject: [PATCH 193/200] Use PyObject for TypeVar etc. names --- Include/internal/pycore_typevarobject.h | 2 +- Objects/clinic/typevarobject.c.h | 58 +++-------- Objects/typevarobject.c | 129 ++++++++++-------------- Python/intrinsics.c | 7 +- 4 files changed, 68 insertions(+), 128 deletions(-) diff --git a/Include/internal/pycore_typevarobject.h b/Include/internal/pycore_typevarobject.h index 9f312fbba0740a..2035e47e923059 100644 --- a/Include/internal/pycore_typevarobject.h +++ b/Include/internal/pycore_typevarobject.h @@ -8,7 +8,7 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif -extern PyObject *_Py_make_typevar(const char *, PyObject *, PyObject *); +extern PyObject *_Py_make_typevar(PyObject *, PyObject *, PyObject *); extern PyObject *_Py_make_paramspec(PyThreadState *, PyObject *); extern PyObject *_Py_make_typevartuple(PyThreadState *, PyObject *); extern PyObject *_Py_make_typealias(PyThreadState *, PyObject *); diff --git a/Objects/clinic/typevarobject.c.h b/Objects/clinic/typevarobject.c.h index 9efdedc7944c34..54189b98446814 100644 --- a/Objects/clinic/typevarobject.c.h +++ b/Objects/clinic/typevarobject.c.h @@ -16,7 +16,7 @@ PyDoc_STRVAR(typevar_new__doc__, "Create a TypeVar."); static PyObject * -typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, +typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints, PyObject *bound, int covariant, int contravariant, int infer_variance); @@ -53,7 +53,7 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t noptargs = Py_MIN(nargs, 1) + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; - const char *name; + PyObject *name; PyObject *constraints = NULL; PyObject *bound = Py_None; int covariant = 0; @@ -68,15 +68,7 @@ typevar_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("typevar", "argument 'name'", "str", fastargs[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } + name = fastargs[0]; constraints = fastargs[1]; if (!noptargs) { goto skip_optional_kwonly; @@ -304,7 +296,7 @@ PyDoc_STRVAR(paramspec_new__doc__, "Create a ParamSpec object."); static PyObject * -paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, +paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound, int covariant, int contravariant, int infer_variance); static PyObject * @@ -340,7 +332,7 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; - const char *name; + PyObject *name; PyObject *bound = Py_None; int covariant = 0; int contravariant = 0; @@ -354,15 +346,7 @@ paramspec_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("paramspec", "argument 'name'", "str", fastargs[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } + name = fastargs[0]; if (!noptargs) { goto skip_optional_kwonly; } @@ -536,7 +520,7 @@ PyDoc_STRVAR(typevartuple__doc__, "Create a new TypeVarTuple with the given name."); static PyObject * -typevartuple_impl(PyTypeObject *type, const char *name); +typevartuple_impl(PyTypeObject *type, PyObject *name); static PyObject * typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) @@ -570,7 +554,7 @@ typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *argsbuf[1]; PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); - const char *name; + PyObject *name; fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); if (!fastargs) { @@ -580,15 +564,7 @@ typevartuple(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("typevartuple", "argument 'name'", "str", fastargs[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } + name = fastargs[0]; return_value = typevartuple_impl(type, name); exit: @@ -747,7 +723,7 @@ PyDoc_STRVAR(typealias_new__doc__, "Create a TypeAliasType."); static PyObject * -typealias_new_impl(PyTypeObject *type, const char *name, PyObject *value, +typealias_new_impl(PyTypeObject *type, PyObject *name, PyObject *value, PyObject *type_params); static PyObject * @@ -783,7 +759,7 @@ typealias_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject * const *fastargs; Py_ssize_t nargs = PyTuple_GET_SIZE(args); Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2; - const char *name; + PyObject *name; PyObject *value; PyObject *type_params = NULL; @@ -795,15 +771,7 @@ typealias_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) _PyArg_BadArgument("typealias", "argument 'name'", "str", fastargs[0]); goto exit; } - Py_ssize_t name_length; - name = PyUnicode_AsUTF8AndSize(fastargs[0], &name_length); - if (name == NULL) { - goto exit; - } - if (strlen(name) != (size_t)name_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } + name = fastargs[0]; value = fastargs[1]; if (!noptargs) { goto skip_optional_kwonly; @@ -815,4 +783,4 @@ typealias_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=61f317e6bb78de3b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=807bcd30ebd10ac3 input=a9049054013a1b77]*/ diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 6c7bb2d4e3b655..b0578756f7dfcc 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -18,7 +18,7 @@ class Generic "PyObject *" "&PyGeneric_Type" typedef struct { PyObject_HEAD - const char *name; + PyObject *name; PyObject *bound; PyObject *evaluate_bound; PyObject *constraints; @@ -30,12 +30,12 @@ typedef struct { typedef struct { PyObject_HEAD - const char *name; + PyObject *name; } typevartupleobject; typedef struct { PyObject_HEAD - const char *name; + PyObject *name; PyObject *bound; bool covariant; bool contravariant; @@ -44,7 +44,7 @@ typedef struct { typedef struct { PyObject_HEAD - const char *name; + PyObject *name; PyObject *type_params; PyObject *compute_value; PyObject *value; @@ -161,6 +161,9 @@ unpack_typevartuples(PyObject *params) if (contains_typevartuple((PyTupleObject *)params)) { Py_ssize_t n = PyTuple_GET_SIZE(params); PyObject *new_params = PyTuple_New(n); + if (new_params == NULL) { + return NULL; + } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; for (Py_ssize_t i = 0; i < n; i++) { PyObject *param = PyTuple_GET_ITEM(params, i); @@ -191,7 +194,7 @@ typevar_dealloc(PyObject *self) _PyObject_GC_UNTRACK(self); - free((void *)tv->name); + Py_DECREF(tv->name); Py_XDECREF(tv->bound); Py_XDECREF(tv->evaluate_bound); Py_XDECREF(tv->constraints); @@ -232,15 +235,15 @@ typevar_repr(PyObject *self) typevarobject *tv = (typevarobject *)self; if (tv->infer_variance) { - return PyUnicode_FromFormat("%s", tv->name); + return Py_NewRef(tv->name); } char variance = tv->covariant ? '+' : tv->contravariant ? '-' : '~'; - return PyUnicode_FromFormat("%c%s", variance, tv->name); + return PyUnicode_FromFormat("%c%U", variance, tv->name); } static PyMemberDef typevar_members[] = { - {"__name__", T_STRING, offsetof(typevarobject, name), READONLY}, + {"__name__", T_OBJECT, offsetof(typevarobject, name), READONLY}, {"__covariant__", T_BOOL, offsetof(typevarobject, covariant), READONLY}, {"__contravariant__", T_BOOL, offsetof(typevarobject, contravariant), READONLY}, {"__infer_variance__", T_BOOL, offsetof(typevarobject, infer_variance), READONLY}, @@ -282,27 +285,19 @@ static PyGetSetDef typevar_getset[] = { }; static typevarobject * -typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, +typevar_alloc(PyObject *name, PyObject *bound, PyObject *evaluate_bound, PyObject *constraints, PyObject *evaluate_constraints, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { - - char *owned_name = strdup(name); - if (owned_name == NULL) { - PyErr_NoMemory(); - return NULL; - } - PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevar_type; assert(tp != NULL); typevarobject *tv = PyObject_GC_New(typevarobject, tp); if (tv == NULL) { - free((void *)owned_name); return NULL; } - tv->name = owned_name; + tv->name = Py_NewRef(name); tv->bound = Py_XNewRef(bound); tv->evaluate_bound = Py_XNewRef(evaluate_bound); @@ -328,7 +323,7 @@ typevar_alloc(const char *name, PyObject *bound, PyObject *evaluate_bound, @classmethod typevar.__new__ as typevar_new - name: str + name: object(subclass_of="&PyUnicode_Type") *constraints: object * bound: object = None @@ -340,10 +335,10 @@ Create a TypeVar. [clinic start generated code]*/ static PyObject * -typevar_new_impl(PyTypeObject *type, const char *name, PyObject *constraints, +typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints, PyObject *bound, int covariant, int contravariant, int infer_variance) -/*[clinic end generated code: output=463d42203b82ea59 input=55a3db20c1cf1450]*/ +/*[clinic end generated code: output=1d200450ee99226d input=2c07ab87c94f462b]*/ { if (covariant && contravariant) { PyErr_SetString(PyExc_ValueError, @@ -426,7 +421,7 @@ static PyObject * typevar_reduce_impl(typevarobject *self) /*[clinic end generated code: output=02e5c55d7cf8a08f input=de76bc95f04fb9ff]*/ { - return PyUnicode_FromString(self->name); + return Py_NewRef(self->name); } static PyObject * @@ -586,7 +581,7 @@ paramspecargs_repr(PyObject *self) PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; if (Py_IS_TYPE(psa->__origin__, tp)) { - return PyUnicode_FromFormat("%s.args", + return PyUnicode_FromFormat("%U.args", ((paramspecobject *)psa->__origin__)->name); } return PyUnicode_FromFormat("%R.args", psa->__origin__); @@ -664,7 +659,7 @@ paramspeckwargs_repr(PyObject *self) PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; if (Py_IS_TYPE(psk->__origin__, tp)) { - return PyUnicode_FromFormat("%s.kwargs", + return PyUnicode_FromFormat("%U.kwargs", ((paramspecobject *)psk->__origin__)->name); } return PyUnicode_FromFormat("%R.kwargs", psk->__origin__); @@ -742,7 +737,7 @@ paramspec_dealloc(PyObject *self) _PyObject_GC_UNTRACK(self); - free((void *)ps->name); + Py_DECREF(ps->name); Py_XDECREF(ps->bound); _PyObject_ClearManagedDict(self); @@ -774,15 +769,15 @@ paramspec_repr(PyObject *self) paramspecobject *ps = (paramspecobject *)self; if (ps->infer_variance) { - return PyUnicode_FromFormat("%s", ps->name); + return Py_NewRef(ps->name); } char variance = ps->covariant ? '+' : ps->contravariant ? '-' : '~'; - return PyUnicode_FromFormat("%c%s", variance, ps->name); + return PyUnicode_FromFormat("%c%U", variance, ps->name); } static PyMemberDef paramspec_members[] = { - {"__name__", T_STRING, offsetof(paramspecobject, name), READONLY}, + {"__name__", T_OBJECT, offsetof(paramspecobject, name), READONLY}, {"__bound__", T_OBJECT, offsetof(paramspecobject, bound), READONLY}, {"__covariant__", T_BOOL, offsetof(paramspecobject, covariant), READONLY}, {"__contravariant__", T_BOOL, offsetof(paramspecobject, contravariant), READONLY}, @@ -811,21 +806,15 @@ static PyGetSetDef paramspec_getset[] = { }; static paramspecobject * -paramspec_alloc(const char *name, PyObject *bound, bool covariant, +paramspec_alloc(PyObject *name, PyObject *bound, bool covariant, bool contravariant, bool infer_variance, PyObject *module) { - char *owned_name = strdup(name); - if (owned_name == NULL) { - PyErr_NoMemory(); - return NULL; - } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.paramspec_type; paramspecobject *ps = PyObject_GC_New(paramspecobject, tp); if (ps == NULL) { - free((void *)owned_name); return NULL; } - ps->name = owned_name; + ps->name = Py_NewRef(name); ps->bound = Py_XNewRef(bound); ps->covariant = covariant; ps->contravariant = contravariant; @@ -844,7 +833,7 @@ paramspec_alloc(const char *name, PyObject *bound, bool covariant, @classmethod paramspec.__new__ as paramspec_new - name: str + name: object(subclass_of="&PyUnicode_Type") * bound: object = None covariant: bool = False @@ -855,9 +844,9 @@ Create a ParamSpec object. [clinic start generated code]*/ static PyObject * -paramspec_new_impl(PyTypeObject *type, const char *name, PyObject *bound, +paramspec_new_impl(PyTypeObject *type, PyObject *name, PyObject *bound, int covariant, int contravariant, int infer_variance) -/*[clinic end generated code: output=846484852fb0dda8 input=f83ea6382c481f21]*/ +/*[clinic end generated code: output=fd2daab79cba62da input=57c49c581979b952]*/ { if (covariant && contravariant) { PyErr_SetString(PyExc_ValueError, "Bivariant types are not supported."); @@ -930,7 +919,7 @@ static PyObject * paramspec_reduce_impl(paramspecobject *self) /*[clinic end generated code: output=b83398674416db27 input=5bf349f0d5dd426c]*/ { - return PyUnicode_FromString(self->name); + return Py_NewRef(self->name); } static PyObject * @@ -1028,7 +1017,7 @@ typevartuple_dealloc(PyObject *self) _PyObject_GC_UNTRACK(self); typevartupleobject *tvt = (typevartupleobject *)self; - free((void *)tvt->name); + Py_DECREF(tvt->name); _PyObject_ClearManagedDict(self); Py_TYPE(self)->tp_free(self); @@ -1058,29 +1047,23 @@ typevartuple_repr(PyObject *self) { typevartupleobject *tvt = (typevartupleobject *)self; - return PyUnicode_FromFormat("%s", tvt->name); + return Py_NewRef(tvt->name); } static PyMemberDef typevartuple_members[] = { - {"__name__", T_STRING, offsetof(typevartupleobject, name), READONLY}, + {"__name__", T_OBJECT, offsetof(typevartupleobject, name), READONLY}, {0} }; static typevartupleobject * -typevartuple_alloc(const char *name, PyObject *module) +typevartuple_alloc(PyObject *name, PyObject *module) { - char *owned_name = strdup(name); - if (owned_name == NULL) { - PyErr_NoMemory(); - return NULL; - } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typevartuple_type; typevartupleobject *tvt = PyObject_GC_New(typevartupleobject, tp); if (tvt == NULL) { - free(owned_name); return NULL; } - tvt->name = owned_name; + tvt->name = Py_NewRef(name); _PyObject_GC_TRACK(tvt); if (module != NULL) { if (PyObject_SetAttrString((PyObject *)tvt, "__module__", module) < 0) { @@ -1095,14 +1078,14 @@ typevartuple_alloc(const char *name, PyObject *module) @classmethod typevartuple.__new__ - name: str + name: object(subclass_of="&PyUnicode_Type") Create a new TypeVarTuple with the given name. [clinic start generated code]*/ static PyObject * -typevartuple_impl(PyTypeObject *type, const char *name) -/*[clinic end generated code: output=a5a5bc3437a27749 input=d89424a0e967cee6]*/ +typevartuple_impl(PyTypeObject *type, PyObject *name) +/*[clinic end generated code: output=09d417a28f976202 input=00d28abcf1fc96bb]*/ { PyObject *module = caller(); if (module == NULL) { @@ -1156,7 +1139,7 @@ static PyObject * typevartuple_reduce_impl(typevartupleobject *self) /*[clinic end generated code: output=3215bc0477913d20 input=3018a4d66147e807]*/ { - return PyUnicode_FromString(self->name); + return Py_NewRef(self->name); } static PyObject * @@ -1239,7 +1222,7 @@ PyType_Spec typevartuple_spec = { }; PyObject * -_Py_make_typevar(const char *name, PyObject *evaluate_bound, PyObject *evaluate_constraints) +_Py_make_typevar(PyObject *name, PyObject *evaluate_bound, PyObject *evaluate_constraints) { return (PyObject *)typevar_alloc(name, NULL, evaluate_bound, NULL, evaluate_constraints, false, false, true, NULL); @@ -1249,14 +1232,14 @@ PyObject * _Py_make_paramspec(PyThreadState *Py_UNUSED(ignored), PyObject *v) { assert(PyUnicode_Check(v)); - return (PyObject *)paramspec_alloc(PyUnicode_AsUTF8(v), NULL, false, false, true, NULL); + return (PyObject *)paramspec_alloc(v, NULL, false, false, true, NULL); } PyObject * _Py_make_typevartuple(PyThreadState *Py_UNUSED(ignored), PyObject *v) { assert(PyUnicode_Check(v)); - return (PyObject *)typevartuple_alloc(PyUnicode_AsUTF8(v), NULL); + return (PyObject *)typevartuple_alloc(v, NULL); } static void @@ -1265,7 +1248,7 @@ typealias_dealloc(PyObject *self) PyTypeObject *tp = Py_TYPE(self); _PyObject_GC_UNTRACK(self); typealiasobject *ta = (typealiasobject *)self; - free((void *)ta->name); + Py_DECREF(ta->name); Py_XDECREF(ta->type_params); Py_XDECREF(ta->compute_value); Py_XDECREF(ta->value); @@ -1291,11 +1274,11 @@ static PyObject * typealias_repr(PyObject *self) { typealiasobject *ta = (typealiasobject *)self; - return PyUnicode_FromString(ta->name); + return Py_NewRef(ta->name); } static PyMemberDef typealias_members[] = { - {"__name__", T_STRING, offsetof(typealiasobject, name), READONLY}, + {"__name__", T_OBJECT, offsetof(typealiasobject, name), READONLY}, {0} }; @@ -1334,21 +1317,15 @@ static PyGetSetDef typealias_getset[] = { }; static typealiasobject * -typealias_alloc(const char *name, PyObject *type_params, PyObject *compute_value, +typealias_alloc(PyObject *name, PyObject *type_params, PyObject *compute_value, PyObject *value) { - char *owned_name = strdup(name); - if (owned_name == NULL) { - PyErr_NoMemory(); - return NULL; - } PyTypeObject *tp = PyInterpreterState_Get()->cached_objects.typealias_type; typealiasobject *ta = PyObject_GC_New(typealiasobject, tp); if (ta == NULL) { - free(owned_name); return NULL; } - ta->name = owned_name; + ta->name = Py_NewRef(name); ta->type_params = Py_IsNone(type_params) ? NULL : Py_XNewRef(type_params); ta->compute_value = Py_XNewRef(compute_value); ta->value = Py_XNewRef(value); @@ -1383,7 +1360,7 @@ static PyObject * typealias_reduce_impl(typealiasobject *self) /*[clinic end generated code: output=913724f92ad3b39b input=4f06fbd9472ec0f1]*/ { - return PyUnicode_FromString(self->name); + return Py_NewRef(self->name); } static PyObject * @@ -1407,7 +1384,7 @@ static PyMethodDef typealias_methods[] = { @classmethod typealias.__new__ as typealias_new - name: str + name: object(subclass_of="&PyUnicode_Type") value: object * type_params: object = NULL @@ -1416,9 +1393,9 @@ Create a TypeAliasType. [clinic start generated code]*/ static PyObject * -typealias_new_impl(PyTypeObject *type, const char *name, PyObject *value, +typealias_new_impl(PyTypeObject *type, PyObject *name, PyObject *value, PyObject *type_params) -/*[clinic end generated code: output=a49732e3a327545c input=fe542c90292dbd35]*/ +/*[clinic end generated code: output=8920ce6bdff86f00 input=df163c34e17e1a35]*/ { if (type_params != NULL && !PyTuple_Check(type_params)) { PyErr_SetString(PyExc_TypeError, "type_params must be a tuple"); @@ -1466,13 +1443,9 @@ _Py_make_typealias(PyThreadState* unused, PyObject *args) assert(PyTuple_GET_SIZE(args) == 3); PyObject *name = PyTuple_GET_ITEM(args, 0); assert(PyUnicode_Check(name)); - const char *name_str = PyUnicode_AsUTF8(name); - if (name_str == NULL) { - return NULL; - } PyObject *type_params = PyTuple_GET_ITEM(args, 1); PyObject *compute_value = PyTuple_GET_ITEM(args, 2); - return (PyObject *)typealias_alloc(name_str, type_params, compute_value, NULL); + return (PyObject *)typealias_alloc(name, type_params, compute_value, NULL); } PyDoc_STRVAR(generic_doc, diff --git a/Python/intrinsics.c b/Python/intrinsics.c index e2787312a67681..c6f5ac5402d644 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -205,7 +205,7 @@ static PyObject * make_typevar(PyThreadState* Py_UNUSED(ignored), PyObject *v) { assert(PyUnicode_Check(v)); - return _Py_make_typevar(PyUnicode_AsUTF8(v), NULL, NULL); + return _Py_make_typevar(v, NULL, NULL); } const instrinsic_func1 @@ -240,7 +240,7 @@ make_typevar_with_bound(PyThreadState* Py_UNUSED(ignored), PyObject *name, PyObject *evaluate_bound) { assert(PyUnicode_Check(name)); - return _Py_make_typevar(PyUnicode_AsUTF8(name), evaluate_bound, NULL); + return _Py_make_typevar(name, evaluate_bound, NULL); } static PyObject * @@ -248,8 +248,7 @@ make_typevar_with_constraints(PyThreadState* Py_UNUSED(ignored), PyObject *name, PyObject *evaluate_constraints) { assert(PyUnicode_Check(name)); - return _Py_make_typevar(PyUnicode_AsUTF8(name), NULL, - evaluate_constraints); + return _Py_make_typevar(name, NULL, evaluate_constraints); } const instrinsic_func2 From a22a08f9d85ad4d0a1beb91f204526a3032ffafe Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 13 May 2023 19:47:43 -0700 Subject: [PATCH 194/200] Reorganize compiler opcodes; no more LOAD_CLASSDEREF --- Include/internal/pycore_opcode.h | 18 +- Include/opcode.h | 25 +- Lib/opcode.py | 5 +- Python/bytecodes.c | 47 +- Python/compile.c | 13 +- Python/generated_cases.c.h | 861 ++++++++++++++----------------- Python/opcode_metadata.h | 39 +- Python/opcode_targets.h | 12 +- 8 files changed, 461 insertions(+), 559 deletions(-) diff --git a/Include/internal/pycore_opcode.h b/Include/internal/pycore_opcode.h index 77226bcebcf4c6..c2fa5692dbe49d 100644 --- a/Include/internal/pycore_opcode.h +++ b/Include/internal/pycore_opcode.h @@ -167,9 +167,6 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_ATTR_SLOT] = LOAD_ATTR, [LOAD_ATTR_WITH_HINT] = LOAD_ATTR, [LOAD_BUILD_CLASS] = LOAD_BUILD_CLASS, - [LOAD_CLASSDEREF] = LOAD_CLASSDEREF, - [LOAD_CLASSDICT_OR_DEREF] = LOAD_CLASSDICT_OR_DEREF, - [LOAD_CLASSDICT_OR_GLOBAL] = LOAD_CLASSDICT_OR_GLOBAL, [LOAD_CLOSURE] = LOAD_CLOSURE, [LOAD_CONST] = LOAD_CONST, [LOAD_CONST__LOAD_FAST] = LOAD_CONST, @@ -179,6 +176,8 @@ const uint8_t _PyOpcode_Deopt[256] = { [LOAD_FAST_CHECK] = LOAD_FAST_CHECK, [LOAD_FAST__LOAD_CONST] = LOAD_FAST, [LOAD_FAST__LOAD_FAST] = LOAD_FAST, + [LOAD_FROM_DICT_OR_DEREF] = LOAD_FROM_DICT_OR_DEREF, + [LOAD_FROM_DICT_OR_GLOBALS] = LOAD_FROM_DICT_OR_GLOBALS, [LOAD_GLOBAL] = LOAD_GLOBAL, [LOAD_GLOBAL_BUILTIN] = LOAD_GLOBAL, [LOAD_GLOBAL_MODULE] = LOAD_GLOBAL, @@ -393,35 +392,35 @@ static const char *const _PyOpcode_OpName[267] = { [LIST_APPEND] = "LIST_APPEND", [SET_ADD] = "SET_ADD", [MAP_ADD] = "MAP_ADD", - [LOAD_CLASSDEREF] = "LOAD_CLASSDEREF", + [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", [COPY_FREE_VARS] = "COPY_FREE_VARS", [YIELD_VALUE] = "YIELD_VALUE", [RESUME] = "RESUME", [MATCH_CLASS] = "MATCH_CLASS", - [STORE_ATTR_SLOT] = "STORE_ATTR_SLOT", [STORE_ATTR_WITH_HINT] = "STORE_ATTR_WITH_HINT", + [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [FORMAT_VALUE] = "FORMAT_VALUE", [BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP", [BUILD_STRING] = "BUILD_STRING", - [STORE_FAST__LOAD_FAST] = "STORE_FAST__LOAD_FAST", [STORE_FAST__STORE_FAST] = "STORE_FAST__STORE_FAST", [STORE_SUBSCR_DICT] = "STORE_SUBSCR_DICT", [STORE_SUBSCR_LIST_INT] = "STORE_SUBSCR_LIST_INT", + [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [LIST_EXTEND] = "LIST_EXTEND", [SET_UPDATE] = "SET_UPDATE", [DICT_MERGE] = "DICT_MERGE", [DICT_UPDATE] = "DICT_UPDATE", - [UNPACK_SEQUENCE_LIST] = "UNPACK_SEQUENCE_LIST", [UNPACK_SEQUENCE_TUPLE] = "UNPACK_SEQUENCE_TUPLE", [UNPACK_SEQUENCE_TWO_TUPLE] = "UNPACK_SEQUENCE_TWO_TUPLE", [SEND_GEN] = "SEND_GEN", + [169] = "<169>", [170] = "<170>", [CALL] = "CALL", [KW_NAMES] = "KW_NAMES", [CALL_INTRINSIC_1] = "CALL_INTRINSIC_1", [CALL_INTRINSIC_2] = "CALL_INTRINSIC_2", - [LOAD_CLASSDICT_OR_GLOBAL] = "LOAD_CLASSDICT_OR_GLOBAL", - [LOAD_CLASSDICT_OR_DEREF] = "LOAD_CLASSDICT_OR_DEREF", + [LOAD_FROM_DICT_OR_GLOBALS] = "LOAD_FROM_DICT_OR_GLOBALS", + [LOAD_FROM_DICT_OR_DEREF] = "LOAD_FROM_DICT_OR_DEREF", [177] = "<177>", [178] = "<178>", [179] = "<179>", @@ -516,6 +515,7 @@ static const char *const _PyOpcode_OpName[267] = { #endif #define EXTRA_CASES \ + case 169: \ case 170: \ case 177: \ case 178: \ diff --git a/Include/opcode.h b/Include/opcode.h index 52265de8e08284..dea7687c39daf8 100644 --- a/Include/opcode.h +++ b/Include/opcode.h @@ -103,7 +103,6 @@ extern "C" { #define LIST_APPEND 145 #define SET_ADD 146 #define MAP_ADD 147 -#define LOAD_CLASSDEREF 148 #define COPY_FREE_VARS 149 #define YIELD_VALUE 150 #define RESUME 151 @@ -119,8 +118,8 @@ extern "C" { #define KW_NAMES 172 #define CALL_INTRINSIC_1 173 #define CALL_INTRINSIC_2 174 -#define LOAD_CLASSDICT_OR_GLOBAL 175 -#define LOAD_CLASSDICT_OR_DEREF 176 +#define LOAD_FROM_DICT_OR_GLOBALS 175 +#define LOAD_FROM_DICT_OR_DEREF 176 #define MIN_INSTRUMENTED_OPCODE 238 #define INSTRUMENTED_POP_JUMP_IF_NONE 238 #define INSTRUMENTED_POP_JUMP_IF_NOT_NONE 239 @@ -206,16 +205,16 @@ extern "C" { #define LOAD_GLOBAL_BUILTIN 111 #define LOAD_GLOBAL_MODULE 112 #define STORE_ATTR_INSTANCE_VALUE 113 -#define STORE_ATTR_SLOT 153 -#define STORE_ATTR_WITH_HINT 154 -#define STORE_FAST__LOAD_FAST 158 -#define STORE_FAST__STORE_FAST 159 -#define STORE_SUBSCR_DICT 160 -#define STORE_SUBSCR_LIST_INT 161 -#define UNPACK_SEQUENCE_LIST 166 -#define UNPACK_SEQUENCE_TUPLE 167 -#define UNPACK_SEQUENCE_TWO_TUPLE 168 -#define SEND_GEN 169 +#define STORE_ATTR_SLOT 148 +#define STORE_ATTR_WITH_HINT 153 +#define STORE_FAST__LOAD_FAST 154 +#define STORE_FAST__STORE_FAST 158 +#define STORE_SUBSCR_DICT 159 +#define STORE_SUBSCR_LIST_INT 160 +#define UNPACK_SEQUENCE_LIST 161 +#define UNPACK_SEQUENCE_TUPLE 166 +#define UNPACK_SEQUENCE_TWO_TUPLE 167 +#define SEND_GEN 168 #define HAS_ARG(op) ((((op) >= HAVE_ARGUMENT) && (!IS_PSEUDO_OPCODE(op)))\ || ((op) == JUMP) \ diff --git a/Lib/opcode.py b/Lib/opcode.py index f8b4fd253292c8..97d0a654a03a90 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -207,7 +207,6 @@ def pseudo_op(name, op, real_ops): def_op('LIST_APPEND', 145) def_op('SET_ADD', 146) def_op('MAP_ADD', 147) -def_op('LOAD_CLASSDEREF', 148) hasfree.append(148) def_op('COPY_FREE_VARS', 149) def_op('YIELD_VALUE', 150) @@ -229,8 +228,8 @@ def pseudo_op(name, op, real_ops): def_op('CALL_INTRINSIC_1', 173) def_op('CALL_INTRINSIC_2', 174) -name_op('LOAD_CLASSDICT_OR_GLOBAL', 175) -def_op('LOAD_CLASSDICT_OR_DEREF', 176) +name_op('LOAD_FROM_DICT_OR_GLOBALS', 175) +def_op('LOAD_FROM_DICT_OR_DEREF', 176) hasfree.append(176) # Instrumented instructions diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 7c931262d621e0..1b8820f94dbc2d 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1003,15 +1003,6 @@ dummy_func( } } - inst(LOAD_LOCALS, ( -- locals)) { - locals = LOCALS(); - if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found"); - ERROR_IF(true, error); - } - Py_INCREF(locals); - } inst(STORE_NAME, (v -- )) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1169,22 +1160,20 @@ dummy_func( } } - op(_LOAD_NAME_INTRO, (-- mod_or_class_dict, name)) { - name = GETITEM(frame->f_code->co_names, oparg); - mod_or_class_dict = LOCALS(); - if (mod_or_class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no locals when loading %R", name); - goto error; + op(_LOAD_LOCALS, ( -- locals)) { + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + ERROR_IF(true, error); } - Py_INCREF(mod_or_class_dict); + Py_INCREF(locals); } - op(_LOAD_CLASSDICT_OR_GLOBAL_INTRO, (mod_or_class_dict -- mod_or_class_dict, name)) { - name = GETITEM(frame->f_code->co_names, oparg); - } + macro(LOAD_LOCALS) = _LOAD_LOCALS; - op(_LOAD_NAME_COMMON, (mod_or_class_dict, name -- v)) { + op(_LOAD_FROM_DICT_OR_GLOBALS, (mod_or_class_dict -- v)) { + PyObject *name = GETITEM(frame->f_code->co_names, oparg); if (PyDict_CheckExact(mod_or_class_dict)) { v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { @@ -1242,9 +1231,9 @@ dummy_func( } } - macro(LOAD_NAME) = _LOAD_NAME_INTRO + _LOAD_NAME_COMMON; + macro(LOAD_NAME) = _LOAD_LOCALS + _LOAD_FROM_DICT_OR_GLOBALS; - macro(LOAD_CLASSDICT_OR_GLOBAL) = _LOAD_CLASSDICT_OR_GLOBAL_INTRO + _LOAD_NAME_COMMON; + macro(LOAD_FROM_DICT_OR_GLOBALS) = _LOAD_FROM_DICT_OR_GLOBALS; family(load_global, INLINE_CACHE_ENTRIES_LOAD_GLOBAL) = { LOAD_GLOBAL, @@ -1366,14 +1355,7 @@ dummy_func( Py_DECREF(oldobj); } - op(_LOAD_CLASSDEREF_INTRO, (-- class_dict)) { - class_dict = Py_NewRef(LOCALS()); - } - - op(_LOAD_CLASSDICT_OR_DEREF_INTRO, (class_dict -- class_dict)) { - } - - op(_LOAD_CLASSDEREF_COMMON, (class_dict -- value)) { + inst(LOAD_FROM_DICT_OR_DEREF, (class_dict -- value)) { PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1410,9 +1392,6 @@ dummy_func( } } - macro(LOAD_CLASSDEREF) = _LOAD_CLASSDEREF_INTRO + _LOAD_CLASSDEREF_COMMON; - macro(LOAD_CLASSDICT_OR_DEREF) = _LOAD_CLASSDICT_OR_DEREF_INTRO + _LOAD_CLASSDEREF_COMMON; - inst(LOAD_DEREF, ( -- value)) { PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); diff --git a/Python/compile.c b/Python/compile.c index 9088cf9fc2c379..f295691706a2d9 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4137,10 +4137,14 @@ compiler_nameop(struct compiler *c, location loc, switch (ctx) { case Load: if (c->u->u_ste->ste_type == ClassBlock) { - op = LOAD_CLASSDEREF; + op = LOAD_FROM_DICT_OR_DEREF; + // First load the locals + if (codegen_addop_noarg(INSTR_SEQUENCE(c), LOAD_LOCALS, loc) < 0) { + return ERROR; + } } else if (c->u->u_ste->ste_type_params_in_class) { - op = LOAD_CLASSDICT_OR_DEREF; + op = LOAD_FROM_DICT_OR_DEREF; // First load the classdict if (compiler_addop_o(c->u, loc, LOAD_DEREF, c->u->u_metadata.u_freevars, &_Py_ID(__classdict__)) < 0) { @@ -4167,7 +4171,7 @@ compiler_nameop(struct compiler *c, location loc, switch (ctx) { case Load: if (c->u->u_ste->ste_type_params_in_class) { - op = LOAD_CLASSDICT_OR_GLOBAL; + op = LOAD_FROM_DICT_OR_GLOBALS; // First load the classdict if (compiler_addop_o(c->u, loc, LOAD_DEREF, c->u->u_metadata.u_freevars, &_Py_ID(__classdict__)) < 0) { @@ -7526,8 +7530,7 @@ fix_cell_offsets(_PyCompile_CodeUnitMetadata *umd, basicblock *entryblock, int * case LOAD_DEREF: case STORE_DEREF: case DELETE_DEREF: - case LOAD_CLASSDEREF: - case LOAD_CLASSDICT_OR_DEREF: + case LOAD_FROM_DICT_OR_DEREF: assert(oldoffset >= 0); assert(oldoffset < noffsets); assert(fixedmap[oldoffset] >= 0); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index a026ca2065d550..fa4ff5ccee78e9 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1386,51 +1386,35 @@ DISPATCH(); } - TARGET(LOAD_LOCALS) { - PyObject *locals; - #line 1007 "Python/bytecodes.c" - locals = LOCALS(); - if (locals == NULL) { - _PyErr_SetString(tstate, PyExc_SystemError, - "no locals found"); - if (true) goto error; - } - Py_INCREF(locals); - #line 1400 "Python/generated_cases.c.h" - STACK_GROW(1); - stack_pointer[-1] = locals; - DISPATCH(); - } - TARGET(STORE_NAME) { PyObject *v = stack_pointer[-1]; - #line 1017 "Python/bytecodes.c" + #line 1008 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; if (ns == NULL) { _PyErr_Format(tstate, PyExc_SystemError, "no locals found when storing %R", name); - #line 1415 "Python/generated_cases.c.h" + #line 1399 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1024 "Python/bytecodes.c" + #line 1015 "Python/bytecodes.c" if (true) goto pop_1_error; } if (PyDict_CheckExact(ns)) err = PyDict_SetItem(ns, name, v); else err = PyObject_SetItem(ns, name, v); - #line 1424 "Python/generated_cases.c.h" + #line 1408 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1031 "Python/bytecodes.c" + #line 1022 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1428 "Python/generated_cases.c.h" + #line 1412 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_NAME) { - #line 1035 "Python/bytecodes.c" + #line 1026 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); PyObject *ns = LOCALS(); int err; @@ -1447,7 +1431,7 @@ name); goto error; } - #line 1451 "Python/generated_cases.c.h" + #line 1435 "Python/generated_cases.c.h" DISPATCH(); } @@ -1455,7 +1439,7 @@ PREDICTED(UNPACK_SEQUENCE); static_assert(INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE == 1, "incorrect cache size"); PyObject *seq = stack_pointer[-1]; - #line 1061 "Python/bytecodes.c" + #line 1052 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyUnpackSequenceCache *cache = (_PyUnpackSequenceCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1468,11 +1452,11 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject **top = stack_pointer + oparg - 1; int res = unpack_iterable(tstate, seq, oparg, -1, top); - #line 1472 "Python/generated_cases.c.h" + #line 1456 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1074 "Python/bytecodes.c" + #line 1065 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1476 "Python/generated_cases.c.h" + #line 1460 "Python/generated_cases.c.h" STACK_SHRINK(1); STACK_GROW(oparg); next_instr += 1; @@ -1482,14 +1466,14 @@ TARGET(UNPACK_SEQUENCE_TWO_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1078 "Python/bytecodes.c" + #line 1069 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != 2, UNPACK_SEQUENCE); assert(oparg == 2); STAT_INC(UNPACK_SEQUENCE, hit); values[0] = Py_NewRef(PyTuple_GET_ITEM(seq, 1)); values[1] = Py_NewRef(PyTuple_GET_ITEM(seq, 0)); - #line 1493 "Python/generated_cases.c.h" + #line 1477 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1500,7 +1484,7 @@ TARGET(UNPACK_SEQUENCE_TUPLE) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1088 "Python/bytecodes.c" + #line 1079 "Python/bytecodes.c" DEOPT_IF(!PyTuple_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyTuple_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1508,7 +1492,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1512 "Python/generated_cases.c.h" + #line 1496 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1519,7 +1503,7 @@ TARGET(UNPACK_SEQUENCE_LIST) { PyObject *seq = stack_pointer[-1]; PyObject **values = stack_pointer - (1); - #line 1099 "Python/bytecodes.c" + #line 1090 "Python/bytecodes.c" DEOPT_IF(!PyList_CheckExact(seq), UNPACK_SEQUENCE); DEOPT_IF(PyList_GET_SIZE(seq) != oparg, UNPACK_SEQUENCE); STAT_INC(UNPACK_SEQUENCE, hit); @@ -1527,7 +1511,7 @@ for (int i = oparg; --i >= 0; ) { *values++ = Py_NewRef(items[i]); } - #line 1531 "Python/generated_cases.c.h" + #line 1515 "Python/generated_cases.c.h" Py_DECREF(seq); STACK_SHRINK(1); STACK_GROW(oparg); @@ -1537,15 +1521,15 @@ TARGET(UNPACK_EX) { PyObject *seq = stack_pointer[-1]; - #line 1110 "Python/bytecodes.c" + #line 1101 "Python/bytecodes.c" int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); PyObject **top = stack_pointer + totalargs - 1; int res = unpack_iterable(tstate, seq, oparg & 0xFF, oparg >> 8, top); - #line 1545 "Python/generated_cases.c.h" + #line 1529 "Python/generated_cases.c.h" Py_DECREF(seq); - #line 1114 "Python/bytecodes.c" + #line 1105 "Python/bytecodes.c" if (res == 0) goto pop_1_error; - #line 1549 "Python/generated_cases.c.h" + #line 1533 "Python/generated_cases.c.h" STACK_GROW((oparg & 0xFF) + (oparg >> 8)); DISPATCH(); } @@ -1556,7 +1540,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *v = stack_pointer[-2]; uint16_t counter = read_u16(&next_instr[0].cache); - #line 1125 "Python/bytecodes.c" + #line 1116 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION if (ADAPTIVE_COUNTER_IS_ZERO(counter)) { PyObject *name = GETITEM(frame->f_code->co_names, oparg); @@ -1572,12 +1556,12 @@ #endif /* ENABLE_SPECIALIZATION */ PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, v); - #line 1576 "Python/generated_cases.c.h" + #line 1560 "Python/generated_cases.c.h" Py_DECREF(v); Py_DECREF(owner); - #line 1141 "Python/bytecodes.c" + #line 1132 "Python/bytecodes.c" if (err) goto pop_2_error; - #line 1581 "Python/generated_cases.c.h" + #line 1565 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -1585,34 +1569,34 @@ TARGET(DELETE_ATTR) { PyObject *owner = stack_pointer[-1]; - #line 1145 "Python/bytecodes.c" + #line 1136 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyObject_SetAttr(owner, name, (PyObject *)NULL); - #line 1592 "Python/generated_cases.c.h" + #line 1576 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1148 "Python/bytecodes.c" + #line 1139 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1596 "Python/generated_cases.c.h" + #line 1580 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(STORE_GLOBAL) { PyObject *v = stack_pointer[-1]; - #line 1152 "Python/bytecodes.c" + #line 1143 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err = PyDict_SetItem(GLOBALS(), name, v); - #line 1606 "Python/generated_cases.c.h" + #line 1590 "Python/generated_cases.c.h" Py_DECREF(v); - #line 1155 "Python/bytecodes.c" + #line 1146 "Python/bytecodes.c" if (err) goto pop_1_error; - #line 1610 "Python/generated_cases.c.h" + #line 1594 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(DELETE_GLOBAL) { - #line 1159 "Python/bytecodes.c" + #line 1150 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); int err; err = PyDict_DelItem(GLOBALS(), name); @@ -1624,34 +1608,50 @@ } goto error; } - #line 1628 "Python/generated_cases.c.h" + #line 1612 "Python/generated_cases.c.h" + DISPATCH(); + } + + TARGET(LOAD_LOCALS) { + PyObject *_tmp_1; + { + PyObject *locals; + #line 1164 "Python/bytecodes.c" + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + if (true) goto error; + } + Py_INCREF(locals); + #line 1628 "Python/generated_cases.c.h" + _tmp_1 = locals; + } + STACK_GROW(1); + stack_pointer[-1] = _tmp_1; DISPATCH(); } TARGET(LOAD_NAME) { PyObject *_tmp_1; - PyObject *_tmp_2; { - PyObject *mod_or_class_dict; - PyObject *name; - #line 1173 "Python/bytecodes.c" - name = GETITEM(frame->f_code->co_names, oparg); - mod_or_class_dict = LOCALS(); - if (mod_or_class_dict == NULL) { - _PyErr_Format(tstate, PyExc_SystemError, - "no locals when loading %R", name); - goto error; + PyObject *locals; + #line 1164 "Python/bytecodes.c" + locals = LOCALS(); + if (locals == NULL) { + _PyErr_SetString(tstate, PyExc_SystemError, + "no locals found"); + if (true) goto error; } - Py_INCREF(mod_or_class_dict); - #line 1647 "Python/generated_cases.c.h" - _tmp_2 = mod_or_class_dict; - _tmp_1 = name; + Py_INCREF(locals); + #line 1648 "Python/generated_cases.c.h" + _tmp_1 = locals; } { - PyObject *name = _tmp_1; - PyObject *mod_or_class_dict = _tmp_2; + PyObject *mod_or_class_dict = _tmp_1; PyObject *v; - #line 1188 "Python/bytecodes.c" + #line 1176 "Python/bytecodes.c" + PyObject *name = GETITEM(frame->f_code->co_names, oparg); if (PyDict_CheckExact(mod_or_class_dict)) { v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { @@ -1708,30 +1708,20 @@ } } #line 1711 "Python/generated_cases.c.h" - _tmp_2 = v; + _tmp_1 = v; } STACK_GROW(1); - stack_pointer[-1] = _tmp_2; + stack_pointer[-1] = _tmp_1; DISPATCH(); } - TARGET(LOAD_CLASSDICT_OR_GLOBAL) { - PyObject *_tmp_1; - PyObject *_tmp_2 = stack_pointer[-1]; - { - PyObject *mod_or_class_dict = _tmp_2; - PyObject *name; - #line 1184 "Python/bytecodes.c" - name = GETITEM(frame->f_code->co_names, oparg); - #line 1727 "Python/generated_cases.c.h" - _tmp_2 = mod_or_class_dict; - _tmp_1 = name; - } + TARGET(LOAD_FROM_DICT_OR_GLOBALS) { + PyObject *_tmp_1 = stack_pointer[-1]; { - PyObject *name = _tmp_1; - PyObject *mod_or_class_dict = _tmp_2; + PyObject *mod_or_class_dict = _tmp_1; PyObject *v; - #line 1188 "Python/bytecodes.c" + #line 1176 "Python/bytecodes.c" + PyObject *name = GETITEM(frame->f_code->co_names, oparg); if (PyDict_CheckExact(mod_or_class_dict)) { v = PyDict_GetItemWithError(mod_or_class_dict, name); if (v != NULL) { @@ -1787,10 +1777,10 @@ } } } - #line 1791 "Python/generated_cases.c.h" - _tmp_2 = v; + #line 1781 "Python/generated_cases.c.h" + _tmp_1 = v; } - stack_pointer[-1] = _tmp_2; + stack_pointer[-1] = _tmp_1; DISPATCH(); } @@ -1799,7 +1789,7 @@ static_assert(INLINE_CACHE_ENTRIES_LOAD_GLOBAL == 4, "incorrect cache size"); PyObject *null = NULL; PyObject *v; - #line 1256 "Python/bytecodes.c" + #line 1245 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -1851,7 +1841,7 @@ } } null = NULL; - #line 1855 "Python/generated_cases.c.h" + #line 1845 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = v; @@ -1865,7 +1855,7 @@ PyObject *res; uint16_t index = read_u16(&next_instr[1].cache); uint16_t version = read_u16(&next_instr[2].cache); - #line 1310 "Python/bytecodes.c" + #line 1299 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); PyDictObject *dict = (PyDictObject *)GLOBALS(); DEOPT_IF(dict->ma_keys->dk_version != version, LOAD_GLOBAL); @@ -1876,7 +1866,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1880 "Python/generated_cases.c.h" + #line 1870 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1891,7 +1881,7 @@ uint16_t index = read_u16(&next_instr[1].cache); uint16_t mod_version = read_u16(&next_instr[2].cache); uint16_t bltn_version = read_u16(&next_instr[3].cache); - #line 1323 "Python/bytecodes.c" + #line 1312 "Python/bytecodes.c" DEOPT_IF(!PyDict_CheckExact(GLOBALS()), LOAD_GLOBAL); DEOPT_IF(!PyDict_CheckExact(BUILTINS()), LOAD_GLOBAL); PyDictObject *mdict = (PyDictObject *)GLOBALS(); @@ -1906,7 +1896,7 @@ Py_INCREF(res); STAT_INC(LOAD_GLOBAL, hit); null = NULL; - #line 1910 "Python/generated_cases.c.h" + #line 1900 "Python/generated_cases.c.h" STACK_GROW(1); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -1916,16 +1906,16 @@ } TARGET(DELETE_FAST) { - #line 1340 "Python/bytecodes.c" + #line 1329 "Python/bytecodes.c" PyObject *v = GETLOCAL(oparg); if (v == NULL) goto unbound_local_error; SETLOCAL(oparg, NULL); - #line 1924 "Python/generated_cases.c.h" + #line 1914 "Python/generated_cases.c.h" DISPATCH(); } TARGET(MAKE_CELL) { - #line 1346 "Python/bytecodes.c" + #line 1335 "Python/bytecodes.c" // "initial" is probably NULL but not if it's an arg (or set // via PyFrame_LocalsToFast() before MAKE_CELL has run). PyObject *initial = GETLOCAL(oparg); @@ -1934,12 +1924,12 @@ goto resume_with_error; } SETLOCAL(oparg, cell); - #line 1938 "Python/generated_cases.c.h" + #line 1928 "Python/generated_cases.c.h" DISPATCH(); } TARGET(DELETE_DEREF) { - #line 1357 "Python/bytecodes.c" + #line 1346 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); // Can't use ERROR_IF here. @@ -1950,119 +1940,56 @@ } PyCell_SET(cell, NULL); Py_DECREF(oldobj); - #line 1954 "Python/generated_cases.c.h" + #line 1944 "Python/generated_cases.c.h" DISPATCH(); } - TARGET(LOAD_CLASSDEREF) { - PyObject *_tmp_1; - { - PyObject *class_dict; - #line 1370 "Python/bytecodes.c" - class_dict = Py_NewRef(LOCALS()); - #line 1964 "Python/generated_cases.c.h" - _tmp_1 = class_dict; - } - { - PyObject *class_dict = _tmp_1; - PyObject *value; - #line 1377 "Python/bytecodes.c" - PyObject *name; - assert(class_dict); - assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); - name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); - if (PyDict_CheckExact(class_dict)) { - value = PyDict_GetItemWithError(class_dict, name); - if (value != NULL) { - Py_INCREF(value); - } - else if (_PyErr_Occurred(tstate)) { - Py_DECREF(class_dict); - goto error; - } - } - else { - value = PyObject_GetItem(class_dict, name); - if (value == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { - Py_DECREF(class_dict); - goto error; - } - _PyErr_Clear(tstate); - } - } - Py_DECREF(class_dict); - if (!value) { - PyObject *cell = GETLOCAL(oparg); - value = PyCell_GET(cell); - if (value == NULL) { - format_exc_unbound(tstate, frame->f_code, oparg); - goto error; - } + TARGET(LOAD_FROM_DICT_OR_DEREF) { + PyObject *class_dict = stack_pointer[-1]; + PyObject *value; + #line 1359 "Python/bytecodes.c" + PyObject *name; + assert(class_dict); + assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); + name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); + if (PyDict_CheckExact(class_dict)) { + value = PyDict_GetItemWithError(class_dict, name); + if (value != NULL) { Py_INCREF(value); } - #line 2005 "Python/generated_cases.c.h" - _tmp_1 = value; - } - STACK_GROW(1); - stack_pointer[-1] = _tmp_1; - DISPATCH(); - } - - TARGET(LOAD_CLASSDICT_OR_DEREF) { - PyObject *_tmp_1 = stack_pointer[-1]; - { - PyObject *class_dict = _tmp_1; - _tmp_1 = class_dict; + else if (_PyErr_Occurred(tstate)) { + Py_DECREF(class_dict); + goto error; + } } - { - PyObject *class_dict = _tmp_1; - PyObject *value; - #line 1377 "Python/bytecodes.c" - PyObject *name; - assert(class_dict); - assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); - name = PyTuple_GET_ITEM(frame->f_code->co_localsplusnames, oparg); - if (PyDict_CheckExact(class_dict)) { - value = PyDict_GetItemWithError(class_dict, name); - if (value != NULL) { - Py_INCREF(value); - } - else if (_PyErr_Occurred(tstate)) { + else { + value = PyObject_GetItem(class_dict, name); + if (value == NULL) { + if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { Py_DECREF(class_dict); goto error; } + _PyErr_Clear(tstate); } - else { - value = PyObject_GetItem(class_dict, name); - if (value == NULL) { - if (!_PyErr_ExceptionMatches(tstate, PyExc_KeyError)) { - Py_DECREF(class_dict); - goto error; - } - _PyErr_Clear(tstate); - } - } - Py_DECREF(class_dict); - if (!value) { - PyObject *cell = GETLOCAL(oparg); - value = PyCell_GET(cell); - if (value == NULL) { - format_exc_unbound(tstate, frame->f_code, oparg); - goto error; - } - Py_INCREF(value); + } + Py_DECREF(class_dict); + if (!value) { + PyObject *cell = GETLOCAL(oparg); + value = PyCell_GET(cell); + if (value == NULL) { + format_exc_unbound(tstate, frame->f_code, oparg); + goto error; } - #line 2057 "Python/generated_cases.c.h" - _tmp_1 = value; + Py_INCREF(value); } - stack_pointer[-1] = _tmp_1; + #line 1986 "Python/generated_cases.c.h" + stack_pointer[-1] = value; DISPATCH(); } TARGET(LOAD_DEREF) { PyObject *value; - #line 1417 "Python/bytecodes.c" + #line 1396 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -2070,7 +1997,7 @@ if (true) goto error; } Py_INCREF(value); - #line 2074 "Python/generated_cases.c.h" + #line 2001 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -2078,18 +2005,18 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1427 "Python/bytecodes.c" + #line 1406 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2087 "Python/generated_cases.c.h" + #line 2014 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1434 "Python/bytecodes.c" + #line 1413 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2100,22 +2027,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2104 "Python/generated_cases.c.h" + #line 2031 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1447 "Python/bytecodes.c" + #line 1426 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2113 "Python/generated_cases.c.h" + #line 2040 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1449 "Python/bytecodes.c" + #line 1428 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2119 "Python/generated_cases.c.h" + #line 2046 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2125,10 +2052,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1453 "Python/bytecodes.c" + #line 1432 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2132 "Python/generated_cases.c.h" + #line 2059 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2138,10 +2065,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1458 "Python/bytecodes.c" + #line 1437 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2145 "Python/generated_cases.c.h" + #line 2072 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2151,7 +2078,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1463 "Python/bytecodes.c" + #line 1442 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2162,13 +2089,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2166 "Python/generated_cases.c.h" + #line 2093 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1474 "Python/bytecodes.c" + #line 1453 "Python/bytecodes.c" if (true) goto pop_1_error; } Py_DECREF(none_val); - #line 2172 "Python/generated_cases.c.h" + #line 2099 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2177,13 +2104,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1481 "Python/bytecodes.c" + #line 1460 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2183 "Python/generated_cases.c.h" + #line 2110 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1483 "Python/bytecodes.c" + #line 1462 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2187 "Python/generated_cases.c.h" + #line 2114 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2191,7 +2118,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1487 "Python/bytecodes.c" + #line 1466 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2206,7 +2133,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2210 "Python/generated_cases.c.h" + #line 2137 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2216,7 +2143,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1504 "Python/bytecodes.c" + #line 1483 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2224,13 +2151,13 @@ if (map == NULL) goto error; - #line 2228 "Python/generated_cases.c.h" + #line 2155 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1512 "Python/bytecodes.c" + #line 1491 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2234 "Python/generated_cases.c.h" + #line 2161 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2238,7 +2165,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1516 "Python/bytecodes.c" + #line 1495 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2278,7 +2205,7 @@ Py_DECREF(ann_dict); } } - #line 2282 "Python/generated_cases.c.h" + #line 2209 "Python/generated_cases.c.h" DISPATCH(); } @@ -2286,7 +2213,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1558 "Python/bytecodes.c" + #line 1537 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2296,14 +2223,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2300 "Python/generated_cases.c.h" + #line 2227 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1568 "Python/bytecodes.c" + #line 1547 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2307 "Python/generated_cases.c.h" + #line 2234 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2311,7 +2238,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1572 "Python/bytecodes.c" + #line 1551 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2319,12 +2246,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2323 "Python/generated_cases.c.h" + #line 2250 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1580 "Python/bytecodes.c" + #line 1559 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2328 "Python/generated_cases.c.h" + #line 2255 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2332,17 +2259,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1586 "Python/bytecodes.c" + #line 1565 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2341 "Python/generated_cases.c.h" + #line 2268 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1591 "Python/bytecodes.c" + #line 1570 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2346 "Python/generated_cases.c.h" + #line 2273 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2352,13 +2279,13 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1598 "Python/bytecodes.c" + #line 1577 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2362 "Python/generated_cases.c.h" + #line 2289 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); @@ -2372,7 +2299,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1613 "Python/bytecodes.c" + #line 1592 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2390,16 +2317,16 @@ // handle any case whose performance we care about PyObject *stack[] = {class, self}; PyObject *super = PyObject_Vectorcall(global_super, stack, oparg & 2, NULL); - #line 2394 "Python/generated_cases.c.h" + #line 2321 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1631 "Python/bytecodes.c" + #line 1610 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2403 "Python/generated_cases.c.h" + #line 2330 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2414,20 +2341,20 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1638 "Python/bytecodes.c" + #line 1617 "Python/bytecodes.c" assert(!(oparg & 1)); DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); STAT_INC(LOAD_SUPER_ATTR, hit); PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL); - #line 2425 "Python/generated_cases.c.h" + #line 2352 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1645 "Python/bytecodes.c" + #line 1624 "Python/bytecodes.c" if (res == NULL) goto pop_3_error; - #line 2431 "Python/generated_cases.c.h" + #line 2358 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2442,7 +2369,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2; PyObject *res; - #line 1649 "Python/bytecodes.c" + #line 1628 "Python/bytecodes.c" assert(oparg & 1); DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); @@ -2463,7 +2390,7 @@ res = res2; res2 = NULL; } - #line 2467 "Python/generated_cases.c.h" + #line 2394 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2477,7 +2404,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1686 "Python/bytecodes.c" + #line 1665 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2511,9 +2438,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2515 "Python/generated_cases.c.h" + #line 2442 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1720 "Python/bytecodes.c" + #line 1699 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2522,12 +2449,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2526 "Python/generated_cases.c.h" + #line 2453 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1729 "Python/bytecodes.c" + #line 1708 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2531 "Python/generated_cases.c.h" + #line 2458 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2541,7 +2468,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1734 "Python/bytecodes.c" + #line 1713 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2554,7 +2481,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2558 "Python/generated_cases.c.h" + #line 2485 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2569,7 +2496,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1750 "Python/bytecodes.c" + #line 1729 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2582,7 +2509,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2586 "Python/generated_cases.c.h" + #line 2513 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2597,7 +2524,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1766 "Python/bytecodes.c" + #line 1745 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2624,7 +2551,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2628 "Python/generated_cases.c.h" + #line 2555 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2639,7 +2566,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1796 "Python/bytecodes.c" + #line 1775 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2649,7 +2576,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2653 "Python/generated_cases.c.h" + #line 2580 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2664,7 +2591,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1809 "Python/bytecodes.c" + #line 1788 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2676,7 +2603,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2680 "Python/generated_cases.c.h" + #line 2607 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2690,7 +2617,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1824 "Python/bytecodes.c" + #line 1803 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2714,7 +2641,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2718 "Python/generated_cases.c.h" + #line 2645 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2722,7 +2649,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1850 "Python/bytecodes.c" + #line 1829 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2748,7 +2675,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2752 "Python/generated_cases.c.h" + #line 2679 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2756,7 +2683,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1878 "Python/bytecodes.c" + #line 1857 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2774,7 +2701,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2778 "Python/generated_cases.c.h" + #line 2705 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2785,7 +2712,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1898 "Python/bytecodes.c" + #line 1877 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2824,7 +2751,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2828 "Python/generated_cases.c.h" + #line 2755 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2835,7 +2762,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1939 "Python/bytecodes.c" + #line 1918 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2845,7 +2772,7 @@ *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2849 "Python/generated_cases.c.h" + #line 2776 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2857,7 +2784,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1958 "Python/bytecodes.c" + #line 1937 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2870,12 +2797,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2874 "Python/generated_cases.c.h" + #line 2801 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 1971 "Python/bytecodes.c" + #line 1950 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2879 "Python/generated_cases.c.h" + #line 2806 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2886,7 +2813,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1975 "Python/bytecodes.c" + #line 1954 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2898,7 +2825,7 @@ _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2902 "Python/generated_cases.c.h" + #line 2829 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2909,7 +2836,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 1990 "Python/bytecodes.c" + #line 1969 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2925,7 +2852,7 @@ _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2929 "Python/generated_cases.c.h" + #line 2856 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2936,7 +2863,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2009 "Python/bytecodes.c" + #line 1988 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2949,7 +2876,7 @@ assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; Py_INCREF(res); - #line 2953 "Python/generated_cases.c.h" + #line 2880 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2960,14 +2887,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2024 "Python/bytecodes.c" + #line 2003 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2966 "Python/generated_cases.c.h" + #line 2893 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2026 "Python/bytecodes.c" + #line 2005 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 2971 "Python/generated_cases.c.h" + #line 2898 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2977,15 +2904,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2030 "Python/bytecodes.c" + #line 2009 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2983 "Python/generated_cases.c.h" + #line 2910 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2032 "Python/bytecodes.c" + #line 2011 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = Py_NewRef((res^oparg) ? Py_True : Py_False); - #line 2989 "Python/generated_cases.c.h" + #line 2916 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2996,12 +2923,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2037 "Python/bytecodes.c" + #line 2016 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 3002 "Python/generated_cases.c.h" + #line 2929 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2039 "Python/bytecodes.c" + #line 2018 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -3009,10 +2936,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 3013 "Python/generated_cases.c.h" + #line 2940 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2047 "Python/bytecodes.c" + #line 2026 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -3021,7 +2948,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 3025 "Python/generated_cases.c.h" + #line 2952 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -3031,21 +2958,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2058 "Python/bytecodes.c" + #line 2037 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 3038 "Python/generated_cases.c.h" + #line 2965 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2061 "Python/bytecodes.c" + #line 2040 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 3045 "Python/generated_cases.c.h" + #line 2972 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2066 "Python/bytecodes.c" + #line 2045 "Python/bytecodes.c" b = Py_NewRef(res ? Py_True : Py_False); - #line 3049 "Python/generated_cases.c.h" + #line 2976 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -3054,15 +2981,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2070 "Python/bytecodes.c" + #line 2049 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 3061 "Python/generated_cases.c.h" + #line 2988 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2073 "Python/bytecodes.c" + #line 2052 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 3066 "Python/generated_cases.c.h" + #line 2993 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -3071,29 +2998,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2077 "Python/bytecodes.c" + #line 2056 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 3079 "Python/generated_cases.c.h" + #line 3006 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2083 "Python/bytecodes.c" + #line 2062 "Python/bytecodes.c" JUMPBY(oparg); - #line 3088 "Python/generated_cases.c.h" + #line 3015 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2087 "Python/bytecodes.c" + #line 2066 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 3097 "Python/generated_cases.c.h" + #line 3024 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -3101,7 +3028,7 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2093 "Python/bytecodes.c" + #line 2072 "Python/bytecodes.c" if (Py_IsTrue(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3111,9 +3038,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3115 "Python/generated_cases.c.h" + #line 3042 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2103 "Python/bytecodes.c" + #line 2082 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3121,14 +3048,14 @@ if (err < 0) goto pop_1_error; } } - #line 3125 "Python/generated_cases.c.h" + #line 3052 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2113 "Python/bytecodes.c" + #line 2092 "Python/bytecodes.c" if (Py_IsFalse(cond)) { _Py_DECREF_NO_DEALLOC(cond); } @@ -3138,9 +3065,9 @@ } else { int err = PyObject_IsTrue(cond); - #line 3142 "Python/generated_cases.c.h" + #line 3069 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2123 "Python/bytecodes.c" + #line 2102 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3148,67 +3075,67 @@ if (err < 0) goto pop_1_error; } } - #line 3152 "Python/generated_cases.c.h" + #line 3079 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2133 "Python/bytecodes.c" + #line 2112 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3161 "Python/generated_cases.c.h" + #line 3088 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2135 "Python/bytecodes.c" + #line 2114 "Python/bytecodes.c" JUMPBY(oparg); } else { _Py_DECREF_NO_DEALLOC(value); } - #line 3169 "Python/generated_cases.c.h" + #line 3096 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2143 "Python/bytecodes.c" + #line 2122 "Python/bytecodes.c" if (Py_IsNone(value)) { _Py_DECREF_NO_DEALLOC(value); JUMPBY(oparg); } else { - #line 3182 "Python/generated_cases.c.h" + #line 3109 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2149 "Python/bytecodes.c" + #line 2128 "Python/bytecodes.c" } - #line 3186 "Python/generated_cases.c.h" + #line 3113 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2153 "Python/bytecodes.c" + #line 2132 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3199 "Python/generated_cases.c.h" + #line 3126 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2162 "Python/bytecodes.c" + #line 2141 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3212 "Python/generated_cases.c.h" + #line 3139 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3219,16 +3146,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2170 "Python/bytecodes.c" + #line 2149 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3228 "Python/generated_cases.c.h" + #line 3155 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2175 "Python/bytecodes.c" + #line 2154 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3236,7 +3163,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_NewRef(Py_None); // Failure! } - #line 3240 "Python/generated_cases.c.h" + #line 3167 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3245,10 +3172,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2185 "Python/bytecodes.c" + #line 2164 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = Py_NewRef(match ? Py_True : Py_False); - #line 3252 "Python/generated_cases.c.h" + #line 3179 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3258,10 +3185,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2191 "Python/bytecodes.c" + #line 2170 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = Py_NewRef(match ? Py_True : Py_False); - #line 3265 "Python/generated_cases.c.h" + #line 3192 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3272,11 +3199,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2197 "Python/bytecodes.c" + #line 2176 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3280 "Python/generated_cases.c.h" + #line 3207 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3285,14 +3212,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2203 "Python/bytecodes.c" + #line 2182 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3292 "Python/generated_cases.c.h" + #line 3219 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2206 "Python/bytecodes.c" + #line 2185 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3296 "Python/generated_cases.c.h" + #line 3223 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3300,7 +3227,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2210 "Python/bytecodes.c" + #line 2189 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3323,11 +3250,11 @@ if (iter == NULL) { goto error; } - #line 3327 "Python/generated_cases.c.h" + #line 3254 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2233 "Python/bytecodes.c" + #line 2212 "Python/bytecodes.c" } - #line 3331 "Python/generated_cases.c.h" + #line 3258 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3338,7 +3265,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2252 "Python/bytecodes.c" + #line 2231 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3369,7 +3296,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3373 "Python/generated_cases.c.h" + #line 3300 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3377,7 +3304,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2285 "Python/bytecodes.c" + #line 2264 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3403,14 +3330,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3407 "Python/generated_cases.c.h" + #line 3334 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2313 "Python/bytecodes.c" + #line 2292 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3430,7 +3357,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3434 "Python/generated_cases.c.h" + #line 3361 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3440,7 +3367,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2335 "Python/bytecodes.c" + #line 2314 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3460,7 +3387,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3464 "Python/generated_cases.c.h" + #line 3391 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3470,7 +3397,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2357 "Python/bytecodes.c" + #line 2336 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3488,7 +3415,7 @@ if (next == NULL) { goto error; } - #line 3492 "Python/generated_cases.c.h" + #line 3419 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3497,7 +3424,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2377 "Python/bytecodes.c" + #line 2356 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3513,14 +3440,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3517 "Python/generated_cases.c.h" + #line 3444 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2395 "Python/bytecodes.c" + #line 2374 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3543,16 +3470,16 @@ Py_DECREF(enter); goto error; } - #line 3547 "Python/generated_cases.c.h" + #line 3474 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2418 "Python/bytecodes.c" + #line 2397 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3556 "Python/generated_cases.c.h" + #line 3483 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3564,7 +3491,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2428 "Python/bytecodes.c" + #line 2407 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3590,16 +3517,16 @@ Py_DECREF(enter); goto error; } - #line 3594 "Python/generated_cases.c.h" + #line 3521 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2454 "Python/bytecodes.c" + #line 2433 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3603 "Python/generated_cases.c.h" + #line 3530 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3611,7 +3538,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2463 "Python/bytecodes.c" + #line 2442 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3632,7 +3559,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3636 "Python/generated_cases.c.h" + #line 3563 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3641,7 +3568,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2486 "Python/bytecodes.c" + #line 2465 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3651,7 +3578,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3655 "Python/generated_cases.c.h" + #line 3582 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3665,7 +3592,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2498 "Python/bytecodes.c" + #line 2477 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3682,7 +3609,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3686 "Python/generated_cases.c.h" + #line 3613 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3696,7 +3623,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2517 "Python/bytecodes.c" + #line 2496 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3706,7 +3633,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3710 "Python/generated_cases.c.h" + #line 3637 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3720,7 +3647,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2529 "Python/bytecodes.c" + #line 2508 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3734,7 +3661,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3738 "Python/generated_cases.c.h" + #line 3665 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3743,16 +3670,16 @@ } TARGET(KW_NAMES) { - #line 2545 "Python/bytecodes.c" + #line 2524 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3751 "Python/generated_cases.c.h" + #line 3678 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2551 "Python/bytecodes.c" + #line 2530 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3765,7 +3692,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3769 "Python/generated_cases.c.h" + #line 3696 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3775,7 +3702,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2596 "Python/bytecodes.c" + #line 2575 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3857,7 +3784,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3861 "Python/generated_cases.c.h" + #line 3788 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3869,7 +3796,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2684 "Python/bytecodes.c" + #line 2663 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3879,7 +3806,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3883 "Python/generated_cases.c.h" + #line 3810 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3888,7 +3815,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2696 "Python/bytecodes.c" + #line 2675 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3914,7 +3841,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3918 "Python/generated_cases.c.h" + #line 3845 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3922,7 +3849,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2724 "Python/bytecodes.c" + #line 2703 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3958,7 +3885,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3962 "Python/generated_cases.c.h" + #line 3889 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3966,7 +3893,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2762 "Python/bytecodes.c" + #line 2741 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3976,7 +3903,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3980 "Python/generated_cases.c.h" + #line 3907 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3989,7 +3916,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2774 "Python/bytecodes.c" + #line 2753 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4000,7 +3927,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4004 "Python/generated_cases.c.h" + #line 3931 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4014,7 +3941,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2788 "Python/bytecodes.c" + #line 2767 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -4025,7 +3952,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4029 "Python/generated_cases.c.h" + #line 3956 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4039,7 +3966,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2802 "Python/bytecodes.c" + #line 2781 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4061,7 +3988,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4065 "Python/generated_cases.c.h" + #line 3992 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4075,7 +4002,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2827 "Python/bytecodes.c" + #line 2806 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4103,7 +4030,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4107 "Python/generated_cases.c.h" + #line 4034 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4117,7 +4044,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2858 "Python/bytecodes.c" + #line 2837 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4149,7 +4076,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4153 "Python/generated_cases.c.h" + #line 4080 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4163,7 +4090,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2893 "Python/bytecodes.c" + #line 2872 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4195,7 +4122,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4199 "Python/generated_cases.c.h" + #line 4126 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4209,7 +4136,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2928 "Python/bytecodes.c" + #line 2907 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4234,7 +4161,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4238 "Python/generated_cases.c.h" + #line 4165 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4247,7 +4174,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2955 "Python/bytecodes.c" + #line 2934 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4274,7 +4201,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4278 "Python/generated_cases.c.h" + #line 4205 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4286,7 +4213,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2985 "Python/bytecodes.c" + #line 2964 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); assert(method != NULL); @@ -4304,14 +4231,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4308 "Python/generated_cases.c.h" + #line 4235 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3005 "Python/bytecodes.c" + #line 2984 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4342,7 +4269,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4346 "Python/generated_cases.c.h" + #line 4273 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4355,7 +4282,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3039 "Python/bytecodes.c" + #line 3018 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4384,7 +4311,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4388 "Python/generated_cases.c.h" + #line 4315 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4397,7 +4324,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3071 "Python/bytecodes.c" + #line 3050 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4426,7 +4353,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4430 "Python/generated_cases.c.h" + #line 4357 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4439,7 +4366,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3103 "Python/bytecodes.c" + #line 3082 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4467,7 +4394,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4471 "Python/generated_cases.c.h" + #line 4398 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4477,9 +4404,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3134 "Python/bytecodes.c" + #line 3113 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4483 "Python/generated_cases.c.h" + #line 4410 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4488,7 +4415,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3138 "Python/bytecodes.c" + #line 3117 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4550,14 +4477,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4554 "Python/generated_cases.c.h" + #line 4481 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3200 "Python/bytecodes.c" + #line 3179 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4561 "Python/generated_cases.c.h" + #line 4488 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4572,7 +4499,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3210 "Python/bytecodes.c" + #line 3189 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4601,14 +4528,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4605 "Python/generated_cases.c.h" + #line 4532 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3241 "Python/bytecodes.c" + #line 3220 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4629,7 +4556,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4633 "Python/generated_cases.c.h" + #line 4560 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4637,15 +4564,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3264 "Python/bytecodes.c" + #line 3243 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4643 "Python/generated_cases.c.h" + #line 4570 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3266 "Python/bytecodes.c" + #line 3245 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4649 "Python/generated_cases.c.h" + #line 4576 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4656,7 +4583,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3270 "Python/bytecodes.c" + #line 3249 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4691,7 +4618,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4695 "Python/generated_cases.c.h" + #line 4622 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4700,10 +4627,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3307 "Python/bytecodes.c" + #line 3286 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4707 "Python/generated_cases.c.h" + #line 4634 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4715,7 +4642,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3312 "Python/bytecodes.c" + #line 3291 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4730,12 +4657,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4734 "Python/generated_cases.c.h" + #line 4661 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3327 "Python/bytecodes.c" + #line 3306 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4739 "Python/generated_cases.c.h" + #line 4666 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4745,16 +4672,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3332 "Python/bytecodes.c" + #line 3311 "Python/bytecodes.c" assert(oparg >= 2); - #line 4751 "Python/generated_cases.c.h" + #line 4678 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3336 "Python/bytecodes.c" + #line 3315 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4766,26 +4693,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4770 "Python/generated_cases.c.h" + #line 4697 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3350 "Python/bytecodes.c" + #line 3329 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4776 "Python/generated_cases.c.h" + #line 4703 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3354 "Python/bytecodes.c" + #line 3333 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4783 "Python/generated_cases.c.h" + #line 4710 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3359 "Python/bytecodes.c" + #line 3338 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4794,12 +4721,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4798 "Python/generated_cases.c.h" + #line 4725 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3370 "Python/bytecodes.c" + #line 3349 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4808,12 +4735,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4812 "Python/generated_cases.c.h" + #line 4739 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3381 "Python/bytecodes.c" + #line 3360 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4826,12 +4753,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4830 "Python/generated_cases.c.h" + #line 4757 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3396 "Python/bytecodes.c" + #line 3375 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4844,30 +4771,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4848 "Python/generated_cases.c.h" + #line 4775 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3411 "Python/bytecodes.c" + #line 3390 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4859 "Python/generated_cases.c.h" + #line 4786 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3419 "Python/bytecodes.c" + #line 3398 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4866 "Python/generated_cases.c.h" + #line 4793 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3424 "Python/bytecodes.c" + #line 3403 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4873 "Python/generated_cases.c.h" + #line 4800 "Python/generated_cases.c.h" } diff --git a/Python/opcode_metadata.h b/Python/opcode_metadata.h index 18621b75e4dd53..601ad3874b7903 100644 --- a/Python/opcode_metadata.h +++ b/Python/opcode_metadata.h @@ -139,8 +139,6 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 0; case LOAD_BUILD_CLASS: return 0; - case LOAD_LOCALS: - return 0; case STORE_NAME: return 1; case DELETE_NAME: @@ -163,10 +161,12 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 1; case DELETE_GLOBAL: return 0; + case LOAD_LOCALS: + return 0; case LOAD_NAME: - return 0+2; - case LOAD_CLASSDICT_OR_GLOBAL: - return 1+2; + return 0+1; + case LOAD_FROM_DICT_OR_GLOBALS: + return 1; case LOAD_GLOBAL: return 0; case LOAD_GLOBAL_MODULE: @@ -179,10 +179,8 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) { return 0; case DELETE_DEREF: return 0; - case LOAD_CLASSDEREF: - return 0+1; - case LOAD_CLASSDICT_OR_DEREF: - return 1+1; + case LOAD_FROM_DICT_OR_DEREF: + return 1; case LOAD_DEREF: return 0; case STORE_DEREF: @@ -535,8 +533,6 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 1; case LOAD_BUILD_CLASS: return 1; - case LOAD_LOCALS: - return 1; case STORE_NAME: return 0; case DELETE_NAME: @@ -559,10 +555,12 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case DELETE_GLOBAL: return 0; + case LOAD_LOCALS: + return 1; case LOAD_NAME: - return 2+1; - case LOAD_CLASSDICT_OR_GLOBAL: - return 2+1; + return 1+1; + case LOAD_FROM_DICT_OR_GLOBALS: + return 1; case LOAD_GLOBAL: return ((oparg & 1) ? 1 : 0) + 1; case LOAD_GLOBAL_MODULE: @@ -575,10 +573,8 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) { return 0; case DELETE_DEREF: return 0; - case LOAD_CLASSDEREF: - return 1+1; - case LOAD_CLASSDICT_OR_DEREF: - return 1+1; + case LOAD_FROM_DICT_OR_DEREF: + return 1; case LOAD_DEREF: return 1; case STORE_DEREF: @@ -870,7 +866,6 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [CLEANUP_THROW] = { true, INSTR_FMT_IX }, [LOAD_ASSERTION_ERROR] = { true, INSTR_FMT_IX }, [LOAD_BUILD_CLASS] = { true, INSTR_FMT_IX }, - [LOAD_LOCALS] = { true, INSTR_FMT_IX }, [STORE_NAME] = { true, INSTR_FMT_IB }, [DELETE_NAME] = { true, INSTR_FMT_IB }, [UNPACK_SEQUENCE] = { true, INSTR_FMT_IBC }, @@ -882,16 +877,16 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[256] = { [DELETE_ATTR] = { true, INSTR_FMT_IB }, [STORE_GLOBAL] = { true, INSTR_FMT_IB }, [DELETE_GLOBAL] = { true, INSTR_FMT_IB }, + [LOAD_LOCALS] = { true, INSTR_FMT_IB }, [LOAD_NAME] = { true, INSTR_FMT_IB }, - [LOAD_CLASSDICT_OR_GLOBAL] = { true, INSTR_FMT_IB }, + [LOAD_FROM_DICT_OR_GLOBALS] = { true, INSTR_FMT_IB }, [LOAD_GLOBAL] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_MODULE] = { true, INSTR_FMT_IBC000 }, [LOAD_GLOBAL_BUILTIN] = { true, INSTR_FMT_IBC000 }, [DELETE_FAST] = { true, INSTR_FMT_IB }, [MAKE_CELL] = { true, INSTR_FMT_IB }, [DELETE_DEREF] = { true, INSTR_FMT_IB }, - [LOAD_CLASSDEREF] = { true, INSTR_FMT_IB }, - [LOAD_CLASSDICT_OR_DEREF] = { true, INSTR_FMT_IB }, + [LOAD_FROM_DICT_OR_DEREF] = { true, INSTR_FMT_IB }, [LOAD_DEREF] = { true, INSTR_FMT_IB }, [STORE_DEREF] = { true, INSTR_FMT_IB }, [COPY_FREE_VARS] = { true, INSTR_FMT_IB }, diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h index 9076be52763e20..af05a33058f3a0 100644 --- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -147,35 +147,35 @@ static void *opcode_targets[256] = { &&TARGET_LIST_APPEND, &&TARGET_SET_ADD, &&TARGET_MAP_ADD, - &&TARGET_LOAD_CLASSDEREF, + &&TARGET_STORE_ATTR_SLOT, &&TARGET_COPY_FREE_VARS, &&TARGET_YIELD_VALUE, &&TARGET_RESUME, &&TARGET_MATCH_CLASS, - &&TARGET_STORE_ATTR_SLOT, &&TARGET_STORE_ATTR_WITH_HINT, + &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP, &&TARGET_BUILD_STRING, - &&TARGET_STORE_FAST__LOAD_FAST, &&TARGET_STORE_FAST__STORE_FAST, &&TARGET_STORE_SUBSCR_DICT, &&TARGET_STORE_SUBSCR_LIST_INT, + &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_LIST_EXTEND, &&TARGET_SET_UPDATE, &&TARGET_DICT_MERGE, &&TARGET_DICT_UPDATE, - &&TARGET_UNPACK_SEQUENCE_LIST, &&TARGET_UNPACK_SEQUENCE_TUPLE, &&TARGET_UNPACK_SEQUENCE_TWO_TUPLE, &&TARGET_SEND_GEN, &&_unknown_opcode, + &&_unknown_opcode, &&TARGET_CALL, &&TARGET_KW_NAMES, &&TARGET_CALL_INTRINSIC_1, &&TARGET_CALL_INTRINSIC_2, - &&TARGET_LOAD_CLASSDICT_OR_GLOBAL, - &&TARGET_LOAD_CLASSDICT_OR_DEREF, + &&TARGET_LOAD_FROM_DICT_OR_GLOBALS, + &&TARGET_LOAD_FROM_DICT_OR_DEREF, &&_unknown_opcode, &&_unknown_opcode, &&_unknown_opcode, From 140120900986e6fa06e2f6ebbc80bfeeb130a6af Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 14 May 2023 05:32:16 -0700 Subject: [PATCH 195/200] Fix another class scoping oddity --- Lib/test/test_type_params.py | 36 ++++++++++++++++++++++++ Python/symtable.c | 53 ++++++++++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 734c769d4ee1b2..70764b112ad94f 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -494,6 +494,42 @@ def foo[U: T](self): ... self.assertIs(X.foo.__type_params__[0].__bound__, float) self.assertIs(X.Alias.__value__, float) + def test_binding_uses_global(self): + ns = run_code(""" + x = "global" + def outer(): + x = "nonlocal" + class Cls: + type Alias = x + val = Alias.__value__ + def meth[T: x](self, arg: x): ... + bound = meth.__type_params__[0].__bound__ + x = "class" + return Cls + """) + cls = ns["outer"]() + self.assertEqual(cls.val, "global") + self.assertEqual(cls.bound, "global") + # will be "class" under PEP 649 + self.assertEqual(cls.meth.__annotations__["arg"], "global") + + def test_no_binding_uses_nonlocal(self): + ns = run_code(""" + x = "global" + def outer(): + x = "nonlocal" + class Cls: + type Alias = x + val = Alias.__value__ + def meth[T: x](self, arg: x): ... + bound = meth.__type_params__[0].__bound__ + return Cls + """) + cls = ns["outer"]() + self.assertEqual(cls.val, "nonlocal") + self.assertEqual(cls.bound, "nonlocal") + self.assertEqual(cls.meth.__annotations__["arg"], "nonlocal") + class TypeParamsManglingTest(unittest.TestCase): def test_mangling(self): diff --git a/Python/symtable.c b/Python/symtable.c index 81398bf6cbe382..a2b961ba2351ad 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -498,6 +498,22 @@ error_at_directive(PySTEntryObject *ste, PyObject *name) global: set of all symbol names explicitly declared as global */ +static int +is_bound_in_symbols(PyObject *symbols, PyObject *name) +{ + if (symbols == NULL) { + return 0; + } + PyObject *v = PyDict_GetItemWithError(symbols, name); + if (v == NULL) { + assert(!PyErr_Occurred()); + return 0; + } + assert(PyLong_CheckExact(v)); + long flags = PyLong_AS_LONG(v); + return flags & DEF_BOUND; +} + #define SET_SCOPE(DICT, NAME, I) { \ PyObject *o = PyLong_FromLong(I); \ if (!o) \ @@ -519,7 +535,7 @@ error_at_directive(PySTEntryObject *ste, PyObject *name) static int analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, PyObject *bound, PyObject *local, PyObject *free, - PyObject *global, PyObject *typeparams) + PyObject *global, PyObject *typeparams, PyObject *class_symbols) { if (flags & DEF_GLOBAL) { if (flags & DEF_NONLOCAL) { @@ -580,6 +596,15 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, is nested. */ if (bound && PySet_Contains(bound, name)) { + // If we were passed class_symbols (i.e., we're in an ste_type_params_in_class scope) + // and the bound name is in that set, then the name is potentially bound both by + // the immediately enclosing class namespace, and also by an outer function namespace. + // In that case, we want the runtime name resolution to look at only the class + // namespace and the globals (not the namespace providing the bound). + if (is_bound_in_symbols(class_symbols, name)) { + SET_SCOPE(scopes, name, GLOBAL_IMPLICIT); + return 1; + } SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; @@ -842,11 +867,12 @@ update_symbols(PyObject *symbols, PyObject *scopes, static int analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, - PyObject *global, PyObject *typeparams, PyObject **child_free); + PyObject *global, PyObject *typeparams, PyObject *class_symbols, + PyObject **child_free); static int analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, - PyObject *global, PyObject *typeparams) + PyObject *global, PyObject *typeparams, PyObject *class_symbols) { PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL; PyObject *newglobal = NULL, *newfree = NULL, *promote_to_cell = NULL; @@ -908,7 +934,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { long flags = PyLong_AS_LONG(v); if (!analyze_name(ste, scopes, name, flags, - bound, local, free, global, typeparams)) + bound, local, free, global, typeparams, class_symbols)) goto error; } @@ -955,13 +981,23 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, assert(c && PySTEntry_Check(c)); entry = (PySTEntryObject*)c; + PyObject *new_class_symbols = NULL; + if (entry->ste_type_params_in_class) { + if (ste->ste_type == ClassBlock) { + new_class_symbols = ste->ste_symbols; + } + else if (class_symbols) { + new_class_symbols = class_symbols; + } + } + // we inline all non-generator-expression comprehensions int inline_comp = entry->ste_comprehension && !entry->ste_generator; if (!analyze_child_block(entry, newbound, newfree, newglobal, - typeparams, &child_free)) + typeparams, new_class_symbols, &child_free)) { goto error; } @@ -1025,7 +1061,8 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, static int analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, - PyObject *global, PyObject *typeparams, PyObject** child_free) + PyObject *global, PyObject *typeparams, PyObject *class_symbols, + PyObject** child_free) { PyObject *temp_bound = NULL, *temp_global = NULL, *temp_free = NULL; PyObject *temp_typeparams = NULL; @@ -1050,7 +1087,7 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, if (!temp_typeparams) goto error; - if (!analyze_block(entry, temp_bound, temp_free, temp_global, temp_typeparams)) + if (!analyze_block(entry, temp_bound, temp_free, temp_global, temp_typeparams, class_symbols)) goto error; *child_free = temp_free; Py_DECREF(temp_bound); @@ -1085,7 +1122,7 @@ symtable_analyze(struct symtable *st) Py_DECREF(global); return 0; } - r = analyze_block(st->st_top, NULL, free, global, typeparams); + r = analyze_block(st->st_top, NULL, free, global, typeparams, NULL); Py_DECREF(free); Py_DECREF(global); Py_DECREF(typeparams); From e049f5adc2f2dbed9cb46fbc44ab0912b6991d99 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 14 May 2023 05:35:12 -0700 Subject: [PATCH 196/200] Make test still succeed under PEP 649 --- Lib/test/test_type_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 70764b112ad94f..28779a6fb9f882 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -504,14 +504,14 @@ class Cls: val = Alias.__value__ def meth[T: x](self, arg: x): ... bound = meth.__type_params__[0].__bound__ + annotation = meth.__annotations__["arg"] x = "class" return Cls """) cls = ns["outer"]() self.assertEqual(cls.val, "global") self.assertEqual(cls.bound, "global") - # will be "class" under PEP 649 - self.assertEqual(cls.meth.__annotations__["arg"], "global") + self.assertEqual(cls.annotation, "global") def test_no_binding_uses_nonlocal(self): ns = run_code(""" From c4d9ec462622d6bfd3634823bcb4bfb64c610338 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 14 May 2023 07:16:29 -0700 Subject: [PATCH 197/200] Fix bug with explicit global in class scope; rename flag for clarity --- Include/internal/pycore_symtable.h | 4 ++-- Lib/test/test_type_params.py | 14 ++++++++++++++ Python/compile.c | 4 ++-- Python/symtable.c | 28 ++++++++++++++++------------ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index e5a3ad27e0c1f8..3fa825d0a83719 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -77,8 +77,8 @@ typedef struct _symtable_entry { over the class dict should be created */ unsigned ste_comp_inlined : 1; /* true if this comprehension is inlined */ unsigned ste_comp_iter_target : 1; /* true if visiting comprehension target */ - unsigned ste_type_params_in_class : 1; /* true if this is a type parameters block - inside a class */ + unsigned ste_can_see_class_scope : 1; /* true if this block can see names bound in an + enclosing class scope */ int ste_comp_iter_expr; /* non-zero if visiting a comprehension range expression */ int ste_lineno; /* first line of block */ int ste_col_offset; /* offset of first line of block */ diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 28779a6fb9f882..5e3202fc3a6cb9 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -530,6 +530,20 @@ def meth[T: x](self, arg: x): ... self.assertEqual(cls.bound, "nonlocal") self.assertEqual(cls.meth.__annotations__["arg"], "nonlocal") + def test_explicit_global(self): + ns = run_code(""" + x = "global" + def outer(): + x = "nonlocal" + class Cls: + global x + type Alias = x + Cls.x = "class" + return Cls + """) + cls = ns["outer"]() + self.assertEqual(cls.Alias.__value__, "global") + class TypeParamsManglingTest(unittest.TestCase): def test_mangling(self): diff --git a/Python/compile.c b/Python/compile.c index f295691706a2d9..c7cd32a4bf3fc5 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4143,7 +4143,7 @@ compiler_nameop(struct compiler *c, location loc, return ERROR; } } - else if (c->u->u_ste->ste_type_params_in_class) { + else if (c->u->u_ste->ste_can_see_class_scope) { op = LOAD_FROM_DICT_OR_DEREF; // First load the classdict if (compiler_addop_o(c->u, loc, LOAD_DEREF, @@ -4170,7 +4170,7 @@ compiler_nameop(struct compiler *c, location loc, case OP_GLOBAL: switch (ctx) { case Load: - if (c->u->u_ste->ste_type_params_in_class) { + if (c->u->u_ste->ste_can_see_class_scope && scope == GLOBAL_IMPLICIT) { op = LOAD_FROM_DICT_OR_GLOBALS; // First load the classdict if (compiler_addop_o(c->u, loc, LOAD_DEREF, diff --git a/Python/symtable.c b/Python/symtable.c index a2b961ba2351ad..4ce789f7a0fe02 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -117,7 +117,7 @@ ste_new(struct symtable *st, identifier name, _Py_block_ty block, ste->ste_needs_class_closure = 0; ste->ste_comp_inlined = 0; ste->ste_comp_iter_target = 0; - ste->ste_type_params_in_class = 0; + ste->ste_can_see_class_scope = 0; ste->ste_comp_iter_expr = 0; ste->ste_needs_classdict = 0; @@ -498,8 +498,8 @@ error_at_directive(PySTEntryObject *ste, PyObject *name) global: set of all symbol names explicitly declared as global */ -static int -is_bound_in_symbols(PyObject *symbols, PyObject *name) +static long +flags_in_symbols(PyObject *symbols, PyObject *name) { if (symbols == NULL) { return 0; @@ -510,8 +510,7 @@ is_bound_in_symbols(PyObject *symbols, PyObject *name) return 0; } assert(PyLong_CheckExact(v)); - long flags = PyLong_AS_LONG(v); - return flags & DEF_BOUND; + return PyLong_AS_LONG(v); } #define SET_SCOPE(DICT, NAME, I) { \ @@ -596,15 +595,20 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, is nested. */ if (bound && PySet_Contains(bound, name)) { - // If we were passed class_symbols (i.e., we're in an ste_type_params_in_class scope) + // If we were passed class_symbols (i.e., we're in an ste_can_see_class_scope scope) // and the bound name is in that set, then the name is potentially bound both by // the immediately enclosing class namespace, and also by an outer function namespace. // In that case, we want the runtime name resolution to look at only the class // namespace and the globals (not the namespace providing the bound). - if (is_bound_in_symbols(class_symbols, name)) { + long class_flags = flags_in_symbols(class_symbols, name); + if (class_flags & DEF_BOUND) { SET_SCOPE(scopes, name, GLOBAL_IMPLICIT); return 1; } + else if (class_flags & DEF_GLOBAL) { + SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); + return 1; + } SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; @@ -982,7 +986,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, entry = (PySTEntryObject*)c; PyObject *new_class_symbols = NULL; - if (entry->ste_type_params_in_class) { + if (entry->ste_can_see_class_scope) { if (ste->ste_type == ClassBlock) { new_class_symbols = ste->ste_symbols; } @@ -1319,7 +1323,7 @@ symtable_enter_typeparam_block(struct symtable *st, identifier name, return 0; } if (current_type == ClassBlock) { - st->st_cur->ste_type_params_in_class = 1; + st->st_cur->ste_can_see_class_scope = 1; if (!symtable_add_def(st, &_Py_ID(__classdict__), USE, lineno, col_offset, end_lineno, end_col_offset)) { return 0; } @@ -1558,7 +1562,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s) if (!symtable_enter_block(st, name, TypeAliasBlock, (void *)s, LOCATION(s))) VISIT_QUIT(st, 0); - st->st_cur->ste_type_params_in_class = is_in_class; + st->st_cur->ste_can_see_class_scope = is_in_class; if (is_in_class && !symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(s->v.TypeAlias.value))) { VISIT_QUIT(st, 0); } @@ -2098,12 +2102,12 @@ symtable_visit_typeparam(struct symtable *st, typeparam_ty tp) if (!symtable_add_def(st, tp->v.TypeVar.name, DEF_TYPE_PARAM | DEF_LOCAL, LOCATION(tp))) VISIT_QUIT(st, 0); if (tp->v.TypeVar.bound) { - int is_in_class = st->st_cur->ste_type_params_in_class; + int is_in_class = st->st_cur->ste_can_see_class_scope; if (!symtable_enter_block(st, tp->v.TypeVar.name, TypeVarBoundBlock, (void *)tp, LOCATION(tp))) VISIT_QUIT(st, 0); - st->st_cur->ste_type_params_in_class = is_in_class; + st->st_cur->ste_can_see_class_scope = is_in_class; if (is_in_class && !symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(tp->v.TypeVar.bound))) { VISIT_QUIT(st, 0); } From b93f85e4ae7eaa822fbdc3c51c35010f8bd06e48 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 14 May 2023 07:27:44 -0700 Subject: [PATCH 198/200] Fix more similar cases --- Lib/test/test_type_params.py | 42 ++++++++++++++++++++++++++++++++++++ Python/symtable.c | 30 ++++++++++++++------------ 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_type_params.py b/Lib/test/test_type_params.py index 5e3202fc3a6cb9..3ca13c21c61a12 100644 --- a/Lib/test/test_type_params.py +++ b/Lib/test/test_type_params.py @@ -544,6 +544,48 @@ class Cls: cls = ns["outer"]() self.assertEqual(cls.Alias.__value__, "global") + def test_explicit_global_with_no_static_bound(self): + ns = run_code(""" + def outer(): + class Cls: + global x + type Alias = x + Cls.x = "class" + return Cls + """) + ns["x"] = "global" + cls = ns["outer"]() + self.assertEqual(cls.Alias.__value__, "global") + + def test_explicit_global_with_assignment(self): + ns = run_code(""" + x = "global" + def outer(): + x = "nonlocal" + class Cls: + global x + type Alias = x + x = "global from class" + Cls.x = "class" + return Cls + """) + cls = ns["outer"]() + self.assertEqual(cls.Alias.__value__, "global from class") + + def test_explicit_nonlocal(self): + ns = run_code(""" + x = "global" + def outer(): + x = "nonlocal" + class Cls: + nonlocal x + type Alias = x + x = "class" + return Cls + """) + cls = ns["outer"]() + self.assertEqual(cls.Alias.__value__, "class") + class TypeParamsManglingTest(unittest.TestCase): def test_mangling(self): diff --git a/Python/symtable.c b/Python/symtable.c index 4ce789f7a0fe02..498376aeab985b 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -589,26 +589,28 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, } return 1; } + // If we were passed class_symbols (i.e., we're in an ste_can_see_class_scope scope) + // and the bound name is in that set, then the name is potentially bound both by + // the immediately enclosing class namespace, and also by an outer function namespace. + // In that case, we want the runtime name resolution to look at only the class + // namespace and the globals (not the namespace providing the bound). + // Similarly, if the name is explicitly global in the class namespace (through the + // global statement), we want to also treat it as a global in this scope. + long class_flags = flags_in_symbols(class_symbols, name); + if (class_flags & DEF_GLOBAL) { + SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); + return 1; + } + else if (class_flags & DEF_BOUND && !(class_flags & DEF_NONLOCAL)) { + SET_SCOPE(scopes, name, GLOBAL_IMPLICIT); + return 1; + } /* If an enclosing block has a binding for this name, it is a free variable rather than a global variable. Note that having a non-NULL bound implies that the block is nested. */ if (bound && PySet_Contains(bound, name)) { - // If we were passed class_symbols (i.e., we're in an ste_can_see_class_scope scope) - // and the bound name is in that set, then the name is potentially bound both by - // the immediately enclosing class namespace, and also by an outer function namespace. - // In that case, we want the runtime name resolution to look at only the class - // namespace and the globals (not the namespace providing the bound). - long class_flags = flags_in_symbols(class_symbols, name); - if (class_flags & DEF_BOUND) { - SET_SCOPE(scopes, name, GLOBAL_IMPLICIT); - return 1; - } - else if (class_flags & DEF_GLOBAL) { - SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); - return 1; - } SET_SCOPE(scopes, name, FREE); ste->ste_free = 1; return PySet_Add(free, name) >= 0; From d4e72a5669a6a11b17c5591fe1494f29e25f963d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 15 May 2023 06:58:35 -0700 Subject: [PATCH 199/200] A few more tests --- Lib/test/test_type_aliases.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Lib/test/test_type_aliases.py b/Lib/test/test_type_aliases.py index dcf167991ec5f0..d2abb932f589f7 100644 --- a/Lib/test/test_type_aliases.py +++ b/Lib/test/test_type_aliases.py @@ -178,3 +178,27 @@ def test_errors(self): TypeAliasType("TA", list, ()) with self.assertRaises(TypeError): TypeAliasType("TA", list, type_params=42) + + +class TypeAliasTypeTest(unittest.TestCase): + def test_immutable(self): + with self.assertRaises(TypeError): + TypeAliasType.whatever = "not allowed" + + def test_no_subclassing(self): + with self.assertRaisesRegex(TypeError, "not an acceptable base type"): + class MyAlias(TypeAliasType): + pass + + def test_union(self): + type Alias1 = int + type Alias2 = str + union = Alias1 | Alias2 + self.assertIsInstance(union, types.UnionType) + self.assertEqual(get_args(union), (Alias1, Alias2)) + union2 = Alias1 | list[float] + self.assertIsInstance(union2, types.UnionType) + self.assertEqual(get_args(union2), (Alias1, list[float])) + union3 = list[range] | Alias1 + self.assertIsInstance(union3, types.UnionType) + self.assertEqual(get_args(union3), (list[range], Alias1)) From 08d931c23f434d7493e1853685ef528430f162d6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 15 May 2023 07:24:40 -0700 Subject: [PATCH 200/200] Remove redundant function --- Python/symtable.c | 63 +++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/Python/symtable.c b/Python/symtable.c index 498376aeab985b..3451f6c7bffb6d 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -498,21 +498,6 @@ error_at_directive(PySTEntryObject *ste, PyObject *name) global: set of all symbol names explicitly declared as global */ -static long -flags_in_symbols(PyObject *symbols, PyObject *name) -{ - if (symbols == NULL) { - return 0; - } - PyObject *v = PyDict_GetItemWithError(symbols, name); - if (v == NULL) { - assert(!PyErr_Occurred()); - return 0; - } - assert(PyLong_CheckExact(v)); - return PyLong_AS_LONG(v); -} - #define SET_SCOPE(DICT, NAME, I) { \ PyObject *o = PyLong_FromLong(I); \ if (!o) \ @@ -534,7 +519,7 @@ flags_in_symbols(PyObject *symbols, PyObject *name) static int analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, PyObject *bound, PyObject *local, PyObject *free, - PyObject *global, PyObject *typeparams, PyObject *class_symbols) + PyObject *global, PyObject *typeparams, PySTEntryObject *class_entry) { if (flags & DEF_GLOBAL) { if (flags & DEF_NONLOCAL) { @@ -589,21 +574,23 @@ analyze_name(PySTEntryObject *ste, PyObject *scopes, PyObject *name, long flags, } return 1; } - // If we were passed class_symbols (i.e., we're in an ste_can_see_class_scope scope) + // If we were passed class_entry (i.e., we're in an ste_can_see_class_scope scope) // and the bound name is in that set, then the name is potentially bound both by // the immediately enclosing class namespace, and also by an outer function namespace. // In that case, we want the runtime name resolution to look at only the class // namespace and the globals (not the namespace providing the bound). // Similarly, if the name is explicitly global in the class namespace (through the // global statement), we want to also treat it as a global in this scope. - long class_flags = flags_in_symbols(class_symbols, name); - if (class_flags & DEF_GLOBAL) { - SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); - return 1; - } - else if (class_flags & DEF_BOUND && !(class_flags & DEF_NONLOCAL)) { - SET_SCOPE(scopes, name, GLOBAL_IMPLICIT); - return 1; + if (class_entry != NULL) { + long class_flags = _PyST_GetSymbol(class_entry, name); + if (class_flags & DEF_GLOBAL) { + SET_SCOPE(scopes, name, GLOBAL_EXPLICIT); + return 1; + } + else if (class_flags & DEF_BOUND && !(class_flags & DEF_NONLOCAL)) { + SET_SCOPE(scopes, name, GLOBAL_IMPLICIT); + return 1; + } } /* If an enclosing block has a binding for this name, it is a free variable rather than a global variable. @@ -873,12 +860,13 @@ update_symbols(PyObject *symbols, PyObject *scopes, static int analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, - PyObject *global, PyObject *typeparams, PyObject *class_symbols, - PyObject **child_free); + PyObject *global, PyObject *typeparams, + PySTEntryObject *class_entry, PyObject **child_free); static int analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, - PyObject *global, PyObject *typeparams, PyObject *class_symbols) + PyObject *global, PyObject *typeparams, + PySTEntryObject *class_entry) { PyObject *name, *v, *local = NULL, *scopes = NULL, *newbound = NULL; PyObject *newglobal = NULL, *newfree = NULL, *promote_to_cell = NULL; @@ -940,7 +928,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { long flags = PyLong_AS_LONG(v); if (!analyze_name(ste, scopes, name, flags, - bound, local, free, global, typeparams, class_symbols)) + bound, local, free, global, typeparams, class_entry)) goto error; } @@ -987,13 +975,13 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, assert(c && PySTEntry_Check(c)); entry = (PySTEntryObject*)c; - PyObject *new_class_symbols = NULL; + PySTEntryObject *new_class_entry = NULL; if (entry->ste_can_see_class_scope) { if (ste->ste_type == ClassBlock) { - new_class_symbols = ste->ste_symbols; + new_class_entry = ste; } - else if (class_symbols) { - new_class_symbols = class_symbols; + else if (class_entry) { + new_class_entry = class_entry; } } @@ -1003,7 +991,7 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, !entry->ste_generator; if (!analyze_child_block(entry, newbound, newfree, newglobal, - typeparams, new_class_symbols, &child_free)) + typeparams, new_class_entry, &child_free)) { goto error; } @@ -1067,8 +1055,8 @@ analyze_block(PySTEntryObject *ste, PyObject *bound, PyObject *free, static int analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, - PyObject *global, PyObject *typeparams, PyObject *class_symbols, - PyObject** child_free) + PyObject *global, PyObject *typeparams, + PySTEntryObject *class_entry, PyObject** child_free) { PyObject *temp_bound = NULL, *temp_global = NULL, *temp_free = NULL; PyObject *temp_typeparams = NULL; @@ -1093,7 +1081,8 @@ analyze_child_block(PySTEntryObject *entry, PyObject *bound, PyObject *free, if (!temp_typeparams) goto error; - if (!analyze_block(entry, temp_bound, temp_free, temp_global, temp_typeparams, class_symbols)) + if (!analyze_block(entry, temp_bound, temp_free, temp_global, + temp_typeparams, class_entry)) goto error; *child_free = temp_free; Py_DECREF(temp_bound);