Skip to content

fix: replace deprecated codecs.open() with built-in open() (#429)#428

Merged
squidfunk merged 1 commit intozensical:masterfrom
kwag93:fix/deprecate-codecs-open
Mar 11, 2026
Merged

fix: replace deprecated codecs.open() with built-in open() (#429)#428
squidfunk merged 1 commit intozensical:masterfrom
kwag93:fix/deprecate-codecs-open

Conversation

@kwag93
Copy link
Copy Markdown
Contributor

@kwag93 kwag93 commented Mar 11, 2026

Summary

Replace codecs.open() with the built-in open() in python/zensical/extensions/emoji.py to resolve a DeprecationWarning on Python 3.14+.

Background

codecs.open() was deprecated in CPython 3.14 (python/cpython#133036, python/cpython#133038). The built-in open() with encoding parameter is the official replacement, available since Python 3.0 — safe for the full supported range (>=3.10).

See also:

Changes

File Change
python/zensical/extensions/emoji.py codecs.open(file, encoding="utf-8")open(file, encoding="utf-8"), remove unused import codecs

Notes

  • open() returns TextIOWrapper (C impl) vs codecs.open() returning StreamReaderWriter (pure Python) — functionally identical for UTF-8 text reading, marginally faster
  • No behavioral change for Python 3.10–3.13 users; suppresses DeprecationWarning for Python 3.14+ users
  • Other projects have made the same change: e.g., GRASS GIS (OSGeo/grass#7062)

AI disclosure

This PR was created with the assistance of Claude Code. The change has been thoroughly reviewed and fully understood by the author — it is a straightforward 1:1 replacement of codecs.open() with the built-in open(), as officially recommended by CPython (python/cpython#133036). The author takes full responsibility for the correctness of this contribution.

@zensical
Copy link
Copy Markdown

zensical bot commented Mar 11, 2026

All commits verified and signed off.

@kwag93 kwag93 force-pushed the fix/deprecate-codecs-open branch from 68d43be to 4ab86d5 Compare March 11, 2026 03:38
@kwag93 kwag93 force-pushed the fix/deprecate-codecs-open branch from 4ab86d5 to fd6c421 Compare March 11, 2026 03:43
@kwag93 kwag93 changed the title fix: replace deprecated codecs.open() with built-in open() fix: replace deprecated codecs.open() with built-in open() (#429) Mar 11, 2026
@squidfunk
Copy link
Copy Markdown
Member

squidfunk commented Mar 11, 2026

Thanks for the PR! We already fixed this in Material 6 months ago, but the code was carried over before the fix and we didn't apply it here, so thanks for raising this and providing a fix ☺️

@squidfunk squidfunk merged commit 7514e32 into zensical:master Mar 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning: codecs.open() deprecated in Python 3.14

2 participants