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 — Deprecate `codecs.open()` · Issue #133036 · python/cpython

Deprecate codecs.open() #133036

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate codecs.open()#133036
Copy link
Assignees
methane
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@methane
methane
opened on Apr 27, 2025
Issue body actions

Discussion: https://discuss.python.org/t/deprecating-codecs-open/88135/

codecs.open() is used a lot because it was recommended in Python 2.
But open() (or io.open()) is recommended since Python 3.

It is a time to deprecate codecs.open().
Since it is still widely used, we won't schedule its removal.

Linked PRs

  • gh-133036: Deprecate codecs.open #133038

Activity

  1. methane
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Apr 27, 2025
  2. methane
    self-assigned this
    on Apr 27, 2025
  3. methane
    added this to Codecs and encodings issueson Apr 27, 2025
  4. methane
    added a commit that references this issue on Apr 27, 2025

    pythongh-133036: deprecate codecs.open

    655759b
  5. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 27, 2025
  6. methane
    added a commit that references this issue on Apr 30, 2025

    gh-133036: Deprecate codecs.open (#133038)

    4e294f6
  7. hugovk
    closed this as completedon Apr 30, 2025
  8. github-project-automation
    moved this to Done in Codecs and encodings issueson Apr 30, 2025
  9. ngoldbaum commented on Aug 7, 2025

    @ngoldbaum
    ngoldbaum
    on Aug 7, 2025
    Contributor
    More actions

    I don't know if this deserves a better clarification in the deprecation notice, but I hit a corner case that took me a few minutes to understand today. Perhaps commenting here will help someone else.

    I tried replacing codecs.open with open in a spot in pandas and hit this error:

    >               with open(as_json, "wb", encoding="utf8") as f:
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    E               ValueError: binary mode doesn't take an encoding argument
    

    I fixed it by replacing "wb" with "w". It seems codecs.open is a little more permissive here than open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @methane
    methane

Labels

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

Projects

  • Codecs and encodings issues
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402520 — 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.