summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2007-01-23 13:54:30 (GMT)
committerThomas Wouters <thomas@python.org>2007-01-23 13:54:30 (GMT)
commite471317a084512d558fd3bfd84592a6a7126cdee (patch)
tree976e72558989488d7101ff57976a27335e4c79f7 /Objects/fileobject.c
parent1e4bb440488e7b982c62fe117cd5409402818d02 (diff)
downloadcpython-e471317a084512d558fd3bfd84592a6a7126cdee.zip
cpython-e471317a084512d558fd3bfd84592a6a7126cdee.tar.gz
cpython-e471317a084512d558fd3bfd84592a6a7126cdee.tar.bz2
Backport trunk revision 53527:
SF patch #1630975: Fix crash when replacing sys.stdout in sitecustomize When running the interpreter in an environment that would cause it to set stdout/stderr/stdin's encoding, having a sitecustomize that would replace them with something other than PyFile objects would crash the interpreter. Fix it by simply ignoring the encoding-setting for non-files. This could do with a test, but I can think of no maintainable and portable way to test this bug, short of adding a sitecustomize.py to the buildsystem and have it always run with it (hmmm....)
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index ced0768..869ded9 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -354,6 +354,8 @@ PyFile_SetEncoding(PyObject *f, const char *enc)
{
PyFileObject *file = (PyFileObject*)f;
PyObject *str = PyString_FromString(enc);
+
+ assert(PyFile_Check(f));
if (!str)
return 0;
Py_DECREF(file->f_encoding);