Skip to content

Incorrect docs for mimetypes.MimeTypes.types_map #115075

Closed

Description

@maxnikulin

.. attribute:: MimeTypes.types_map
Tuple containing two dictionaries, mapping filename extensions to MIME types:
the first dictionary is for the non-standards types and the second one is for
the standard types. They are initialized by :data:`common_types` and
:data:`types_map`.

Notice

They are initialized by common_types and types_map.

The same is applicable for MimeTypes.types_map_inv. Try

import mimetypes

mimetypes.init()
mimetypes.types_map[".ae1"] = "application/pers.added"
db = mimetypes.MimeTypes()
print(db.types_map[True].get(".ae1"))

it reports

None

Accordingly to the docs I would expect application/pers.added. It can be achieved by commenting out the mimetypes.init() call.

I think, behavior changed when #49213 was fixed, but docs have not been updated.

I see some reason in the documented behavior. Perhaps mimetypes.init() should be more flexible and support both ways to set types_map: from the global dictionary and from the internal data, but likely it should be discussed on the pyhton-ideas mailing list first.

Linked PRs

Activity

  1. added a commit that references this issue on May 31, 2026
  2. serhiy-storchaka commented on May 31, 2026

    @serhiy-storchaka
    Member

    This behavior was so long, that it is now considered a new norm. We should just document it. Any changes of the behavior should be considered a new feature.

  3. added a commit that references this issue on Aug 30, 2026
  4. added 2 commits that reference this issue on Aug 30, 2026
  5. added a commit that references this issue on Aug 31, 2026
  6. added a commit that references this issue on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions