To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``JSONDecoder`` is used.
-
- The ``encoding`` argument is ignored and deprecated since Python 3.1.
"""
if isinstance(s, str):
if s.startswith('\ufeff'):
f'not {s.__class__.__name__}')
s = s.decode(detect_encoding(s), 'surrogatepass')
- if "encoding" in kw:
- import warnings
- warnings.warn(
- "'encoding' is ignored and deprecated. It will be removed in Python 3.9",
- DeprecationWarning,
- stacklevel=2
- )
- del kw['encoding']
-
if (cls is None and object_hook is None and
parse_int is None and parse_float is None and
parse_constant is None and object_pairs_hook is None and not kw):
d = self.json.JSONDecoder()
self.assertRaises(ValueError, d.raw_decode, 'a'*42, -50000)
- def test_deprecated_encode(self):
- with self.assertWarns(DeprecationWarning):
- self.loads('{}', encoding='fake')
-
class TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass