@@ -296,7 +296,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
296296 parse_constant = parse_constant , object_pairs_hook = object_pairs_hook , ** kw )
297297
298298
299- def loads (s , * , encoding = None , cls = None , object_hook = None , parse_float = None ,
299+ def loads (s , * , cls = None , object_hook = None , parse_float = None ,
300300 parse_int = None , parse_constant = None , object_pairs_hook = None , ** kw ):
301301 """Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
302302 containing a JSON document) to a Python object.
@@ -330,7 +330,7 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
330330 To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
331331 kwarg; otherwise ``JSONDecoder`` is used.
332332
333- The ``encoding`` argument is ignored and deprecated.
333+ The ``encoding`` argument is ignored and deprecated since Python 3.1 .
334334 """
335335 if isinstance (s , str ):
336336 if s .startswith ('\ufeff ' ):
@@ -342,6 +342,15 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None,
342342 f'not { s .__class__ .__name__ } ' )
343343 s = s .decode (detect_encoding (s ), 'surrogatepass' )
344344
345+ if "encoding" in kw :
346+ import warnings
347+ warnings .warn (
348+ "'encoding' is ignored and deprecated. It will be removed in Python 3.9" ,
349+ DeprecationWarning ,
350+ stacklevel = 2
351+ )
352+ del kw ['encoding' ]
353+
345354 if (cls is None and object_hook is None and
346355 parse_int is None and parse_float is None and
347356 parse_constant is None and object_pairs_hook is None and not kw ):
0 commit comments