diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-04-21 16:07:06 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-04-21 16:07:06 (GMT) |
commit | 273a720f876e754013e17fab0ab9b599284239f7 (patch) | |
tree | 3467634eaf7246dd125f8aa8ebad732e001a6915 /Lib | |
parent | 8714cfdc4aeedce96fb40c73f7226535fbe7833f (diff) | |
parent | d73aca769f1f6eebb46faa9161cbebe806db3659 (diff) | |
download | cpython-273a720f876e754013e17fab0ab9b599284239f7.zip cpython-273a720f876e754013e17fab0ab9b599284239f7.tar.gz cpython-273a720f876e754013e17fab0ab9b599284239f7.tar.bz2 |
merge 3.4 (#24022)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_compile.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 3d33bb5..41a92ff 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -1,9 +1,11 @@ import math +import os import unittest import sys import _ast +import tempfile import types -from test import support +from test import support, script_helper class TestSpecifics(unittest.TestCase): @@ -492,6 +494,16 @@ if 1: self.assertInvalidSingle('f()\nxy # blah\nblah()') self.assertInvalidSingle('x = 5 # comment\nx = 6\n') + def test_particularly_evil_undecodable(self): + # Issue 24022 + src = b'0000\x00\n00000000000\n\x00\n\x9e\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 |