Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 00d650b

Browse files
committed
Fix JSON docs about loads() accepting only str objects, not bytes.
1 parent 2e042d3 commit 00d650b

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

Doc/library/json.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ Basic Usage
118118
file-like object).
119119

120120
If *skipkeys* is ``True`` (default: ``False``), then dict keys that are not
121-
of a basic type (:class:`bytes`, :class:`str`, :class:`int`,
122-
:class:`float`, :class:`bool`, ``None``) will be skipped instead of raising a
123-
:exc:`TypeError`.
121+
of a basic type (:class:`str`, :class:`int`, :class:`float`, :class:`bool`,
122+
``None``) will be skipped instead of raising a :exc:`TypeError`.
124123

125124
The :mod:`json` module always produces :class:`str` objects, not
126125
:class:`bytes` objects. Therefore, ``fp.write()`` must support :class:`str`
@@ -203,15 +202,11 @@ Basic Usage
203202

204203
.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
205204

206-
Deserialize *s* (a :class:`bytes` or :class:`str` instance containing a JSON
207-
document) to a Python object.
208-
209-
If *s* is a :class:`bytes` instance and is encoded with an ASCII based encoding
210-
other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be
211-
specified. Encodings that are not ASCII based (such as UCS-2) are not
212-
allowed and should be decoded to :class:`str` first.
205+
Deserialize *s* (a :class:`str` instance containing a JSON document) to a
206+
Python object.
213207

214-
The other arguments have the same meaning as in :func:`load`.
208+
The other arguments have the same meaning as in :func:`load`, except
209+
*encoding* which is ignored and deprecated.
215210

216211

217212
Encoders and decoders

Lib/json/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
298298
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
299299
kwarg; otherwise ``JSONDecoder`` is used.
300300
301+
The ``encoding`` argument is ignored and deprecated.
302+
301303
"""
302304
if (cls is None and object_hook is None and
303305
parse_int is None and parse_float is None and

0 commit comments

Comments
 (0)