summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-09-16 20:57:00 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-09-16 20:57:00 (GMT)
commit935349406aeb9d43fecea447f0309ce63ed3a406 (patch)
tree0c0cbc4c991840c4cb1e0cf835069fe571be7c03 /Tools
parent3c41154331ed281514943a1d2c61fca0d89dc63c (diff)
parentdafea851901fc1de278ad79727d3b44f46ba5a31 (diff)
downloadcpython-935349406aeb9d43fecea447f0309ce63ed3a406.zip
cpython-935349406aeb9d43fecea447f0309ce63ed3a406.tar.gz
cpython-935349406aeb9d43fecea447f0309ce63ed3a406.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')
-rwxr-xr-xTools/scripts/findnocoding.py6
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: