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 /Tools/scripts/findnocoding.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 'Tools/scripts/findnocoding.py')
-rwxr-xr-x | Tools/scripts/findnocoding.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Tools/scripts/findnocoding.py b/Tools/scripts/findnocoding.py index b3e9dc7..c0997d6 100755 --- a/Tools/scripts/findnocoding.py +++ b/Tools/scripts/findnocoding.py @@ -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: |