mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #26581: Use the first coding cookie on a line, not the last one.
This commit is contained in:
parent
97eee1cfda
commit
e431d3c9aa
8 changed files with 10 additions and 6 deletions
|
@ -14,7 +14,7 @@ import unittest
|
|||
import warnings
|
||||
|
||||
|
||||
CODING_RE = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)', re.ASCII)
|
||||
CODING_RE = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
|
||||
|
||||
|
||||
class EncodingTest:
|
||||
|
|
|
@ -178,7 +178,7 @@ class AbstractSourceEncodingTest:
|
|||
def test_double_coding_same_line(self):
|
||||
src = (b'#coding:iso8859-15 coding:latin1\n'
|
||||
b'print(ascii("\xc3\xa4"))\n')
|
||||
self.check_script_output(src, br"'\xc3\xa4'")
|
||||
self.check_script_output(src, br"'\xc3\u20ac'")
|
||||
|
||||
def test_first_non_utf8_coding_line(self):
|
||||
src = (b'#coding:iso-8859-15 \xa4\n'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue