-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
cpython/Doc/library/mimetypes.rst
Lines 213 to 218 in 13eb521
.. 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
andtypes_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
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir