Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8)

Side by Side Diff: Lib/test/test_importlib/source/test_source_encoding.py

Issue 26581: Double coding cookie
Patch Set: Created 4 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/lib2to3/pgen2/tokenize.py ('k') | Lib/test/test_source_encoding.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from .. import util 1 from .. import util
2 2
3 machinery = util.import_importlib('importlib.machinery') 3 machinery = util.import_importlib('importlib.machinery')
4 4
5 import codecs 5 import codecs
6 import importlib.util 6 import importlib.util
7 import re 7 import re
8 import sys 8 import sys
9 import types 9 import types
10 # Because sys.path gets essentially blanked, need to have unicodedata already 10 # Because sys.path gets essentially blanked, need to have unicodedata already
11 # imported for the parser to use. 11 # imported for the parser to use.
12 import unicodedata 12 import unicodedata
13 import unittest 13 import unittest
14 import warnings 14 import warnings
15 15
16 16
17 CODING_RE = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)', re.ASCII) 17 CODING_RE = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
18 18
19 19
20 class EncodingTest: 20 class EncodingTest:
21 21
22 """PEP 3120 makes UTF-8 the default encoding for source code 22 """PEP 3120 makes UTF-8 the default encoding for source code
23 [default encoding]. 23 [default encoding].
24 24
25 PEP 263 specifies how that can change on a per-file basis. Either the first 25 PEP 263 specifies how that can change on a per-file basis. Either the first
26 or second line can contain the encoding line [encoding first line] 26 or second line can contain the encoding line [encoding first line]
27 encoding second line]. If the file has the BOM marker it is considered UTF-8 27 encoding second line]. If the file has the BOM marker it is considered UTF-8
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return loader.load_module(module_name) 167 return loader.load_module(module_name)
168 168
169 169
170 (Frozen_LineEndingTestPEP302, 170 (Frozen_LineEndingTestPEP302,
171 Source_LineEndingTestPEP302 171 Source_LineEndingTestPEP302
172 ) = util.test_both(LineEndingTestPEP302, machinery=machinery) 172 ) = util.test_both(LineEndingTestPEP302, machinery=machinery)
173 173
174 174
175 if __name__ == '__main__': 175 if __name__ == '__main__':
176 unittest.main() 176 unittest.main()
OLDNEW
« no previous file with comments | « Lib/lib2to3/pgen2/tokenize.py ('k') | Lib/test/test_source_encoding.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+