Title: under windows - bad exception catch
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: mimetypes initialization fails on Windows because of non-Latin characters in registry
View: 9291
Assigned To: Nosy List: mclander, r.david.murray
Priority: normal Keywords:

Created on 2012-01-29 22:18 by mclander, last changed 2012-01-29 22:27 by r.david.murray. This issue is now closed.

Messages (2)
msg152267 - (view) Author: Alexander Maksimenko (mclander) Date: 2012-01-29 22:18 expectts Unicode*En*codeError, but Unicode*De*codeError happens when registry has non latin symbols (Vista Home 64).

I just change cathc jn next line to UnicodeDecodeError and all now works fine. But may be error not here, but on encode method which raise "negative" exception

F:\>c:\python27\python -m SimpleHTTPServer
Traceback (most recent call last):
  File "", line 2, in <module>
    import SimpleHTTPServer
  File "c:\python27\lib\", line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "c:\python27\lib\", line 204, in SimpleHTTPRequestHandler
    mimetypes.init() # try to read system mime.types
  File "c:\python27\lib\", line 355, in init
  File "c:\python27\lib\", line 259, in read_windows_registry
    for ctype in enum_types(mimedb):
  File "c:\python27\lib\", line 249, 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)

---------- here after changes -----------------

F:\>c:\python27\python -m SimpleHTTPServer
Serving HTTP on port 8000 ...
mc-quad - - [30/Jan/2012 02:02:18] "GET / HTTP/1.1" 200 -
mc-quad - - [30/Jan/2012 02:02:18] code 404, message File not found
mc-quad - - [30/Jan/2012 02:02:18] "GET /favicon.ico HTTP/1.1" 404 -
msg152268 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-01-29 22:27
This is a duplicate of issue 9291.
Date User Action Args
2012-01-29 22:27:56r.david.murraysetstatus: open -> closed

superseder: mimetypes initialization fails on Windows because of non-Latin characters in registry

nosy: + r.david.murray
messages: + msg152268
resolution: duplicate
stage: resolved
2012-01-29 22:18:06mclandercreate