mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917)
Co-authored-by: Guido van Rossum <guido@python.org> Co-authored-by: Talin <viridia@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
parent
cc02b4f2e8
commit
145bf269df
43 changed files with 10867 additions and 2607 deletions
|
@ -872,9 +872,10 @@ make_type(struct ast_state *state, const char *type, PyObject* base,
|
|||
}
|
||||
PyTuple_SET_ITEM(fnames, i, field);
|
||||
}
|
||||
result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOs}",
|
||||
result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
|
||||
type, base,
|
||||
state->_fields, fnames,
|
||||
state->__match_args__, fnames,
|
||||
state->__module__,
|
||||
state->ast,
|
||||
state->__doc__, doc);
|
||||
|
@ -1005,6 +1006,7 @@ static int add_ast_fields(struct ast_state *state)
|
|||
empty_tuple = PyTuple_New(0);
|
||||
if (!empty_tuple ||
|
||||
PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
|
||||
PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
|
||||
PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
|
||||
Py_XDECREF(empty_tuple);
|
||||
return -1;
|
||||
|
@ -1405,6 +1407,7 @@ def generate_module_def(mod, f, internal_h):
|
|||
state_strings = {
|
||||
"ast",
|
||||
"_fields",
|
||||
"__match_args__",
|
||||
"__doc__",
|
||||
"__dict__",
|
||||
"__module__",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue