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
00d650ba
Commit
00d650ba
authored
Jan 21, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix JSON docs about loads() accepting only str objects, not bytes.
parent
2e042d3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
11 deletions
+8
-11
Doc/library/json.rst
Doc/library/json.rst
+6
-11
Lib/json/__init__.py
Lib/json/__init__.py
+2
-0
No files found.
Doc/library/json.rst
View file @
00d650ba
...
...
@@ -118,9 +118,8 @@ Basic Usage
file-like object).
If *skipkeys* is ``True`` (default: ``False``), then dict keys that are not
of a basic type (:class:`bytes`, :class:`str`, :class:`int`,
:class:`float`, :class:`bool`, ``None``) will be skipped instead of raising a
:exc:`TypeError`.
of a basic type (:class:`str`, :class:`int`, :class:`float`, :class:`bool`,
``None``) will be skipped instead of raising a :exc:`TypeError`.
The :mod:`json` module always produces :class:`str` objects, not
:class:`bytes` objects. Therefore, ``fp.write()`` must support :class:`str`
...
...
@@ -203,15 +202,11 @@ Basic Usage
.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *s* (a :class:`bytes` or :class:`str` instance containing a JSON
document) to a Python object.
If *s* is a :class:`bytes` instance and is encoded with an ASCII based encoding
other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be
specified. Encodings that are not ASCII based (such as UCS-2) are not
allowed and should be decoded to :class:`str` first.
Deserialize *s* (a :class:`str` instance containing a JSON document) to a
Python object.
The other arguments have the same meaning as in :func:`load`.
The other arguments have the same meaning as in :func:`load`, except
*encoding* which is ignored and deprecated.
Encoders and decoders
...
...
Lib/json/__init__.py
View file @
00d650ba
...
...
@@ -298,6 +298,8 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``JSONDecoder`` is used.
The ``encoding`` argument is ignored and deprecated.
"""
if
(
cls
is
None
and
object_hook
is
None
and
parse_int
is
None
and
parse_float
is
None
and
...
...
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