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
595e3cbb
Commit
595e3cbb
authored
Oct 16, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check for error conditions in _json #3623
parent
eaede315
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
Lib/json/tests/test_scanstring.py
Lib/json/tests/test_scanstring.py
+7
-0
Modules/_json.c
Modules/_json.c
+5
-3
No files found.
Lib/json/tests/test_scanstring.py
View file @
595e3cbb
...
...
@@ -2,6 +2,7 @@ import sys
import
decimal
from
unittest
import
TestCase
import
json
import
json.decoder
class
TestScanString
(
TestCase
):
...
...
@@ -100,3 +101,9 @@ class TestScanString(TestCase):
self
.
assertEquals
(
scanstring
(
'["Bad value", truth]'
,
2
,
None
,
True
),
(
u'Bad value'
,
12
))
def
test_issue3623
(
self
):
self
.
assertRaises
(
ValueError
,
json
.
decoder
.
scanstring
,
b"xxx"
,
1
,
"xxx"
)
self
.
assertRaises
(
UnicodeDecodeError
,
json
.
encoder
.
encode_basestring_ascii
,
b"xx
\
xff
"
)
Modules/_json.c
View file @
595e3cbb
...
...
@@ -179,11 +179,13 @@ raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
errmsg_fn
=
PyObject_GetAttrString
(
decoder
,
"errmsg"
);
if
(
errmsg_fn
==
NULL
)
return
;
Py_
X
DECREF
(
decoder
);
Py_DECREF
(
decoder
);
}
pymsg
=
PyObject_CallFunction
(
errmsg_fn
,
"(zOn)"
,
msg
,
s
,
end
);
PyErr_SetObject
(
PyExc_ValueError
,
pymsg
);
Py_DECREF
(
pymsg
);
if
(
pymsg
)
{
PyErr_SetObject
(
PyExc_ValueError
,
pymsg
);
Py_DECREF
(
pymsg
);
}
/*
def linecol(doc, pos):
...
...
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