我在python 3.6.6 xmlrpc中发现了一个问题。如果我传递包含控制字符的字符串,例如'\ x1f',则xmlrpc.client无法正确封送它。是错误还是仅仅是对字符串参数的约束?
with xmlrpc.client.ServerProxy(uri, verbose=True) as proxy:
ret = proxy.func('\x1f')
send: b"<?xml version='1.0'?>\n<methodCall>\n<methodName>func</methodName>\n<params>\n<param>\n<value><string>\x1f</string></value>\n</param>\n</params>\n</methodCall>\n"
reply: 'HTTP/1.0 200 OK\r\n'
header: Server header: Date header: Content-type header: Content-length body: b"<?xml version='1.0'?>\n<methodResponse>\n<fault>\n<value><struct>\n<member>\n<name>faultCode</name>\n<value><int>1</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string><class 'xml.parsers.expat.ExpatError'>:not well-formed (invalid token): line 6, column 15</string></value>\n</member>\n</struct></value>\n</fault>\n</methodResponse>\n"
File "/usr/lib64/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/usr/lib64/python3.6/xmlrpc/client.py", line 1154, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib64/python3.6/xmlrpc/client.py", line 1170, in single_request
return self.parse_response(resp)
File "/usr/lib64/python3.6/xmlrpc/client.py", line 1342, in parse_response
return u.close()
File "/usr/lib64/python3.6/xmlrpc/client.py", line 656, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 1: "<class 'xml.parsers.expat.ExpatError'>:not well-formed (invalid token): line 6, column 15">