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
7d01e78c
Commit
7d01e78c
authored
Apr 13, 2011
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Plain Diff
Merge with 3.2.
parents
b5eacc29
04c6423f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
9 deletions
+34
-9
Lib/json/decoder.py
Lib/json/decoder.py
+6
-0
Lib/test/json_tests/test_decode.py
Lib/test/json_tests/test_decode.py
+5
-0
Lib/test/json_tests/test_scanstring.py
Lib/test/json_tests/test_scanstring.py
+7
-2
Lib/test/json_tests/test_speedups.py
Lib/test/json_tests/test_speedups.py
+10
-4
Misc/NEWS
Misc/NEWS
+6
-3
No files found.
Lib/json/decoder.py
View file @
7d01e78c
...
...
@@ -165,6 +165,12 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
nextchar
=
s
[
end
:
end
+
1
]
# Trivial empty object
if
nextchar
==
'}'
:
if
object_pairs_hook
is
not
None
:
result
=
object_pairs_hook
(
pairs
)
return
result
,
end
pairs
=
{}
if
object_hook
is
not
None
:
pairs
=
object_hook
(
pairs
)
return
pairs
,
end
+
1
elif
nextchar
!=
'"'
:
raise
ValueError
(
errmsg
(
"Expecting property name"
,
s
,
end
))
...
...
Lib/test/json_tests/test_decode.py
View file @
7d01e78c
...
...
@@ -31,6 +31,11 @@ class TestDecode(TestCase):
self
.
assertTrue
(
isinstance
(
rval
,
float
))
self
.
assertEqual
(
rval
,
1.0
)
def
test_empty_objects
(
self
):
self
.
assertEqual
(
json
.
loads
(
'{}'
),
{})
self
.
assertEqual
(
json
.
loads
(
'[]'
),
[])
self
.
assertEqual
(
json
.
loads
(
'""'
),
""
)
def
test_object_pairs_hook
(
self
):
s
=
'{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
p
=
[(
"xkd"
,
1
),
(
"kcw"
,
2
),
(
"art"
,
3
),
(
"hxm"
,
4
),
...
...
Lib/test/json_tests/test_scanstring.py
View file @
7d01e78c
import
sys
import
decimal
from
unittest
import
TestCase
from
unittest
import
TestCase
,
skipUnless
import
json
import
json.decoder
try
:
import
_json
except
ImportError
:
_json
=
None
class
TestScanString
(
TestCase
):
def
test_py_scanstring
(
self
):
self
.
_test_scanstring
(
json
.
decoder
.
py_scanstring
)
@
skipUnless
(
_json
,
'test requires the _json module'
)
def
test_c_scanstring
(
self
):
if
json
.
decoder
.
c_scanstring
is
not
None
:
self
.
_test_scanstring
(
json
.
decoder
.
c_scanstring
)
...
...
Lib/test/json_tests/test_speedups.py
View file @
7d01e78c
from
unittest
import
TestCase
from
unittest
import
TestCase
,
skipUnless
from
json
import
decoder
,
encoder
,
scanner
try
:
import
_json
except
ImportError
:
_json
=
None
@
skipUnless
(
_json
,
'test requires the _json module'
)
class
TestSpeedups
(
TestCase
):
def
test_scanstring
(
self
):
self
.
assertEqual
(
decoder
.
scanstring
.
__module__
,
"_json"
)
self
.
assert
True
(
decoder
.
scanstring
is
decoder
.
c_scanstring
)
self
.
assert
Is
(
decoder
.
scanstring
,
decoder
.
c_scanstring
)
def
test_encode_basestring_ascii
(
self
):
self
.
assertEqual
(
encoder
.
encode_basestring_ascii
.
__module__
,
"_json"
)
self
.
assert
True
(
encoder
.
encode_basestring_ascii
is
encoder
.
c_encode_basestring_ascii
)
self
.
assert
Is
(
encoder
.
encode_basestring_ascii
,
encoder
.
c_encode_basestring_ascii
)
class
TestDecode
(
TestCase
):
def
test_make_scanner
(
self
):
...
...
Misc/NEWS
View file @
7d01e78c
...
...
@@ -103,11 +103,14 @@ Core and Builtins
Library
-------
- Issue #11830: Remove unnecessary introspection code in the decimal module.
- Issue #9233: Fix json.loads('
{}
') to return a dict (instead of a list), when
_json is not available.
- Issue #11703 - urllib2.geturl() does not return correct url when the original
- Issue #11830: Remove unnecessary introspection code in the decimal module.
- Issue #11703: urllib2.geturl() does not return correct url when the original
url contains #fragment.
- Issue #10019: Fixed regression in json module where an indent of 0 stopped
adding newlines and acted instead like '
None
'.
...
...
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