[3.13] gh-118851: Default ctx arguments to AST constructors to Load() (GH-118854) (#118871)

(cherry picked from commit 68fbc00dc8)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-05-10 00:52:42 +02:00 committed by GitHub
parent 982c73a33e
commit 00ec116883
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(