summaryrefslogtreecommitdiff
path: root/Lib/test/test_tokenize.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2012-04-20 14:37:17 +0200
committerMartin v. Löwis <martin@v.loewis.de>2012-04-20 14:37:17 +0200
commit63c39fe38e54c986a70dd9f97acf444837d1d244 (patch)
tree038aad8667c580ef236848618548010de9e14b4d /Lib/test/test_tokenize.py
parent7b17a4e117fa6ad9f0063aa2f039930f40d91820 (diff)
parent63674f4b52aa7c2832fec09a026e24cd521e491b (diff)
downloadcpython-git-63c39fe38e54c986a70dd9f97acf444837d1d244.tar.gz
merge 3.2: issue 14629
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r--Lib/test/test_tokenize.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index db87e11da4..11590ead86 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -838,6 +838,16 @@ class TestDetectEncoding(TestCase):
found, consumed_lines = detect_encoding(rl)
self.assertEqual(found, "iso-8859-1")
+ def test_syntaxerror_latin1(self):
+ # Issue 14629: need to raise SyntaxError if the first
+ # line(s) have non-UTF-8 characters
+ lines = (
+ b'print("\xdf")', # Latin-1: LATIN SMALL LETTER SHARP S
+ )
+ readline = self.get_readline(lines)
+ self.assertRaises(SyntaxError, detect_encoding, readline)
+
+
def test_utf8_normalization(self):
# See get_normal_name() in tokenizer.c.
encodings = ("utf-8", "utf-8-mac", "utf-8-unix")