summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-07-01 20:52:56 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-07-01 20:52:56 +0000
commitceda6a67ce93dd9ac982ead61a23f98f85ea1821 (patch)
treeafbcf17649cc2972bf0267f8b32391a2eb48969f /Python
parent6fa30f40b50e9f98579d16ee8358b75b898f13de (diff)
downloadcpython-git-ceda6a67ce93dd9ac982ead61a23f98f85ea1821.tar.gz
#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
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c2
1 files changed, 2 insertions, 0 deletions
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;