mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-25455: Fixed crashes in repr of recursive buffered file-like objects. (#514)
This commit is contained in:
parent
77ed11552d
commit
a5af6e1af7
6 changed files with 74 additions and 9 deletions
|
@ -1415,8 +1415,18 @@ buffered_repr(buffered *self)
|
|||
res = PyUnicode_FromFormat("<%s>", Py_TYPE(self)->tp_name);
|
||||
}
|
||||
else {
|
||||
res = PyUnicode_FromFormat("<%s name=%R>",
|
||||
Py_TYPE(self)->tp_name, nameobj);
|
||||
int status = Py_ReprEnter((PyObject *)self);
|
||||
res = NULL;
|
||||
if (status == 0) {
|
||||
res = PyUnicode_FromFormat("<%s name=%R>",
|
||||
Py_TYPE(self)->tp_name, nameobj);
|
||||
Py_ReprLeave((PyObject *)self);
|
||||
}
|
||||
else if (status > 0) {
|
||||
PyErr_Format(PyExc_RuntimeError,
|
||||
"reentrant call inside %s.__repr__",
|
||||
Py_TYPE(self)->tp_name);
|
||||
}
|
||||
Py_DECREF(nameobj);
|
||||
}
|
||||
return res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue