Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions 11 Lib/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ def loads(s, *, 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 since Python 3.1.
"""
if isinstance(s, str):
if s.startswith('\ufeff'):
Expand All @@ -342,15 +340,6 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None,
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):
Expand Down
4 changes: 0 additions & 4 deletions 4 Lib/test/test_json/test_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,5 @@ def test_negative_index(self):
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed ``encoding`` option from :func:`json.loads`. It has been deprecated
since Python 3.1.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.