gh-116126: Implement PEP 696 (#116129)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
This commit is contained in:
Jelle Zijlstra 2024-05-03 06:17:32 -07:00 committed by GitHub
parent 852263e108
commit ca269e58c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 1924 additions and 623 deletions

View file

@ -657,14 +657,17 @@ struct _type_param {
struct {
identifier name;
expr_ty bound;
expr_ty default_value;
} TypeVar;
struct {
identifier name;
expr_ty default_value;
} ParamSpec;
struct {
identifier name;
expr_ty default_value;
} TypeVarTuple;
} v;
@ -892,14 +895,15 @@ 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);
type_param_ty _PyAST_TypeVar(identifier name, expr_ty bound, int lineno, int
col_offset, int end_lineno, int end_col_offset,
PyArena *arena);
type_param_ty _PyAST_ParamSpec(identifier name, int lineno, int col_offset, int
end_lineno, int end_col_offset, PyArena *arena);
type_param_ty _PyAST_TypeVarTuple(identifier name, int lineno, int col_offset,
int end_lineno, int end_col_offset, PyArena
*arena);
type_param_ty _PyAST_TypeVar(identifier name, expr_ty bound, expr_ty
default_value, int lineno, int col_offset, int
end_lineno, int end_col_offset, PyArena *arena);
type_param_ty _PyAST_ParamSpec(identifier name, expr_ty default_value, int
lineno, int col_offset, int end_lineno, int
end_col_offset, PyArena *arena);
type_param_ty _PyAST_TypeVarTuple(identifier name, expr_ty default_value, int
lineno, int col_offset, int end_lineno, int
end_col_offset, PyArena *arena);
PyObject* PyAST_mod2obj(mod_ty t);

View file

@ -184,6 +184,7 @@ struct ast_state {
PyObject *conversion;
PyObject *ctx;
PyObject *decorator_list;
PyObject *default_value;
PyObject *defaults;
PyObject *elt;
PyObject *elts;

View file

@ -28,8 +28,9 @@
#define INTRINSIC_TYPEVAR_WITH_BOUND 2
#define INTRINSIC_TYPEVAR_WITH_CONSTRAINTS 3
#define INTRINSIC_SET_FUNCTION_TYPE_PARAMS 4
#define INTRINSIC_SET_TYPEPARAM_DEFAULT 5
#define MAX_INTRINSIC_2 4
#define MAX_INTRINSIC_2 5
typedef PyObject *(*intrinsic_func1)(PyThreadState* tstate, PyObject *value);
typedef PyObject *(*intrinsic_func2)(PyThreadState* tstate, PyObject *value1, PyObject *value2);

View file

@ -13,10 +13,12 @@ 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 PyObject *_Py_set_typeparam_default(PyThreadState *, PyObject *, PyObject *);
extern int _Py_initialize_generic(PyInterpreterState *);
extern void _Py_clear_generic_types(PyInterpreterState *);
extern PyTypeObject _PyTypeAlias_Type;
extern PyObject _Py_NoDefaultStruct;
#ifdef __cplusplus
}