From dafea851901fc1de278ad79727d3b44f46ba5a31 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 16 Sep 2013 23:51:56 +0300 Subject: Issue #18873: The tokenize module, IDLE, 2to3, and the findnocoding.py script now detect Python source code encoding only in comment lines. --- Tools/scripts/findnocoding.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Tools/scripts/findnocoding.py') diff --git a/Tools/scripts/findnocoding.py b/Tools/scripts/findnocoding.py index b3e9dc7361..c0997d6598 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: -- cgit v1.2.1