Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e431d3c9
Commit
e431d3c9
authored
Mar 20, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26581: Use the first coding cookie on a line, not the last one.
parent
97eee1cf
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
10 additions
and
6 deletions
+10
-6
Lib/idlelib/IOBinding.py
Lib/idlelib/IOBinding.py
+1
-1
Lib/lib2to3/pgen2/tokenize.py
Lib/lib2to3/pgen2/tokenize.py
+1
-1
Lib/test/test_importlib/source/test_source_encoding.py
Lib/test/test_importlib/source/test_source_encoding.py
+1
-1
Lib/test/test_source_encoding.py
Lib/test/test_source_encoding.py
+1
-1
Lib/tokenize.py
Lib/tokenize.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
Parser/tokenizer.c
Parser/tokenizer.c
+1
-0
Tools/scripts/findnocoding.py
Tools/scripts/findnocoding.py
+1
-1
No files found.
Lib/idlelib/IOBinding.py
View file @
e431d3c9
...
...
@@ -62,7 +62,7 @@ locale_encoding = locale_encoding.lower()
encoding
=
locale_encoding
### KBK 07Sep07 This is used all over IDLE, check!
### 'encoding' is used below in encode(), check!
coding_re
=
re
.
compile
(
r'^[ \t\f]*#.*coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
coding_re
=
re
.
compile
(
r'^[ \t\f]*#.*
?
coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
blank_re = re.compile(r'
^
[
\
t
\
f
]
*
(
?
:[
#\r\n]|$)', re.ASCII)
def
coding_spec
(
data
):
...
...
Lib/lib2to3/pgen2/tokenize.py
View file @
e431d3c9
...
...
@@ -236,7 +236,7 @@ class Untokenizer:
startline
=
False
toks_append
(
tokval
)
cookie_re
=
re
.
compile
(
r'^[ \t\f]*#.*coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
cookie_re
=
re
.
compile
(
r'^[ \t\f]*#.*
?
coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
blank_re = re.compile(br'
^
[
\
t
\
f
]
*
(
?
:[
#\r\n]|$)', re.ASCII)
def
_get_normal_name
(
orig_enc
):
...
...
Lib/test/test_importlib/source/test_source_encoding.py
View file @
e431d3c9
...
...
@@ -14,7 +14,7 @@ import unittest
import
warnings
CODING_RE
=
re
.
compile
(
r'^[ \t\f]*#.*coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
CODING_RE
=
re
.
compile
(
r'^[ \t\f]*#.*
?
coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
class EncodingTest:
...
...
Lib/test/test_source_encoding.py
View file @
e431d3c9
...
...
@@ -178,7 +178,7 @@ class AbstractSourceEncodingTest:
def
test_double_coding_same_line
(
self
):
src
=
(
b'#coding:iso8859-15 coding:latin1
\
n
'
b'print(ascii("
\
xc3
\
xa4
"))
\
n
'
)
self
.
check_script_output
(
src
,
br"'\xc3\
xa4
'"
)
self
.
check_script_output
(
src
,
br"'\xc3\
u20ac
'"
)
def
test_first_non_utf8_coding_line
(
self
):
src
=
(
b'#coding:iso-8859-15
\
xa4
\
n
'
...
...
Lib/tokenize.py
View file @
e431d3c9
...
...
@@ -33,7 +33,7 @@ import re
import
sys
from
token
import
*
cookie_re
=
re
.
compile
(
r'^[ \t\f]*#.*coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
cookie_re
=
re
.
compile
(
r'^[ \t\f]*#.*
?
coding[:=][ \t]*([-\
w.]+)
', re.ASCII)
blank_re = re.compile(br'
^
[
\
t
\
f
]
*
(
?
:[
#\r\n]|$)', re.ASCII)
import
token
...
...
Misc/NEWS
View file @
e431d3c9
...
...
@@ -10,6 +10,9 @@ Release date: tba
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 #26464: Fix str.translate() when string is ASCII and first replacements
removes character, but next replacement uses a non-ASCII character or a
string longer than 1 character. Regression introduced in Python 3.5.0.
...
...
Parser/tokenizer.c
View file @
e431d3c9
...
...
@@ -275,6 +275,7 @@ get_coding_spec(const char *s, char **spec, Py_ssize_t size, struct tok_state *t
return
0
;
}
*
spec
=
r
;
break
;
}
}
}
...
...
Tools/scripts/findnocoding.py
View file @
e431d3c9
...
...
@@ -32,7 +32,7 @@ except ImportError:
"no sophisticated Python source file search will be done."
,
file
=
sys
.
stderr
)
decl_re
=
re
.
compile
(
rb'^[ \t\f]*#.*coding[:=][ \t]*([-\
w.]+)
')
decl_re
=
re
.
compile
(
rb'^[ \t\f]*#.*
?
coding[:=][ \t]*([-\
w.]+)
')
blank_re = re.compile(rb'
^
[
\
t
\
f
]
*
(
?
:[
#\r\n]|$)')
def
get_declaration
(
line
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment