summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-09-16 21:00:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-09-16 21:00:46 (GMT)
commite787bce79c016cf7b9e743a6230ceb8e97b4a938 (patch)
tree2b86121e69e169391770e3adace1e55c28805fc8 /Tools
parent74213e4ee941e163ebdfa6b7d3d493ee68f6bb8d (diff)
downloadcpython-e787bce79c016cf7b9e743a6230ceb8e97b4a938.zip
cpython-e787bce79c016cf7b9e743a6230ceb8e97b4a938.tar.gz
cpython-e787bce79c016cf7b9e743a6230ceb8e97b4a938.tar.bz2
Issue #18873: 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 e49fc42..838e573 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.")
-decl_re = re.compile(r"coding[=:]\s*([-\w.]+)")
+decl_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)', re.ASCII)
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: