mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Issue #18873: The tokenize module, IDLE, 2to3, and the findnocoding.py script
now detect Python source code encoding only in comment lines.
This commit is contained in:
parent
975fce3788
commit
dafea85190
9 changed files with 44 additions and 22 deletions
|
@ -32,13 +32,13 @@ except ImportError:
|
|||
"no sophisticated Python source file search will be done.", file=sys.stderr)
|
||||
|
||||
|
||||
decl_re = re.compile(rb"coding[=:]\s*([-\w.]+)")
|
||||
decl_re = re.compile(rb'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)')
|
||||
|
||||
def get_declaration(line):
|
||||
match = decl_re.search(line)
|
||||
match = decl_re.match(line)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return ''
|
||||
return b''
|
||||
|
||||
def has_correct_encoding(text, codec):
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue