format在python3_Python3 在使用traceback.format_exc()的时候遇到 UnicodeDecodeError

RT,怎么回事?

try:

xxxxx

except:

import traceback

ret['response-head']['msg'] = traceback.format_exc(1)

KeyError: '56 '

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/python3.3/lib/python3.3/site-packages/Django-1.5-py3.3.egg/django/core/handlers/base.py", line 115, in get_response

response = callback(request, *callback_args, **callback_kwargs)

File "./videoDetectWebsite/views/index.py", line 113, in api

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 270, in format_exc

format_exception(etype, value, tb, limit, chain))

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 187, in format_exception

list.extend(format_tb(tb, limit))

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 75, in format_tb

return format_list(extract_tb(tb, limit))

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 100, in extract_tb

line = linecache.getline(filename, lineno, f.f_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 15, in getline

lines = getlines(filename, module_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 41, in getlines

return updatecache(filename, module_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 127, in updatecache

lines = fp.readlines()

File "/usr/local/python3.3/lib/python3.3/codecs.py", line 300, in decode

(result, consumed) = self._buffer_decode(data, self.errors, final)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 205: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 936, in emit

msg = self.format(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 807, in format

return fmt.format(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 554, in format

record.exc_text = self.formatException(record.exc_info)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 504, in formatException

traceback.print_exception(ei[0], ei[1], tb, None, sio)

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 162, in print_exception

print_tb(tb, limit, file)

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 68, in print_tb

line = linecache.getline(filename, lineno, f.f_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 15, in getline

lines = getlines(filename, module_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 41, in getlines

return updatecache(filename, module_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 127, in updatecache

lines = fp.readlines()

File "/usr/local/python3.3/lib/python3.3/codecs.py", line 300, in decode

(result, consumed) = self._buffer_decode(data, self.errors, final)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 205: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/usr/local/python3.3/lib/python3.3/site-packages/Django-1.5-py3.3.egg/django/core/handlers/wsgi.py", line 255, in __call__

response = self.get_response(request)

File "/usr/local/python3.3/lib/python3.3/site-packages/Django-1.5-py3.3.egg/django/core/handlers/base.py", line 178, in get_response

response = self.handle_uncaught_exception(request, resolver, sys.exc_info())

File "/usr/local/python3.3/lib/python3.3/site-packages/Django-1.5-py3.3.egg/django/core/handlers/base.py", line 212, in handle_uncaught_exception

'request': request

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 1260, in error

self._log(ERROR, msg, args, **kwargs)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 1366, in _log

self.handle(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 1376, in handle

self.callHandlers(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 1438, in callHandlers

hdlr.handle(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 832, in handle

self.emit(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 944, in emit

self.handleError(record)

File "/usr/local/python3.3/lib/python3.3/logging/__init__.py", line 885, in handleError

None, sys.stderr)

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 162, in print_exception

print_tb(tb, limit, file)

File "/usr/local/python3.3/lib/python3.3/traceback.py", line 68, in print_tb

line = linecache.getline(filename, lineno, f.f_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 15, in getline

lines = getlines(filename, module_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 41, in getlines

return updatecache(filename, module_globals)

File "/usr/local/python3.3/lib/python3.3/linecache.py", line 127, in updatecache

lines = fp.readlines()

File "/usr/local/python3.3/lib/python3.3/codecs.py", line 300, in decode

(result, consumed) = self._buffer_decode(data, self.errors, final)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 205: invalid start byte

[pid: 12907|app: 0|req: 1/1] 118.192.22.212 () {44 vars in 733 bytes} [Sat Jun 8 08:13:39 2013] POST /api/huohuaId2Url => generated 0 bytes in 550 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值