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:
Jelle Zijlstra 2024-05-09 15:30:14 -07:00 committed by GitHub
parent 98ff3f65c0
commit 68fbc00dc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 41 additions and 6 deletions

7
Python/Python-ast.c generated
View file

@ -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(