Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json.loads encoding parameter deprecation removal in Python 3.9 #83558

Closed
tirkarthi opened this issue Jan 18, 2020 · 9 comments
Closed

json.loads encoding parameter deprecation removal in Python 3.9 #83558

tirkarthi opened this issue Jan 18, 2020 · 9 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@tirkarthi
Copy link
Member

BPO 39377
Nosy @vstinner, @methane, @serhiy-storchaka, @ammaraskar, @tirkarthi
PRs
  • bpo-39377: json: Remove encoding option. #18075
  • bpo-39377: json: Update doc about the encoding option. #18076
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-01-22.10:22:24.145>
    created_at = <Date 2020-01-18.05:27:39.947>
    labels = ['type-bug', 'library', '3.9']
    title = 'json.loads encoding parameter deprecation removal in Python 3.9'
    updated_at = <Date 2020-01-22.10:22:24.144>
    user = 'https://github.com/tirkarthi'

    bugs.python.org fields:

    activity = <Date 2020-01-22.10:22:24.144>
    actor = 'methane'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-22.10:22:24.145>
    closer = 'methane'
    components = ['Library (Lib)']
    creation = <Date 2020-01-18.05:27:39.947>
    creator = 'xtreak'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39377
    keywords = ['patch']
    message_count = 9.0
    messages = ['360235', '360289', '360291', '360292', '360293', '360294', '360295', '360296', '360457']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'methane', 'serhiy.storchaka', 'ammar2', 'xtreak']
    pr_nums = ['18075', '18076']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39377'
    versions = ['Python 3.9']

    @tirkarthi
    Copy link
    Member Author

    This is a followup of bpo-33461. 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.

    @tirkarthi tirkarthi added 3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 18, 2020
    @methane
    Copy link
    Member

    methane commented Jan 20, 2020

    New changeset 5492bfc by Inada Naoki in branch 'master':
    bpo-39377: json: Remove the encoding option. (GH-18075)
    5492bfc

    @tirkarthi
    Copy link
    Member Author

    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.

    @ammaraskar
    Copy link
    Member

    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'

    @methane
    Copy link
    Member

    methane commented Jan 20, 2020

    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.

    @tirkarthi
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member

    I reopen the issue.

    New changeset 5492bfc by Inada Naoki in branch 'master':
    bpo-39377: json: Remove the encoding option. (GH-18075)
    5492bfc

    Would you mind to document the removal in the following doc section?
    https://docs.python.org/dev/whatsnew/3.9.html#removed

    @vstinner vstinner reopened this Jan 20, 2020
    @vstinner vstinner reopened this Jan 20, 2020
    @serhiy-storchaka
    Copy link
    Member

    Please update the documentation which still mentions the encoding parameter.

    @methane
    Copy link
    Member

    methane commented Jan 22, 2020

    New changeset 5bbac8c by Inada Naoki in branch 'master':
    bpo-39377: json: Update doc about the encoding option. (GH-18076)
    5bbac8c

    @methane methane closed this as completed Jan 22, 2020
    @methane methane closed this as completed Jan 22, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants