Skip to content

Commit e5c9a96

Browse files
committed
Move Py_ReprEnter past the depth check
1 parent d539589 commit e5c9a96

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

Parser/asdl_c.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,39 +1480,35 @@ def visitModule(self, mod):
14801480
return NULL;
14811481
}
14821482
1483-
int status = Py_ReprEnter((PyObject *)self);
1484-
if (status != 0) {
1485-
if (status < 0) {
1486-
return NULL;
1487-
}
1488-
return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
1489-
}
1490-
14911483
PyObject *fields;
14921484
if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
1493-
Py_ReprLeave((PyObject *)self);
14941485
return NULL;
14951486
}
14961487
14971488
Py_ssize_t numfields = PySequence_Size(fields);
14981489
if (numfields < 0) {
1499-
Py_ReprLeave((PyObject *)self);
15001490
Py_DECREF(fields);
15011491
return NULL;
15021492
}
15031493
15041494
if (numfields == 0) {
1505-
Py_ReprLeave((PyObject *)self);
15061495
Py_DECREF(fields);
15071496
return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
15081497
}
15091498
15101499
if (depth <= 0) {
1511-
Py_ReprLeave((PyObject *)self);
15121500
Py_DECREF(fields);
15131501
return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
15141502
}
15151503
1504+
int status = Py_ReprEnter((PyObject *)self);
1505+
if (status != 0) {
1506+
if (status < 0) {
1507+
return NULL;
1508+
}
1509+
return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
1510+
}
1511+
15161512
const char* tp_name = Py_TYPE(self)->tp_name;
15171513
PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
15181514
if (writer == NULL) {

Python/Python-ast.c

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

0 commit comments

Comments
 (0)