-
Notifications
You must be signed in to change notification settings - Fork 95
DeprecationWarning: codecs.open() deprecated in Python 3.14 #429
Description
Context
When building a Zensical site with Python 3.14, a DeprecationWarning is emitted from the emoji extension on every icon load.
Bug description
codecs.open() was deprecated in CPython 3.14 (python/cpython#133036, merged 2025-04-30). The _load() function in python/zensical/extensions/emoji.py uses codecs.open(file, encoding="utf-8"), which triggers a DeprecationWarning on every SVG icon load:
python/zensical/extensions/emoji.py:83: DeprecationWarning: codecs.open() is deprecated. Use open() instead.
The fix is to replace codecs.open() with the built-in open(), which has supported the encoding parameter since Python 3.0 and is safe for the full supported range (>=3.10).
References:
- CPython issue: Deprecate
codecs.open()python/cpython#133036 - CPython PR: gh-133036: Deprecate codecs.open python/cpython#133038
- Discussion: https://discuss.python.org/t/deprecating-codecs-open/88135
- What's New in Python 3.14: https://docs.python.org/3/whatsnew/3.14.html
Related links
Reproduction
No .zip needed — this is reproducible with any Zensical project that uses emoji/icons on Python 3.14.
- Install Python 3.14
- pip install zensical==0.0.25
- Run
python -W all -c "from zensical.extensions.emoji import _load; _load('any_svg_file.svg')" - Observe DeprecationWarning
Steps to reproduce
- Install Python 3.14.3
- Install zensical 0.0.25:
pip install zensical - Create or use any zensical project with icons/emojis
- Run
zensical buildwith warnings enabled (python -W all) - Observe:
DeprecationWarning: codecs.open() is deprecated. Use open() instead.fromemoji.py:83
Browser
No response
Before submitting
- I have read and followed the bug reporting guidelines.
- I have attached links to the documentation, and possibly related issues.
- I assure that I have removed all customizations before submitting this bug report.
- I have attached a .zip file with a minimal reproduction.