https://github.com/python/cpython/commit/1bfcc3cc871d3fab21b77cdc47cdbfcf89fd8b5b
commit: 1bfcc3cc871d3fab21b77cdc47cdbfcf89fd8b5b
branch: main
author: Bartosz Sławecki <[email protected]>
committer: encukou <[email protected]>
date: 2026-09-15T08:26:26+02:00
summary:
gh-156909: Fix `AST.__repr__` call getting the `_fields` attribute (GH-157490)
files:
M Parser/asdl_c.py
M Python/Python-ast.c
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 08a43327766079..2cd34e4eb70f9b 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -1480,8 +1480,8 @@ def visitModule(self, mod):
return NULL;
}
- PyObject *fields;
- if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields,
&fields) < 0) {
+ PyObject *fields = PyObject_GetAttr((PyObject *)Py_TYPE(self),
state->_fields);
+ if (!fields) {
return NULL;
}
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 87f160ed19301e..83d058e8357196 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -5792,8 +5792,8 @@ ast_repr_max_depth(AST_object *self, int depth)
return NULL;
}
- PyObject *fields;
- if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields,
&fields) < 0) {
+ PyObject *fields = PyObject_GetAttr((PyObject *)Py_TYPE(self),
state->_fields);
+ if (!fields) {
return NULL;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]