diff -r 04e95f05aafe Lib/test/test_xmlrpc.py
--- a/Lib/test/test_xmlrpc.py Mon Jan 18 19:38:53 2016 +0200
+++ b/Lib/test/test_xmlrpc.py Mon Jan 18 20:21:19 2016 +0200
@@ -149,7 +149,7 @@ class XMLRPCTestCase(unittest.TestCase):
@test_support.requires_unicode
def test_dump_encoding(self):
- value = unichr(0x20ac)
+ value = unichr(0x20ac) + unichr(0xa4)
strg = xmlrpclib.dumps((value,), encoding='iso-8859-15')
strg = "" + strg
self.assertEqual(xmlrpclib.loads(strg)[0][0], value)
@@ -496,7 +496,7 @@ class SimpleServerTestCase(BaseServerTes
@test_support.requires_unicode
def test_client_encoding(self):
start_string = unichr(0x20ac)
- end_string = unichr(0xa3)
+ end_string = unichr(0xa4)
try:
p = xmlrpclib.ServerProxy(URL, encoding='iso-8859-15')
@@ -635,7 +635,7 @@ class SimpleServerEncodingTestCase(BaseS
@test_support.requires_unicode
def test_server_encoding(self):
start_string = unichr(0x20ac)
- end_string = unichr(0xa3)
+ end_string = unichr(0xa4)
try:
p = xmlrpclib.ServerProxy(URL)
diff -r 04e95f05aafe Lib/xmlrpclib.py
--- a/Lib/xmlrpclib.py Mon Jan 18 19:38:53 2016 +0200
+++ b/Lib/xmlrpclib.py Mon Jan 18 20:21:19 2016 +0200
@@ -703,9 +703,8 @@ class Marshaller:
if unicode:
def dump_unicode(self, value, write, escape=escape):
- value = value.encode(self.encoding)
write("")
- write(escape(value))
+ write(escape(value).encode(self.encoding, 'xmlcharrefreplace'))
write("\n")
dispatch[UnicodeType] = dump_unicode
@@ -732,12 +731,13 @@ class Marshaller:
write("\n")
for k, v in value.items():
write("\n")
- if type(k) is not StringType:
- if unicode and type(k) is UnicodeType:
- k = k.encode(self.encoding)
- else:
- raise TypeError, "dictionary key must be string"
- write("%s\n" % escape(k))
+ if type(k) is StringType:
+ k = escape(k)
+ elif unicode and type(k) is UnicodeType:
+ k = escape(k).encode(self.encoding, 'xmlcharrefreplace')
+ else:
+ raise TypeError, "dictionary key must be string"
+ write("%s\n" % k)
dump(v, write)
write("\n")
write("\n")
@@ -1099,7 +1099,7 @@ def dumps(params, methodname=None, metho
if methodname:
# a method call
if not isinstance(methodname, StringType):
- methodname = methodname.encode(encoding)
+ methodname = methodname.encode(encoding, 'xmlcharrefreplace')
data = (
xmlheader,
"\n"