changeset: 100624:8506d127d482 branch: 2.7 parent: 100621:c3c5a88ddfda user: Serhiy Storchaka date: Sun Mar 20 23:36:29 2016 +0200 files: Lib/idlelib/IOBinding.py Lib/lib2to3/pgen2/tokenize.py Misc/NEWS Tools/scripts/findnocoding.py description: Issue #26581: Use the first coding cookie on a line, not the last one. diff -r c3c5a88ddfda -r 8506d127d482 Lib/idlelib/IOBinding.py --- a/Lib/idlelib/IOBinding.py Sun Mar 20 22:29:40 2016 +0200 +++ b/Lib/idlelib/IOBinding.py Sun Mar 20 23:36:29 2016 +0200 @@ -65,7 +65,7 @@ encoding = encoding.lower() -coding_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') +coding_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)') blank_re = re.compile(r'^[ \t\f]*(?:[#\r\n]|$)') class EncodingMessage(SimpleDialog): diff -r c3c5a88ddfda -r 8506d127d482 Lib/lib2to3/pgen2/tokenize.py --- a/Lib/lib2to3/pgen2/tokenize.py Sun Mar 20 22:29:40 2016 +0200 +++ b/Lib/lib2to3/pgen2/tokenize.py Sun Mar 20 23:36:29 2016 +0200 @@ -236,7 +236,7 @@ startline = False toks_append(tokval) -cookie_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') +cookie_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)') blank_re = re.compile(r'^[ \t\f]*(?:[#\r\n]|$)') def _get_normal_name(orig_enc): diff -r c3c5a88ddfda -r 8506d127d482 Misc/NEWS --- a/Misc/NEWS Sun Mar 20 22:29:40 2016 +0200 +++ b/Misc/NEWS Sun Mar 20 23:36:29 2016 +0200 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26581: If coding cookie is specified multiple times on a line in + Python source code file, only the first one is taken to account. + - Issue #22836: Ensure exception reports from PyErr_Display() and PyErr_WriteUnraisable() are sensible even when formatting them produces secondary errors. This affects the reports produced by diff -r c3c5a88ddfda -r 8506d127d482 Tools/scripts/findnocoding.py --- a/Tools/scripts/findnocoding.py Sun Mar 20 22:29:40 2016 +0200 +++ b/Tools/scripts/findnocoding.py Sun Mar 20 23:36:29 2016 +0200 @@ -32,7 +32,7 @@ "no sophisticated Python source file search will be done.") -decl_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') +decl_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)') blank_re = re.compile(r'^[ \t\f]*(?:[#\r\n]|$)') def get_declaration(line):