summaryrefslogtreecommitdiffstats
path: root/Lib/test/data
stat options
Period:
Authors:

Commits per author per week (path 'Lib/test/data')

AuthorW12 2026W13 2026W14 2026W15 2026Total
Total00000
r>
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2023-05-16 03:36:23 (GMT)
committerGitHub <noreply@github.com>2023-05-16 03:36:23 (GMT)
commit24d8b88420b81fc60aeb0cbcacef1e72d633824a (patch)
tree1b06e157ddc7d1066fd41a28d2c27270ccf2e278
parentfdafdc235e74f2f4fedc1f745bf8b90141daa162 (diff)
downloadcpython-24d8b88420b81fc60aeb0cbcacef1e72d633824a.zip
cpython-24d8b88420b81fc60aeb0cbcacef1e72d633824a.tar.gz
cpython-24d8b88420b81fc60aeb0cbcacef1e72d633824a.tar.bz2
gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for: - Generic functions (def func[T](): ...) - Generic classes (class X[T](): ...) - Type aliases (type X = ...) - New scoping when the new syntax is used within a class body - Compiler and interpreter changes to support the new syntax and scoping rules Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Eric Traut <eric@traut.com> Co-authored-by: Larry Hastings <larry@hastings.org> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat
-rw-r--r--Doc/library/ast.rst3
-rw-r--r--Grammar/python.gram46
-rw-r--r--Include/cpython/funcobject.h1
-rw-r--r--Include/internal/pycore_ast.h97
-rw-r--r--Include/internal/pycore_ast_state.h7
-rw-r--r--Include/internal/pycore_function.h2
-rw-r--r--Include/internal/pycore_global_objects.h8
-rw-r--r--Include/internal/pycore_global_objects_fini_generated.h16
-rw-r--r--Include/internal/pycore_global_strings.h16
-rw-r--r--Include/internal/pycore_intrinsics.h12
-rw-r--r--Include/internal/pycore_opcode.h16
-rw-r--r--Include/internal/pycore_runtime_init_generated.h16
-rw-r--r--Include/internal/pycore_symtable.h21
-rw-r--r--Include/internal/pycore_typevarobject.h22
-rw-r--r--Include/internal/pycore_unicodeobject_generated.h36
-rw-r--r--Include/opcode.h14
-rw-r--r--Lib/ast.py26
-rw-r--r--Lib/importlib/_bootstrap_external.py3
-rw-r--r--Lib/keyword.py3
-rw-r--r--Lib/opcode.py20
-rw-r--r--Lib/test/support/__init__.py9
-rw-r--r--Lib/test/test_ast.py125
-rw-r--r--Lib/test/test_keyword.py3
-rw-r--r--Lib/test/test_sys.py2
-rw-r--r--Lib/test/test_type_aliases.py204
-rw-r--r--Lib/test/test_type_params.py847
-rw-r--r--Lib/test/test_typing.py54
-rw-r--r--Lib/typing.py591
-rw-r--r--Makefile.pre.in2
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-04-25-08-43-11.gh-issue-103763.ZLBZk1.rst23
-rw-r--r--Modules/Setup.bootstrap.in1
-rw-r--r--Modules/Setup.stdlib.in1
-rw-r--r--Modules/_typingmodule.c28
-rw-r--r--Objects/clinic/typevarobject.c.h786
-rw-r--r--Objects/funcobject.c27
-rw-r--r--Objects/object.c6
-rw-r--r--Objects/typeobject.c47
-rw-r--r--Objects/typevarobject.c1620
-rw-r--r--Objects/unionobject.c8
-rw-r--r--PCbuild/_freeze_module.vcxproj1
-rw-r--r--PCbuild/pythoncore.vcxproj2
-rw-r--r--PCbuild/pythoncore.vcxproj.filters6
-rw-r--r--Parser/Python.asdl11
-rw-r--r--Parser/action_helpers.c11
-rw-r--r--Parser/parser.c4515
-rw-r--r--Python/Python-ast.c767
-rw-r--r--Python/ast.c45
-rw-r--r--Python/ast_opt.c24
-rw-r--r--Python/bytecodes.c53
-rw-r--r--Python/compile.c623
-rw-r--r--Python/generated_cases.c.h984
-rw-r--r--Python/intrinsics.c34
-rw-r--r--Python/opcode_metadata.h20
-rw-r--r--Python/opcode_targets.h10
-rw-r--r--Python/pylifecycle.c2
-rw-r--r--Python/symtable.c355
56 files changed, 9084 insertions, 3148 deletions
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 0811b3f..eb6a973 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=[],
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 6361dcd..c79207b 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" 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,39 @@ 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(CHECK(expr_ty, _PyPegen_set_expr_context(p, n, Store)), t, b, EXTRA)) }
+
+# Type parameter declaration
+# --------------------------
+
+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 }
+
+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 }
+
# EXPRESSIONS
# -----------
diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h
index c716330..6f78f58 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_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_ast.h b/Include/internal/pycore_ast.h
index 36277ef..9f1cef0 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;
@@ -226,6 +239,12 @@ struct _stmt {
} Assign;
struct {
+ expr_ty name;
+ asdl_typeparam_seq *typeparams;
+ expr_ty value;
+ } TypeAlias;
+
+ struct {
expr_ty target;
operator_ty op;
expr_ty value;
@@ -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(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);
@@ -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 f15b490..e723ead5 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_function.h b/Include/internal/pycore_function.h
index 1198814..ecbb700 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_global_objects.h b/Include/internal/pycore_global_objects.h
index 64d9384..40cc04d 100644
--- a/Include/internal/pycore_global_objects.h
+++ b/Include/internal/pycore_global_objects.h
@@ -68,6 +68,14 @@ struct _Py_interp_cached_objects {
PyObject *type_slots_pname;
pytype_slotdef *type_slots_ptrs[MAX_EQUIV];
+ /* TypeVar and related types */
+ 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/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h
index 7e49581..24a268a 100644
--- a/Include/internal/pycore_global_objects_fini_generated.h
+++ b/Include/internal/pycore_global_objects_fini_generated.h
@@ -555,15 +555,19 @@ _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(generic_base));
_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(newline));
_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));
@@ -602,6 +606,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__));
@@ -724,6 +730,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_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__));
@@ -779,8 +786,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));
@@ -795,6 +805,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));
@@ -850,11 +861,13 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(compile_mode));
_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));
@@ -964,6 +977,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));
@@ -1080,6 +1094,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));
@@ -1213,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 8ebfee8..c1005d0 100644
--- a/Include/internal/pycore_global_strings.h
+++ b/Include/internal/pycore_global_strings.h
@@ -40,15 +40,19 @@ 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, ".<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")
STRUCT_FOR_STR(newline, "\n")
STRUCT_FOR_STR(open_br, "{")
STRUCT_FOR_STR(percent, "%")
STRUCT_FOR_STR(shim_name, "<shim>")
+ STRUCT_FOR_STR(type_params, ".type_params")
STRUCT_FOR_STR(utf_8, "utf-8")
} literals;
@@ -90,6 +94,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__)
@@ -212,6 +218,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(__subclasshook__)
STRUCT_FOR_ID(__truediv__)
STRUCT_FOR_ID(__trunc__)
+ STRUCT_FOR_ID(__type_params__)
STRUCT_FOR_ID(__typing_is_unpacked_typevartuple__)
STRUCT_FOR_ID(__typing_prepare_subst__)
STRUCT_FOR_ID(__typing_subst__)
@@ -267,8 +274,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)
@@ -283,6 +293,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)
@@ -338,11 +349,13 @@ struct _Py_global_strings {
STRUCT_FOR_ID(compile_mode)
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)
@@ -452,6 +465,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)
@@ -568,6 +582,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)
@@ -701,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_intrinsics.h b/Include/internal/pycore_intrinsics.h
index 3902059..39f1568 100644
--- a/Include/internal/pycore_intrinsics.h
+++ b/Include/internal/pycore_intrinsics.h
@@ -8,15 +8,23 @@
#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 INTRINSIC_SUBSCRIPT_GENERIC 10
+#define INTRINSIC_TYPEALIAS 11
-#define MAX_INTRINSIC_1 6
+#define MAX_INTRINSIC_1 11
/* Binary Functions: */
#define INTRINSIC_2_INVALID 0
#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 1
+#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_opcode.h b/Include/internal/pycore_opcode.h
index e823e1b..c2fa569 100644
--- a/Include/internal/pycore_opcode.h
+++ b/Include/internal/pycore_opcode.h