Python的一个bug,记录一下
安装报错:
E:\webpy-master>python setup.py install
Traceback (most recent call last):
File "setup.py", line 6, in <module>
from web import __version__
File "E:\webpy-master\web\__init__.py", line 14, in <module>
import utils, db, net, wsgi, http, webapi, httpserver, debugerror
File "E:\webpy-master\web\wsgi.py", line 12, in <module>
import httpserver
File "E:\webpy-master\web\httpserver.py", line 4, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHand
ler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 9: ordinal
not in range(128)
bug:http://bugs.python.org/issue10490
patch地址:http://bugs.python.org/file19746/mimetypes-patch2-2.7.patch
patch:
Index: release27-maint/Lib/mimetypes.py
===================================================================
--- release27-maint/Lib/mimetypes.py (revision 86639)
+++ release27-maint/Lib/mimetypes.py (working copy)
@@ -245,12 +245,7 @@
ctype = _winreg.EnumKey(mimedb, i)
except EnvironmentError:
break
- try:
- ctype = ctype.encode(default_encoding) # omit in 3.x!
- except UnicodeEncodeError:
- pass
- else:
- yield ctype
+ yield ctype
i += 1
default_encoding = sys.getdefaultencoding()
浙公网安备 33010602011771号