我正在與金字塔框架,試圖向其發佈UTF8數據。 這裏是我得到的例外。我不知道如何解決這個問題。任何想法爲什麼它發生?金字塔請求:UnicodeDecodeError
mod_wsgi (pid=1389): Exception occurred processing WSGI script '/home/user/transcriptions/pyramid.wsgi'.
Traceback (most recent call last):
File "/home/user/transcriptions/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/router.py", line 187, in __call__
response = self.handle_request(request)
File "/home/user/transcriptions/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/tweens.py", line 20, in excview_tween
response = handler(request)
File "/home/user/transcriptions/lib/python2.7/site-packages/pyramid_tm-0.5-py2.7.egg/pyramid_tm/__init__.py", line 100, in tm_tween
response = handler(request)
File "/home/user/transcriptions/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/router.py", line 164, in handle_request
response = view_callable(context, request)
File "/home/user/transcriptions/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/config/views.py", line 333, in rendered_view
result = view(context, request)
File "/home/user/transcriptions/lib/python2.7/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/config/views.py", line 471, in _requestonly_view
response = view(request)
File "/home/user/transcriptions/transcriptions/frontend_views.py", line 179, in rpc_adduser
data = request.params
File "/home/user/transcriptions/lib/python2.7/site-packages/WebOb-1.2.1-py2.7.egg/webob/request.py", line 832, in params
params = NestedMultiDict(self.GET, self.POST)
File "/home/user/transcriptions/lib/python2.7/site-packages/WebOb-1.2.1-py2.7.egg/webob/request.py", line 783, in POST
vars = MultiDict.from_fieldstorage(fs)
File "/home/user/transcriptions/lib/python2.7/site-packages/WebOb-1.2.1-py2.7.egg/webob/multidict.py", line 74, in from_fieldstorage
obj.add(field.name, decode(field.value))
File "/home/user/transcriptions/lib/python2.7/site-packages/WebOb-1.2.1-py2.7.egg/webob/multidict.py", line 67, in <lambda>
decode = lambda b: b.decode('utf8')
File "/usr/lib/python2.6/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 6-8: invalid data
它窒息的字符串是「Venus \ xe4gen」。
我從具有這些屬性定義的HTML表單提交的數據:
<form name="form_reg" id="formtrans" method="post" action="signup"
content="text/html; charset=utf-8">
你想要發佈什麼?表單編碼數據中的某些內容是* not * UTF-8。你的'rpc_adduser'嘗試訪問'request.params' multidict結構,觸發表單數據的解碼並且解碼失敗。 –
我正在發佈一個HTML表單。具有該格式的HTML文件的字符集是UTF-8 – KennyPowers
您是否檢查過'request.body'?包含原始POST。 –