[issue38656] mimetypes for python 3.7.5 fails to detect matroska video

Florian Bruhin report at bugs.python.org
Mon Nov 18 04:47:13 EST 2019


Florian Bruhin <python.org at the-compiler.org> added the comment:

I'm seeing the same in ranger and I'm currently trying to debug this - I'm still
not quite sure what I'm seeing as there seem to be various issues/weirdnesses
which overlap each other.

This strikes me as odd:

>>> import mimetypes
>>> mimetypes.guess_type('E01.mkv')
('video/x-matroska', None)
>>> mimetypes.types_map['.mkv']
'video/x-matroska'

>>> mt = mimetypes.MimeTypes()
>>> mt.guess_type('E01.mkv')
(None, None)
>>> mt.types_map
({'.rtf': 'application/rtf', [redacted for brevity]}, {'.js': 'application/javascript', [redacted for brevity]})
>>> mt.types_map[0]['.mkv']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: '.mkv'
>>> mt.types_map[1]['.mkv']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: '.mkv'

The Python documentation claims: "This class represents a MIME-types database.
By default, it provides access to the same database as the rest of this module.
The initial database is a copy of that provided by the module" - yet that
apparently isn't the case.

I see this with both Python 3.7.5 and 3.8.0, but with 3.6.9 I get the correct
output for both module- and class-level access.

----------
nosy: +The Compiler

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38656>
_______________________________________


More information about the Python-bugs-list mailing list