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
273a720f
Commit
273a720f
authored
Apr 21, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Plain Diff
merge 3.4 (#24022)
parents
8714cfdc
d73aca76
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
Lib/test/test_compile.py
Lib/test/test_compile.py
+13
-1
Misc/NEWS
Misc/NEWS
+2
-0
Parser/tokenizer.c
Parser/tokenizer.c
+3
-4
No files found.
Lib/test/test_compile.py
View file @
273a720f
import
math
import
os
import
unittest
import
sys
import
_ast
import
tempfile
import
types
from
test
import
support
from
test
import
support
,
script_helper
class
TestSpecifics
(
unittest
.
TestCase
):
...
...
@@ -492,6 +494,16 @@ if 1:
self
.
assertInvalidSingle
(
'f()
\
n
xy # blah
\
n
blah()'
)
self
.
assertInvalidSingle
(
'x = 5 # comment
\
n
x = 6
\
n
'
)
def
test_particularly_evil_undecodable
(
self
):
# Issue 24022
src
=
b'0000
\
x00
\
n
00000000000
\
n
\
x00
\
n
\
x9e
\
n
'
with
tempfile
.
TemporaryDirectory
()
as
tmpd
:
fn
=
os
.
path
.
join
(
tmpd
,
"bad.py"
)
with
open
(
fn
,
"wb"
)
as
fp
:
fp
.
write
(
src
)
res
=
script_helper
.
run_python_until_end
(
fn
)[
0
]
self
.
assertIn
(
b"Non-UTF-8"
,
res
.
err
)
@
support
.
cpython_only
def
test_compiler_recursion_limit
(
self
):
# Expected limit is sys.getrecursionlimit() * the scaling factor
...
...
Misc/NEWS
View file @
273a720f
...
...
@@ -10,6 +10,8 @@ Release date: 2015-04-24
Core and Builtins
-----------------
- Issue #24022: Fix tokenizer crash when processing undecodable source code.
Library
-------
...
...
Parser/tokenizer.c
View file @
273a720f
...
...
@@ -1307,6 +1307,8 @@ verify_identifier(struct tok_state *tok)
{
PyObject
*
s
;
int
result
;
if
(
tok
->
decoding_erred
)
return
0
;
s
=
PyUnicode_DecodeUTF8
(
tok
->
start
,
tok
->
cur
-
tok
->
start
,
NULL
);
if
(
s
==
NULL
||
PyUnicode_READY
(
s
)
==
-
1
)
{
if
(
PyErr_ExceptionMatches
(
PyExc_UnicodeDecodeError
))
{
...
...
@@ -1475,11 +1477,8 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
c
=
tok_nextc
(
tok
);
}
tok_backup
(
tok
,
c
);
if
(
nonascii
&&
!
verify_identifier
(
tok
))
{
tok
->
done
=
E_IDENTIFIER
;
if
(
nonascii
&&
!
verify_identifier
(
tok
))
return
ERRORTOKEN
;
}
*
p_start
=
tok
->
start
;
*
p_end
=
tok
->
cur
;
return
NAME
;
...
...
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