Description
When running tests with Python 3.12+, the library emits deprecation warnings about codecs.open():
DeprecationWarning: 'codecs.open' is deprecated. Use built-in open() instead.
This appears to come from the internal file loading mechanism.
Environment
- Python: 3.12+
- python-frontmatter: 1.1.0
Suggested Fix
Replace codecs.open() with the built-in open() function with explicit encoding parameter:
# Before
import codecs
with codecs.open(path, 'r', encoding='utf-8') as f:
content = f.read()
# After
with open(path, 'r', encoding='utf-8') as f:
content = f.read()
The built-in open() has supported the encoding parameter since Python 3.0, so this change would be backwards compatible.
Workaround
Currently filtering the warning in pytest.ini:
filterwarnings =
ignore::DeprecationWarning:frontmatter.*:
Thank you for maintaining this library!
Description
When running tests with Python 3.12+, the library emits deprecation warnings about
codecs.open():This appears to come from the internal file loading mechanism.
Environment
Suggested Fix
Replace
codecs.open()with the built-inopen()function with explicit encoding parameter:The built-in
open()has supported theencodingparameter since Python 3.0, so this change would be backwards compatible.Workaround
Currently filtering the warning in pytest.ini:
filterwarnings = ignore::DeprecationWarning:frontmatter.*:Thank you for maintaining this library!