mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
#3242: fix a crash in "print", if sys.stdout is set to a custom object,
whose write() method installs another sys.stdout. Will backport.
This commit is contained in:
parent
dbd0ae383d
commit
bdd941fac3
3 changed files with 25 additions and 1 deletions
|
@ -1617,9 +1617,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
|||
"lost sys.stdout");
|
||||
}
|
||||
if (w != NULL) {
|
||||
Py_INCREF(w);
|
||||
err = PyFile_WriteString("\n", w);
|
||||
if (err == 0)
|
||||
PyFile_SoftSpace(w, 0);
|
||||
Py_DECREF(w);
|
||||
}
|
||||
Py_XDECREF(stream);
|
||||
stream = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue