summaryrefslogtreecommitdiff
path: root/Lib/xmlrpc
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xmlrpc')
-rw-r--r--Lib/xmlrpc/client.py34
-rw-r--r--Lib/xmlrpc/server.py25
2 files changed, 39 insertions, 20 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index bbf9ee63f7..bd3278e005 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
@@ -151,7 +152,7 @@ def escape(s):
return s.replace(">", ">",)
# used in User-Agent header sent
-__version__ = sys.version[:3]
+__version__ = '%d.%d' % sys.version_info[:2]
# xmlrpc integer limits
MAXINT = 2**31-1
@@ -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:
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index 7817693232..849bfddd84 100644
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -971,16 +971,15 @@ if __name__ == '__main__':
def getCurrentTime():
return datetime.datetime.now()
- server = SimpleXMLRPCServer(("localhost", 8000))
- server.register_function(pow)
- server.register_function(lambda x,y: x+y, 'add')
- server.register_instance(ExampleService(), allow_dotted_names=True)
- server.register_multicall_functions()
- print('Serving XML-RPC on localhost port 8000')
- print('It is advisable to run this example server within a secure, closed network.')
- try:
- server.serve_forever()
- except KeyboardInterrupt:
- print("\nKeyboard interrupt received, exiting.")
- server.server_close()
- sys.exit(0)
+ with SimpleXMLRPCServer(("localhost", 8000)) as server:
+ server.register_function(pow)
+ server.register_function(lambda x,y: x+y, 'add')
+ server.register_instance(ExampleService(), allow_dotted_names=True)
+ server.register_multicall_functions()
+ print('Serving XML-RPC on localhost port 8000')
+ print('It is advisable to run this example server within a secure, closed network.')
+ try:
+ server.serve_forever()
+ except KeyboardInterrupt:
+ print("\nKeyboard interrupt received, exiting.")
+ sys.exit(0)