This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: json.loads encoding parameter deprecation removal in Python 3.9
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ammar2, methane, serhiy.storchaka, vstinner, xtreak
Priority: normal Keywords: patch

Created on 2020-01-18 05:27 by xtreak, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18075 merged methane, 2020-01-20 04:02
PR 18076 merged methane, 2020-01-20 05:07
Messages (9)
msg360235 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-01-18 05:27
This is a followup of issue33461. The warning says about removal of the encoding parameter in 3.9 . It's already ignored since 3.1 hence I assume this should be raising a TypeError in 3.9 removing the deprecation warning. I am finding some projects using the encoding parameter though it has no effect. Since Python 3.9 has alpha 3 to be released it will be good to fix the deprecation in the early stage of release cycle.
msg360289 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-01-20 04:54
New changeset 5492bfcefec67b016e8239c0e9135bc2f03e3058 by Inada Naoki in branch 'master':
bpo-39377: json: Remove the encoding option. (GH-18075)
https://github.com/python/cpython/commit/5492bfcefec67b016e8239c0e9135bc2f03e3058
msg360291 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-01-20 05:36
Should we be raising an error if encoding is present on 3.9 as part of kwargs? It's obtrusive but for people going from Python 3.7 to 3.9 there will be no change and they will keep assuming encoding parameter is valid.
msg360292 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2020-01-20 06:08
Do you mean to say we should or shouldn't be raising an error? With Inada-san's change you get this:

>>> json.loads("true", encoding='utf8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ammar\workspace\cpython\lib\json\__init__.py", line 359, in loads
    return cls(**kw).decode(s)
TypeError: __init__() got an unexpected keyword argument 'encoding'
msg360293 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-01-20 06:24
If this broke some real-world software and the pain is high enough, we can revert the change and add one more deprecation period, like all other removals.
msg360294 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-01-20 07:50
> Do you mean to say we should or shouldn't be raising an error? With Inada-san's change you get this:

Sorry, I misread the patch as only removal and didn't test the change completely.

I am filing issues on code that I can find using this pattern and will wait for the feedback during alpha cycle.

* https://github.com/ansible/ansible/issues/66592
* https://github.com/jupyter/notebook/issues/5165
* https://github.com/django-extensions/django-extensions/issues/1465
msg360295 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-20 07:54
I reopen the issue.

> New changeset 5492bfcefec67b016e8239c0e9135bc2f03e3058 by Inada Naoki in branch 'master':
> bpo-39377: json: Remove the encoding option. (GH-18075)
> https://github.com/python/cpython/commit/5492bfcefec67b016e8239c0e9135bc2f03e3058

Would you mind to document the removal in the following doc section?
https://docs.python.org/dev/whatsnew/3.9.html#removed
msg360296 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-01-20 08:13
Please update the documentation which still mentions the encoding parameter.
msg360457 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2020-01-22 10:01
New changeset 5bbac8cbdf140ebce446ea4e7db2b20a5d7b8402 by Inada Naoki in branch 'master':
bpo-39377: json: Update doc about the encoding option. (GH-18076)
https://github.com/python/cpython/commit/5bbac8cbdf140ebce446ea4e7db2b20a5d7b8402
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83558
2020-01-22 10:22:24methanesetstatus: open -> closed
resolution: fixed
2020-01-22 10:01:48methanesetmessages: + msg360457
2020-01-20 08:13:05serhiy.storchakasetmessages: + msg360296
2020-01-20 07:54:32vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg360295
2020-01-20 07:50:35xtreaksetmessages: + msg360294
2020-01-20 06:24:18methanesetmessages: + msg360293
2020-01-20 06:08:56ammar2setnosy: + ammar2
messages: + msg360292
2020-01-20 05:36:14xtreaksetmessages: + msg360291
2020-01-20 05:07:43methanesetpull_requests: + pull_request17469
2020-01-20 04:54:18methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-01-20 04:54:08methanesetmessages: + msg360289
2020-01-20 04:02:20methanesetkeywords: + patch
stage: patch review
pull_requests: + pull_request17468
2020-01-18 05:27:40xtreakcreate