[issue9291] mimetypes initialization fails on Windows because of non-Latin characters in registry
Dmitry Jemerov
report at bugs.python.org
Sun Jul 18 13:54:55 CEST 2010
New submission from Dmitry Jemerov <intelliyole at gmail.com>:
On Windows, mimetypes initialization reads the list of MIME types from the Windows registry. It assumes that all characters are Latin-1 encoded, and fails when it's not the case, with the following exception:
Traceback (most recent call last):
File "mttest.py", line 3, in <module>
mimetypes.init()
File "c:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "c:\Python27\lib\mimetypes.py", line 260, in read_windows_registry
for ctype in enum_types(mimedb):
File "c:\Python27\lib\mimetypes.py", line 250, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
This can be reproduced, for example, on a Russian Windows XP installation which has QuickTime installed (QuickTime creates the non-Latin entries in the registry). The following line causes the exception to happen:
import mimetypes; mimetypes.init()
----------
components: Library (Lib), Windows
messages: 110637
nosy: Dmitry.Jemerov
priority: normal
severity: normal
status: open
title: mimetypes initialization fails on Windows because of non-Latin characters in registry
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9291>
_______________________________________
More information about the Python-bugs-list
mailing list