PyUnit:无法读取XML-RPC请求:3字节UTF-8序列的字节2无效

时间:2012-03-12 21:17:15

标签: eclipse windows-7 python-unittest

当我从eclipse运行pyunit时,PyUnit视图没有更新,我有以下错误

Finding files... done.
Importing test modules ... done.

----------------------------------------------------------------------
Ran 1 tests in 0.000s

OK
Traceback (most recent call last):
  File "C:\Program Files\eclipse\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydev_runfiles_xml_rpc.py", line 131, in run
    self.server.notifyCommands(commands)
  File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\lib\xmlrpclib.py", line 1575, in __request
    verbose=self.__verbose
  File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "C:\Python27\lib\xmlrpclib.py", line 1473, in parse_response
    return u.close()
  File "C:\Python27\lib\xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
Fault: <Fault 0: 'Failed to read XML-RPC request: Invalid byte 2 of 3-byte UTF-8 sequence.'>

你知道导致这个错误的原因是什么吗?

2 个答案:

答案 0 :(得分:0)

问题是由对eclipse目录的访问权限不足(只读访问)引起的。 我授予安装目录的权限(修改),现在我没有这个错误。

答案 1 :(得分:0)

我也使用pyclipse与eclipse发现了这个错误。

我的问题是,在测试期间,尝试将一个utf-8字符串打印到pyunit控制台。转换字符串解决了问题:

问题代码:

print(my_Utf8_String)

修正:

print (unicode(my_Utf8_String).encode('utf8'))