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
11f0b41e
Commit
11f0b41e
authored
Jul 07, 2012
by
Florent Xicluna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14990: tokenize: correctly fail with SyntaxError on invalid encoding declaration.
parent
9235b254
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
1 deletion
+8
-1
Lib/test/test_tokenize.py
Lib/test/test_tokenize.py
+4
-0
Lib/tokenize.py
Lib/tokenize.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_tokenize.py
View file @
11f0b41e
...
...
@@ -674,6 +674,10 @@ class TestTokenizerAdheresToPep0263(TestCase):
f
=
'tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt'
self
.
assertTrue
(
self
.
_testFile
(
f
))
def
test_bad_coding_cookie
(
self
):
self
.
assertRaises
(
SyntaxError
,
self
.
_testFile
,
'bad_coding.py'
)
self
.
assertRaises
(
SyntaxError
,
self
.
_testFile
,
'bad_coding2.py'
)
class
Test_Tokenize
(
TestCase
):
...
...
Lib/tokenize.py
View file @
11f0b41e
...
...
@@ -310,7 +310,7 @@ def detect_encoding(readline):
raise
SyntaxError
(
"unknown encoding: "
+
encoding
)
if
bom_found
:
if
codec
.
name
!=
'utf-8'
:
if
encoding
!=
'utf-8'
:
# This behaviour mimics the Python interpreter
raise
SyntaxError
(
'encoding problem: utf-8'
)
encoding
+=
'-sig'
...
...
Misc/NEWS
View file @
11f0b41e
...
...
@@ -87,6 +87,9 @@ Core and Builtins
Library
-------
- Issue #14990: Correctly fail with SyntaxError on invalid encoding
declaration.
- Issue #15247: FileIO now raises an error when given a file descriptor
pointing to a directory.
...
...
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