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
dee76e62
Commit
dee76e62
authored
Jan 13, 2012
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13774: json: Fix a SystemError when a bogus encoding is passed to
json.loads().
parent
44765e58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
1 deletion
+15
-1
Lib/json/tests/test_unicode.py
Lib/json/tests/test_unicode.py
+4
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_json.c
Modules/_json.c
+8
-1
No files found.
Lib/json/tests/test_unicode.py
View file @
dee76e62
...
...
@@ -80,6 +80,10 @@ class TestUnicode(object):
# Issue 10038.
self
.
assertEqual
(
type
(
self
.
loads
(
'"foo"'
)),
unicode
)
def
test_bad_encoding
(
self
):
self
.
assertRaises
(
UnicodeEncodeError
,
self
.
loads
,
'"a"'
,
u"rat
\
xe9
"
)
self
.
assertRaises
(
TypeError
,
self
.
loads
,
'"a"'
,
1
)
class
TestPyUnicode
(
TestUnicode
,
PyTest
):
pass
class
TestCUnicode
(
TestUnicode
,
CTest
):
pass
Misc/NEWS
View file @
dee76e62
...
...
@@ -374,6 +374,9 @@ Library
Extension
Modules
-----------------
-
Issue
#
13774
:
json
:
Fix
a
SystemError
when
a
bogus
encoding
is
passed
to
json
.
loads
().
-
Issue
#
9975
:
socket
:
Fix
incorrect
use
of
flowinfo
and
scope_id
.
Patch
by
Vilmos
Nebehaj
.
...
...
Modules/_json.c
View file @
dee76e62
...
...
@@ -1725,8 +1725,15 @@ scanner_init(PyObject *self, PyObject *args, PyObject *kwds)
Py_DECREF
(
s
->
encoding
);
s
->
encoding
=
tmp
;
}
if
(
s
->
encoding
==
NULL
||
!
PyString_Check
(
s
->
encoding
)
)
if
(
s
->
encoding
==
NULL
)
goto
bail
;
if
(
!
PyString_Check
(
s
->
encoding
))
{
PyErr_Format
(
PyExc_TypeError
,
"encoding must be a string, not %.80s"
,
Py_TYPE
(
s
->
encoding
)
->
tp_name
);
goto
bail
;
}
/* All of these will fail "gracefully" so we don't need to verify them */
s
->
strict
=
PyObject_GetAttrString
(
ctx
,
"strict"
);
...
...
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