Skip to content

Commit ad0a18a

Browse files
authored
[3.15] gh-156909: Fix AST.__repr__ call getting the _fields attribute (GH-157490) (GH-157596)
(cherry picked from commit 1bfcc3c)
1 parent 2befd17 commit ad0a18a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎Parser/asdl_c.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,8 @@ def visitModule(self, mod):
14801480
return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
14811481
}
14821482
1483-
PyObject *fields;
1484-
if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
1483+
PyObject *fields = PyObject_GetAttr((PyObject *)Py_TYPE(self), state->_fields);
1484+
if (!fields) {
14851485
Py_ReprLeave((PyObject *)self);
14861486
return NULL;
14871487
}

‎Python/Python-ast.c‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)