diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-04-04 23:25:27 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-04-04 23:25:27 (GMT) |
commit | 9ed77358d618e4c65fbe5df67a87618be29fc391 (patch) | |
tree | 20eff232a288142e83f20de808626c9c3c8fbeec /Lib | |
parent | bff533b4798de3909b53dc2d14d9b074587c17ac (diff) | |
download | cpython-9ed77358d618e4c65fbe5df67a87618be29fc391.zip cpython-9ed77358d618e4c65fbe5df67a87618be29fc391.tar.gz cpython-9ed77358d618e4c65fbe5df67a87618be29fc391.tar.bz2 |
Issue2221: in Idle, exec('xx') raised a SystemError('error return without exception set')
instead of the expected NameError
This happens when sys.stdout is redirected to something that cannot flush().
the flush_io() function must be exception-neutral: don't raise, and don't clear exceptions.
Next step: exec() is not supposed to flush sys.stdout...
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 111090c..7244aff 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -448,6 +448,17 @@ class BuiltinTest(unittest.TestCase): del l['__builtins__'] self.assertEqual((g, l), ({'a': 1}, {'b': 2})) + def test_exec_redirected(self): + savestdout = sys.stdout + sys.stdout = None # Whatever that cannot flush() + try: + # Used to raise SystemError('error return without exception set') + exec('a') + except NameError: + pass + finally: + sys.stdout = savestdout + def test_filter(self): self.assertEqual(list(filter(lambda c: 'a' <= c <= 'z', 'Hello World')), list('elloorld')) self.assertEqual(list(filter(None, [1, 'hello', [], [3], '', None, 9, 0])), [1, 'hello', [3], 9]) |