From ceda6a67ce93dd9ac982ead61a23f98f85ea1821 Mon Sep 17 00:00:00 2001 From: Amaury Forgeot d'Arc Date: Tue, 1 Jul 2008 20:52:56 +0000 Subject: #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 --- Python/ceval.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Python') diff --git a/Python/ceval.c b/Python/ceval.c index 06d524b275..9bc147b78d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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; -- cgit v1.2.1