[bridgedb/master] Urllib removed its splithost function

commit 37464528094a5a70bc65860879f45e93b6b8d0ac Author: Damian Johnson <atagar@torproject.org> Date: Sat Jan 18 16:39:56 2020 -0800 Urllib removed its splithost function Urllib's documentation said to avoid splithost, and the method was removed in python 3.... https://docs.python.org/2/library/urllib.html This fixes... Traceback (most recent call last): File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_crypto.py", line 379, in test_verifyHostname_matching contextFactory = crypto.SSLVerifyingContextFactory(url) File "/home/atagar/Desktop/tor/bridgedb/bridgedb/crypto.py", line 377, in __init__ self.hostname = self.getHostnameFromURL(url) File "/home/atagar/Desktop/tor/bridgedb/bridgedb/crypto.py", line 413, in getHostnameFromURL hostname = urllib.splithost(urllib.splittype(url)[1])[0] builtins.AttributeError: module 'urllib' has no attribute 'splithost' Test results changed as follows... before: FAILED (skips=114, failures=21, errors=57, successes=792) after: FAILED (skips=114, failures=21, errors=55, successes=794) --- bridgedb/crypto.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridgedb/crypto.py b/bridgedb/crypto.py index 5b1912f..1aee089 100644 --- a/bridgedb/crypto.py +++ b/bridgedb/crypto.py @@ -47,7 +47,7 @@ import io import logging import os import re -import urllib +import urllib.parse import OpenSSL @@ -410,7 +410,8 @@ class SSLVerifyingContextFactory(ssl.CertificateOptions): :rtype: str :returns: The full hostname (including any subdomains). """ - hostname = urllib.splithost(urllib.splittype(url)[1])[0] + + hostname = urllib.parse.urlparse(url).netloc logging.debug("Parsed hostname %r for cert CN matching." % hostname) return hostname
participants (1)
-
phw@torproject.org