mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
This commit is contained in:
parent
534fe18e17
commit
7e3ba2a699
3 changed files with 12 additions and 1 deletions
|
@ -1432,6 +1432,14 @@ class BuiltinTest(unittest.TestCase):
|
|||
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'")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue