Skip to content

codecs.open DeprecationWarning when using Python 3.14 #8446

@tleonhardt

Description

@tleonhardt

Context

When building documentation using MkDocs with the Material Theme in virtual environment using Python 3.14.0rc2, I got the following warning:

INFO    -  DeprecationWarning: codecs.open() is deprecated. Use open() instead.
             File ".venv/lib/python3.14/site-packages/material/extensions/emoji.py", line 53, in to_svg
               el.text = md.htmlStash.store(_load(icons[shortname]["path"]))
             File ".venv/lib/python3.14/site-packages/material/extensions/emoji.py", line 68, in _load
               with codecs.open(file, encoding = "utf-8") as f:

This is the line causing the problems in emoji.py:

def _load(file: str):
    with codecs.open(file, encoding = "utf-8") as f:
        return f.read()

Proposed solution, just replace codecs.open with open and remove the import for codecs:

def _load(file: str):
    with open(file, encoding = "utf-8") as f:
        return f.read()

I don't understand why your code tree duplicates files, but the file appears to be located at these two locations:

  • material/extensions/emoji.py
  • src/extensions/emoji.py

Bug description

codecs.open is deprecated as of Python 3.14 and open should be used instead.

Related links

Reproduction

mkdocs build -s using latest version of MkDocs and Material Theme with Python 3.14

Steps to reproduce

mkdocs build -s using latest version of MkDocs and Material Theme with Python 3.14

Note: I tried building the zip-file you want, but couldn't. This is a very straightforward issue with a clear 1 or 2 line solution.

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    resolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions