[Python-checkins] r51129 - in python/trunk: Lib/test/test_builtin.py Misc/NEWS Python/bltinmodule.c
georg.brandl
python-checkins at python.org
Sun Aug 6 10:23:55 CEST 2006
Author: georg.brandl
Date: Sun Aug 6 10:23:54 2006
New Revision: 51129
Modified:
python/trunk/Lib/test/test_builtin.py
python/trunk/Misc/NEWS
python/trunk/Python/bltinmodule.c
Log:
Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
Modified: python/trunk/Lib/test/test_builtin.py
==============================================================================
--- python/trunk/Lib/test/test_builtin.py (original)
+++ python/trunk/Lib/test/test_builtin.py Sun Aug 6 10:23:54 2006
@@ -1432,6 +1432,14 @@
self.assertEqual(input('testing\n'), 2)
self.assertEqual(raw_input(), 'The quick brown fox jumps over the lazy dog.')
self.assertEqual(raw_input('testing\n'), 'Dear John')
+
+ # SF 1535165: don't segfault on closed stdin
+ # sys.stdout must be a regular file for triggering
+ sys.stdout = savestdout
+ sys.stdin.close()
+ self.assertRaises(ValueError, input, 'prompt')
+
+ sys.stdout = BitBucket()
sys.stdin = cStringIO.StringIO("NULL\0")
self.assertRaises(TypeError, input, 42, 42)
sys.stdin = cStringIO.StringIO(" 'whitespace'")
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sun Aug 6 10:23:54 2006
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- Bug #1535165: fixed a segfault in input() and raw_input() when
+ sys.stdin is closed.
+
- On Windows, the PyErr_Warn function is now exported from
the Python dll again.
Modified: python/trunk/Python/bltinmodule.c
==============================================================================
--- python/trunk/Python/bltinmodule.c (original)
+++ python/trunk/Python/bltinmodule.c Sun Aug 6 10:23:54 2006
@@ -1725,7 +1725,7 @@
if (PyFile_WriteString(" ", fout) != 0)
return NULL;
}
- if (PyFile_Check(fin) && PyFile_Check(fout)
+ if (PyFile_AsFile(fin) && PyFile_AsFile(fout)
&& isatty(fileno(PyFile_AsFile(fin)))
&& isatty(fileno(PyFile_AsFile(fout)))) {
PyObject *po;
More information about the Python-checkins
mailing list