diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-03-14 04:38:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-14 04:38:40 +0100 |
commit | cd8dcbc851fcc312722cdb5544c2f25cf46b3f8a (patch) | |
tree | 6a16b4054f682f075245ca5bd917995bbb18c096 /Lib/test/test_cmd_line.py | |
parent | 9923df96413a0b480a34ec1d537b66ca0eeb0fdc (diff) | |
download | cpython-cd8dcbc851fcc312722cdb5544c2f25cf46b3f8a.tar.gz cpython-cd8dcbc851fcc312722cdb5544c2f25cf46b3f8a.zip |
bpo-43410: Fix crash in the parser when producing syntax errors when reading from stdin (GH-24763)
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r-- | Lib/test/test_cmd_line.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index f12dff3202f..95ab9d8c139 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -816,9 +816,16 @@ class IgnoreEnvironmentTest(unittest.TestCase): PYTHONVERBOSE="1", ) +class SyntaxErrorTests(unittest.TestCase): + def test_tokenizer_error_with_stdin(self): + proc = subprocess.run([sys.executable, "-"], input = b"(1+2+3", + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + self.assertNotEqual(proc.returncode, 0) + self.assertNotEqual(proc.stderr, None) + self.assertIn(b"\nSyntaxError", proc.stderr) def test_main(): - support.run_unittest(CmdLineTest, IgnoreEnvironmentTest) + support.run_unittest(CmdLineTest, IgnoreEnvironmentTest, SyntaxErrorTests) support.reap_children() if __name__ == "__main__": |