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.
Activity
pythongh-133036: deprecate codecs.open
gh-133036: Deprecate codecs.open (#133038)
ngoldbaum commented on Aug 7, 2025
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 argumentI fixed it by replacing "wb" with "w". It seems codecs.open is a little more permissive here than open.