summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-14 13:10:35 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-14 13:10:35 (GMT)
commit0d441119f5eb6437f6145e89e0963f75494d8a3f (patch)
treed8504a540716a9399777ba8f4a65ac7c1ef25ddb /Lib
parent806fb2540520839812887140fa1d4ba2e60ecc5e (diff)
downloadcpython-0d441119f5eb6437f6145e89e0963f75494d8a3f.zip
cpython-0d441119f5eb6437f6145e89e0963f75494d8a3f.tar.gz
cpython-0d441119f5eb6437f6145e89e0963f75494d8a3f.tar.bz2
Issue #25388: Fixed tokenizer crash when processing undecodable source code
with a null byte.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_compile.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 2affcc9..ee28ca9 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -504,6 +504,16 @@ if 1:
res = script_helper.run_python_until_end(fn)[0]
self.assertIn(b"Non-UTF-8", res.err)
+ def test_yet_more_evil_still_undecodable(self):
+ # Issue #25388
+ src = b"#\x00\n#\xfd\n"
+ with tempfile.TemporaryDirectory() as tmpd:
+ fn = os.path.join(tmpd, "bad.py")
+ with open(fn, "wb") as fp:
+ fp.write(src)
+ res = script_helper.run_python_until_end(fn)[0]
+ self.assertIn(b"Non-UTF-8", res.err)
+
@support.cpython_only
def test_compiler_recursion_limit(self):
# Expected limit is sys.getrecursionlimit() * the scaling factor