mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix input() builtin function to respect compiler flags.
(SF patch 876178, patch by mwh, unittest by perky)
This commit is contained in:
parent
96c44658b9
commit
ff83c2bacc
3 changed files with 20 additions and 1 deletions
|
@ -931,6 +931,19 @@ class BuiltinTest(unittest.TestCase):
|
|||
self.assertEqual(input(), 'whitespace')
|
||||
sys.stdin = cStringIO.StringIO()
|
||||
self.assertRaises(EOFError, input)
|
||||
|
||||
# SF 876178: make sure input() respect future options.
|
||||
sys.stdin = cStringIO.StringIO('1/2')
|
||||
sys.stdout = cStringIO.StringIO()
|
||||
exec compile('print input()', 'test_builtin_tmp', 'exec')
|
||||
sys.stdin.seek(0, 0)
|
||||
exec compile('from __future__ import division;print input()',
|
||||
'test_builtin_tmp', 'exec')
|
||||
sys.stdin.seek(0, 0)
|
||||
exec compile('print input()', 'test_builtin_tmp', 'exec')
|
||||
self.assertEqual(sys.stdout.getvalue().splitlines(),
|
||||
['0', '0.5', '0'])
|
||||
|
||||
del sys.stdout
|
||||
self.assertRaises(RuntimeError, input, 'prompt')
|
||||
del sys.stdin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue