summaryrefslogtreecommitdiffstats
path: root/Lib/xmlrpc/client.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-11 08:23:38 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-11 08:23:38 (GMT)
commit352601ca00376aaf07d4399096f985d3d8ecb96f (patch)
treedb43e391a0593aae173dcaa0cbea5f8f8ac84478 /Lib/xmlrpc/client.py
parent9fab79bcb5b83dc0247ce4cd60486341c73e7fd5 (diff)
downloadcpython-352601ca00376aaf07d4399096f985d3d8ecb96f.zip
cpython-352601ca00376aaf07d4399096f985d3d8ecb96f.tar.gz
cpython-352601ca00376aaf07d4399096f985d3d8ecb96f.tar.bz2
Issue #26885: xmlrpc now supports unmarshalling additional data types used
by Apache XML-RPC implementation for numerics and None.
Diffstat (limited to 'Lib/xmlrpc/client.py')
-rw-r--r--Lib/xmlrpc/client.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index 581a3b9..bd3278e 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -132,6 +132,7 @@ import base64
import sys
import time
from datetime import datetime
+from decimal import Decimal
import http.client
import urllib.parse
from xml.parsers import expat
@@ -667,6 +668,8 @@ class Unmarshaller:
def start(self, tag, attrs):
# prepare to handle this element
+ if ':' in tag:
+ tag = tag.split(':')[-1]
if tag == "array" or tag == "struct":
self._marks.append(len(self._stack))
self._data = []
@@ -682,9 +685,13 @@ class Unmarshaller:
try:
f = self.dispatch[tag]
except KeyError:
- pass # unknown tag ?
- else:
- return f(self, "".join(self._data))
+ if ':' not in tag:
+ return # unknown tag ?
+ try:
+ f = self.dispatch[tag.split(':')[-1]]
+ except KeyError:
+ return # unknown tag ?
+ return f(self, "".join(self._data))
#
# accelerator support
@@ -694,9 +701,13 @@ class Unmarshaller:
try:
f = self.dispatch[tag]
except KeyError:
- pass # unknown tag ?
- else:
- return f(self, data)
+ if ':' not in tag:
+ return # unknown tag ?
+ try:
+ f = self.dispatch[tag.split(':')[-1]]
+ except KeyError:
+ return # unknown tag ?
+ return f(self, data)
#
# element decoders
@@ -721,14 +732,23 @@ class Unmarshaller:
def end_int(self, data):
self.append(int(data))
self._value = 0
+ dispatch["i1"] = end_int
+ dispatch["i2"] = end_int
dispatch["i4"] = end_int
dispatch["i8"] = end_int
dispatch["int"] = end_int
+ dispatch["biginteger"] = end_int
def end_double(self, data):
self.append(float(data))
self._value = 0
dispatch["double"] = end_double
+ dispatch["float"] = end_double
+
+ def end_bigdecimal(self, data):
+ self.append(Decimal(data))
+ self._value = 0
+ dispatch["bigdecimal"] = end_bigdecimal
def end_string(self, data):
if self._encoding: