diff options
author | Jay Pipes <jaypipes@gmail.com> | 2013-12-05 23:03:01 -0500 |
---|---|---|
committer | Jay Pipes <jaypipes@gmail.com> | 2013-12-05 23:03:01 -0500 |
commit | 4ad655eb9cecec931b92a894538f92306b438af4 (patch) | |
tree | be7b457b55d0e4473930920bd8e2918071ac660e | |
parent | a2ff39f478438a095a042d1c8f496a3a2e02bcfc (diff) | |
download | oslo-serialization-4ad655eb9cecec931b92a894538f92306b438af4.tar.gz |
Python3 support for xmlrpclib
Python3 actually does include xmlrpc(lib). It's just called
xmlrpc.client. The class and function signatures are the
same as the old Python2.x xmlrpclib module.
Adds a note that six.moves should be used once six 1.4.2 is
released. See http://bit.ly/1bqrVzu.
References:
Python 2 xmprpllib doc: http://docs.python.org/2/library/xmlrpclib.html
Python 3 xmlrpc.client doc: http://docs.python.org/3/library/xmlrpc.client.html
Change-Id: I478b56f22d02350a21093a887d9f6fcb84958724
-rw-r--r-- | openstack/common/jsonutils.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/openstack/common/jsonutils.py b/openstack/common/jsonutils.py index cd4479a..a5f5c12 100644 --- a/openstack/common/jsonutils.py +++ b/openstack/common/jsonutils.py @@ -39,8 +39,12 @@ import json try: import xmlrpclib except ImportError: - # NOTE(jd): xmlrpclib is not shipped with Python 3 - xmlrpclib = None + # NOTE(jaypipes): xmlrpclib was renamed to xmlrpc.client in Python3 + # however the function and object call signatures + # remained the same. This whole try/except block should + # be removed and replaced with a call to six.moves once + # six 1.4.2 is released. See http://bit.ly/1bqrVzu + import xmlrpc.client as xmlrpclib import six @@ -129,7 +133,7 @@ def to_primitive(value, convert_instances=False, convert_datetime=True, # It's not clear why xmlrpclib created their own DateTime type, but # for our purposes, make it a datetime type which is explicitly # handled - if xmlrpclib and isinstance(value, xmlrpclib.DateTime): + if isinstance(value, xmlrpclib.DateTime): value = datetime.datetime(*tuple(value.timetuple())[:6]) if convert_datetime and isinstance(value, datetime.datetime): |