diff Tools/scripts/findnocoding.py @ 85733:3d46ef0c62c5 2.7

Issue #18873: IDLE, 2to3, and the findnocoding.py script now detect Python source code encoding only in comment lines.
author Serhiy Storchaka <storchaka@gmail.com>
date Tue, 17 Sep 2013 00:00:46 +0300
parents 82ccc7e77ec5
children f16855d6d4e1
line wrap: on
line diff
--- a/Tools/scripts/findnocoding.py	Mon Sep 16 14:32:54 2013 -0400
+++ b/Tools/scripts/findnocoding.py	Tue Sep 17 00:00:46 2013 +0300
@@ -32,13 +32,13 @@
                          "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: