GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Passing bytes to `tomllib.loads()` gives wrong error message · Issue #132655 · python/cpython

Passing bytes to tomllib.loads() gives wrong error message #132655

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Passing bytes to tomllib.loads() gives wrong error message#132655
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@dargueta-accompanyhealth
dargueta-accompanyhealth
opened on Apr 17, 2025
Issue body actions

Bug report

Edit: It looks like this was fixed in #124587 but either regressed or that hasn't been released yet? It was merged October 2024.

Bug description:

If you call tomllib.loads() and mistakenly pass in a bytes object instead of a string...

tomllib.loads(b'a="asdf"')

...you get a TypeError as expected, but the error message is wrong:

TypeError: a bytes-like object is required, not 'str'

The error message should be the reverse, something like "a string-like object is required, not 'bytes'".

The bug is present on macOS with the following versions:

  • 3.13.3
  • 3.12.10
  • 3.11.12

CPython versions tested on:

3.13, 3.12, 3.11

Operating systems tested on:

macOS

Activity

  1. dargueta-accompanyhealth
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 17, 2025
  2. StanFromIreland commented on Apr 17, 2025

    @StanFromIreland
    StanFromIreland
    on Apr 17, 2025
    Member
    More actions

    This should be closed, the problem is an update was not backported (it only works on 3.14) as it is a semi-bug/feature, if we want to backport it discussion should be moved to the original issue #124835.

    Backporting would only go as far as 3.13, there is nothing to do for other versions.

  3. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Apr 17, 2025
  4. StanFromIreland commented on Apr 17, 2025

    @StanFromIreland
    StanFromIreland
    on Apr 17, 2025
    Member
    More actions

    @picnixz Any thoughts -- should it be backported?

  5. hauntsaninja commented on Apr 17, 2025

    @hauntsaninja
    hauntsaninja
    on Apr 17, 2025
    Contributor
    More actions

    I'd intentionally chosen not to backport as per #124835 (comment)

  6. StanFromIreland commented on Apr 17, 2025

    @StanFromIreland
    StanFromIreland
    on Apr 17, 2025
    Member
    More actions

    This can be closed then :-)

  7. hauntsaninja commented on Apr 17, 2025

    @hauntsaninja
    hauntsaninja
    on Apr 17, 2025
    Contributor
    More actions

    Thank you for reporting this!!

  8. hauntsaninja
    closed this as not plannedon Apr 17, 2025
  9. dargueta-accompanyhealth commented on Apr 17, 2025

    @dargueta-accompanyhealth
    dargueta-accompanyhealth
    on Apr 17, 2025
    Author
    More actions

    Got it, makes sense. Thanks for the quick response as well.

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/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.