Message110637
| Author |
Dmitry.Jemerov |
| Recipients |
Dmitry.Jemerov |
| Date |
2010年07月18日.11:54:52 |
| SpamBayes Score |
0.000279033 |
| Marked as misclassified |
No |
| Message-id |
<1279454095.41.0.733053669611.issue9291@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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() |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年07月18日 11:54:55 | Dmitry.Jemerov | set | recipients:
+ Dmitry.Jemerov |
| 2010年07月18日 11:54:55 | Dmitry.Jemerov | set | messageid: <1279454095.41.0.733053669611.issue9291@psf.upfronthosting.co.za> |
| 2010年07月18日 11:54:53 | Dmitry.Jemerov | link | issue9291 messages |
| 2010年07月18日 11:54:52 | Dmitry.Jemerov | create |
|