Skip to content

Commit ee4c047

Browse files
authored
Merge pull request #193 from python/master
bpo-39377: json: Remove the encoding option. (pythonGH-18075)
2 parents 149cf1b + 5492bfc commit ee4c047

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

Lib/json/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,6 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None,
329329
330330
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
331331
kwarg; otherwise ``JSONDecoder`` is used.
332-
333-
The ``encoding`` argument is ignored and deprecated since Python 3.1.
334332
"""
335333
if isinstance(s, str):
336334
if s.startswith('\ufeff'):
@@ -342,15 +340,6 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None,
342340
f'not {s.__class__.__name__}')
343341
s = s.decode(detect_encoding(s), 'surrogatepass')
344342

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-
354343
if (cls is None and object_hook is None and
355344
parse_int is None and parse_float is None and
356345
parse_constant is None and object_pairs_hook is None and not kw):

Lib/test/test_json/test_decode.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,5 @@ def test_negative_index(self):
9595
d = self.json.JSONDecoder()
9696
self.assertRaises(ValueError, d.raw_decode, 'a'*42, -50000)
9797

98-
def test_deprecated_encode(self):
99-
with self.assertWarns(DeprecationWarning):
100-
self.loads('{}', encoding='fake')
101-
10298
class TestPyDecode(TestDecode, PyTest): pass
10399
class TestCDecode(TestDecode, CTest): pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Removed ``encoding`` option from :func:`json.loads`. It has been deprecated
2+
since Python 3.1.

0 commit comments

Comments
 (0)