diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-09-16 20:51:56 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-09-16 20:51:56 (GMT) |
commit | dafea851901fc1de278ad79727d3b44f46ba5a31 (patch) | |
tree | 5f8d95de4856502e61c78168e7918776b161e9b4 /Lib/test/test_tokenize.py | |
parent | 975fce37883899a55bbcdaa6300c5c6ffe9d3db2 (diff) | |
download | cpython-dafea851901fc1de278ad79727d3b44f46ba5a31.zip cpython-dafea851901fc1de278ad79727d3b44f46ba5a31.tar.gz cpython-dafea851901fc1de278ad79727d3b44f46ba5a31.tar.bz2 |
Issue #18873: The tokenize module, IDLE, 2to3, and the findnocoding.py script
now detect Python source code encoding only in comment lines.
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r-- | Lib/test/test_tokenize.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index b4a58f0..1765085 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -946,6 +946,13 @@ class TestDetectEncoding(TestCase): readline = self.get_readline((b'# coding: bad\n',)) self.assertRaises(SyntaxError, detect_encoding, readline) + def test_false_encoding(self): + # Issue 18873: "Encoding" detected in non-comment lines + readline = self.get_readline((b'print("#coding=fake")',)) + encoding, consumed_lines = detect_encoding(readline) + self.assertEqual(encoding, 'utf-8') + self.assertEqual(consumed_lines, [b'print("#coding=fake")']) + def test_open(self): filename = support.TESTFN + '.py' self.addCleanup(support.unlink, filename) |