summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2024-05-09 22:30:14 (GMT)
committerGitHub <noreply@github.com>2024-05-09 22:30:14 (GMT)
commit68fbc00dc870f6a8dcbecd2ec19298e21015867f (patch)
tree64510f6aeda5d45d63c36142818b9d25f03750d5 /Python/Python-ast.c
parent98ff3f65c0232f31df89ebb52b244625ec9e3eb6 (diff)
downloadcpython-68fbc00dc870f6a8dcbecd2ec19298e21015867f.zip
cpython-68fbc00dc870f6a8dcbecd2ec19298e21015867f.tar.gz
cpython-68fbc00dc870f6a8dcbecd2ec19298e21015867f.tar.bz2
gh-118851: Default ctx arguments to AST constructors to Load() (#118854)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 4956d04..7aa1c51 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -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(