Skip to content

Accept UTF-8 encoded bytes as input to json.loads() #71952

Closed

Description

@ncoghlan
BPO 27765
Nosy @rhettinger, @ncoghlan, @ezio-melotti, @serhiy-storchaka
Superseder
  • bpo-10976: accept bytes in json.loads()
  • 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 2016-08-17.12:20:36.787>
    created_at = <Date 2016-08-15.07:20:28.611>
    labels = ['type-feature', 'library']
    title = 'Accept UTF-8 encoded bytes as input to json.loads()'
    updated_at = <Date 2016-08-17.12:36:03.790>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2016-08-17.12:36:03.790>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-08-17.12:20:36.787>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2016-08-15.07:20:28.611>
    creator = 'ncoghlan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 27765
    keywords = []
    message_count = 2.0
    messages = ['272725', '272728']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'ncoghlan', 'ezio.melotti', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '10976'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27765'
    versions = ['Python 3.6']

    Activity

    1. ncoghlan commented on Aug 15, 2016

      @ncoghlan
      ContributorAuthor

      In two recent Python 3 porting projects, a key incompatibility I encountered was that "json.loads(data)" on UTF-8 encoded bytes required an explicit decoding step under Python 3, rather than implicitly decoding the data as UTF-8.

      Unlike many other wire formats, assuming UTF-8 for binary JSON data is a pretty safe assumption, and there's no type ambiguity here since the output type is still a properly decoded JSON object.

      (This RFE has been split out from the larger RFE at bpo-19837, which also covers implicit *encoding* to UTF-8, which is a more questionable idea)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Aug 15, 2016
    3. serhiy-storchaka commented on Aug 15, 2016

      @serhiy-storchaka
      Member

      This looks as a duplicate of bpo-10976.

      See also bpo-17909 (which covers not just UTF-8, but UTF-16 and UTF-32, in conforming with RFC 4627).

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions