From 5fa6cb571e6f8c47998b188d749e3d3daf90f1db Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 5 Sep 2019 22:51:15 +0900 Subject: [PATCH 1/3] bpo-38038: Remove urllib.parse._xxxx fromxmlrpc.client. --- Lib/xmlrpc/client.py | 12 +++++++----- .../Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index b4b2941ea5b407..1ac2e30d620608 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1220,7 +1220,9 @@ def get_host_info(self, host): if isinstance(host, tuple): host, x509 = host - auth, host = urllib.parse._splituser(host) + p = urllib.parse.urlparse(host) + user, delim, host = p.path.rpartition('@') + auth = user if delim else None if auth: auth = urllib.parse.unquote_to_bytes(auth) @@ -1421,15 +1423,15 @@ def __init__(self, uri, transport=None, encoding=None, verbose=False, # establish a "logical" server connection # get the url - type, uri = urllib.parse._splittype(uri) - if type not in ("http", "https"): + p = urllib.parse.urlparse(uri) + if p.scheme not in ("http", "https"): raise OSError("unsupported XML-RPC protocol") - self.__host, self.__handler = urllib.parse._splithost(uri) + self.__host, self.__handler = p.netloc, p.path if not self.__handler: self.__handler = "/RPC2" if transport is None: - if type == "https": + if p.scheme == "https": handler = SafeTransport extra_kwargs = {"context": context} else: diff --git a/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst b/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst new file mode 100644 index 00000000000000..df7912970c089e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst @@ -0,0 +1,2 @@ +Remove urllib.parse._splituser and urllib.parse._splittype from +xmlrpc.client. Patch by Dong-hee Na. From b7935035733f80cda1d4588f4cd00ec8658d547a Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Fri, 6 Sep 2019 01:19:16 +0900 Subject: [PATCH 2/3] Update code --- Lib/xmlrpc/client.py | 4 +--- .../next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index 1ac2e30d620608..67b6c6c820889b 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1220,9 +1220,7 @@ def get_host_info(self, host): if isinstance(host, tuple): host, x509 = host - p = urllib.parse.urlparse(host) - user, delim, host = p.path.rpartition('@') - auth = user if delim else None + auth, host = urllib.parse._splituser(host) if auth: auth = urllib.parse.unquote_to_bytes(auth) diff --git a/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst b/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst index df7912970c089e..b77346ea3759ec 100644 --- a/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst +++ b/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst @@ -1,2 +1,2 @@ -Remove urllib.parse._splituser and urllib.parse._splittype from -xmlrpc.client. Patch by Dong-hee Na. +Remove urllib.parse._splittype from :meth:`__init__` of +:class:`xmlrpc.client.ServerProxy`. Patch by Dong-hee Na. From eca5086d21c3f7497c25417cdd5de07209835550 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sun, 8 Sep 2019 02:59:27 +0900 Subject: [PATCH 3/3] bpo-38038: Apply codereview --- Lib/xmlrpc/client.py | 5 ++--- .../next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index 67b6c6c820889b..d15d60d2937a82 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1424,9 +1424,8 @@ def __init__(self, uri, transport=None, encoding=None, verbose=False, p = urllib.parse.urlparse(uri) if p.scheme not in ("http", "https"): raise OSError("unsupported XML-RPC protocol") - self.__host, self.__handler = p.netloc, p.path - if not self.__handler: - self.__handler = "/RPC2" + self.__host = p.netloc + self.__handler = p.path or "/RPC2" if transport is None: if p.scheme == "https": diff --git a/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst b/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst deleted file mode 100644 index b77346ea3759ec..00000000000000 --- a/Misc/NEWS.d/next/Library/2019-09-05-23-21-33.bpo-38038.--6YvP.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove urllib.parse._splittype from :meth:`__init__` of -:class:`xmlrpc.client.ServerProxy`. Patch by Dong-hee Na.