当我尝试运行我的jabber bot时出现此错误。
File "modules/xmpp/dispatcher.py", line 16, in Process
self.Stream.Parse(data)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc5 in position 32: invalid continuation byte
错误在此代码的第143行中:
def Process(self, timeout=0):
""" Check incoming stream for data waiting. If "timeout" is positive - block for as max. this time.
Returns:
1) length of processed data if some data were processed;
2) '0' string if no data were processed but link is alive;
3) 0 (zero) if underlying connection is closed.
Take note that in case of disconnection detect during Process() call
disconnect handlers are called automatically.
"""
for handler in self._cycleHandlers: handler(self)
if len(self._pendingExceptions) > 0:
_pendingException = self._pendingExceptions.pop()
raise _pendingException[0], _pendingException[1], _pendingException[2]
if self._owner.Connection.pending_data(timeout):
try: data=self._owner.Connection.receive()
except IOError: return
self.Stream.Parse(data)
if len(self._pendingExceptions) > 0:
_pendingException = self._pendingExceptions.pop()
raise _pendingException[0], _pendingException[1], _pendingException[2]
if data: return len(data)
return '0' # It means that nothing is received but link is alive.
它需要解码第16行中的data
字符串或什么?
请破解代码并解决我的问题..
答案 0 :(得分:0)
我会尝试self.Stream.Parse(data.encode('utf-8'))
,看看是否有效。