mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[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:
parent
982c73a33e
commit
00ec116883
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