mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-118851: Default ctx arguments to AST constructors to Load() (#118854)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
98ff3f65c0
commit
68fbc00dc8
6 changed files with 41 additions and 6 deletions
7
Python/Python-ast.c
generated
7
Python/Python-ast.c
generated
|
@ -5221,6 +5221,13 @@ ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
|
|||
goto set_remaining_cleanup;
|
||||
}
|
||||
}
|
||||
else if (type == state->expr_context_type) {
|
||||
// special case for expr_context: default to Load()
|
||||
res = PyObject_SetAttr(self, name, state->Load_singleton);
|
||||
if (res < 0) {
|
||||
goto set_remaining_cleanup;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// simple field (e.g., identifier)
|
||||
if (PyErr_WarnFormat(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue