#3242: fix a crash in "print", if sys.stdout is set to a custom object,

whose write() method installs another sys.stdout.

Backport of r64633
This commit is contained in:
Amaury Forgeot d'Arc 2008-07-01 20:52:56 +00:00
parent 6fa30f40b5
commit ceda6a67ce
3 changed files with 26 additions and 1 deletions

View file

@ -1603,9 +1603,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;