##// END OF EJS Templates
hgweb: hack around mimetypes encoding thinko (issue4160)...
Matt Mackall -
r20357:6863d42e stable
parent child Browse files
Show More
@@ -322,7 +322,20 b' def create_server(ui, app):'
322 322 cls = MercurialHTTPServer
323 323
324 324 # ugly hack due to python issue5853 (for threaded use)
325 import mimetypes; mimetypes.init()
325 try:
326 import mimetypes
327 mimetypes.init()
328 except UnicodeDecodeError:
329 # Python 2.x's mimetypes module attempts to decode strings
330 # from Windows' ANSI APIs as ascii (fail), then re-encode them
331 # as ascii (clown fail), because the default Python Unicode
332 # codec is hardcoded as ascii.
333
334 reload(sys) # resurrect sys.setdefaultencoding()
335 oldenc = sys.getdefaultencoding()
336 sys.setdefaultencoding("latin1") # or any full 8-bit encoding
337 mimetypes.init()
338 sys.setdefaultencoding(oldenc)
326 339
327 340 address = ui.config('web', 'address', '')
328 341 port = util.getport(ui.config('web', 'port', 8000))
General Comments 0
You need to be logged in to leave comments. Login now