Merge pull request #231 from cjmayo/python3_21

{python3_21} fix urllib imports
This commit is contained in:
anarcat 2019-04-11 11:47:50 -04:00 committed by GitHub
commit 2bdd155d56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -25,7 +25,10 @@ try:
except ImportError:
# Python 3
from urllib import parse as urlparse
import urllib
try: # Python 3
from urllib import request as urlrequest
except ImportError:
import urllib as urlrequest
try:
from urllib2 import urlopen
except ImportError:
@ -79,7 +82,7 @@ def get_os_filename (path):
"""Return filesystem path for given URL path."""
if os.name == 'nt':
path = prepare_urlpath_for_nt(path)
res = urllib.url2pathname(fileutil.pathencode(path))
res = urlrequest.url2pathname(fileutil.pathencode(path))
if os.name == 'nt' and res.endswith(':') and len(res) == 2:
# Work around http://bugs.python.org/issue11474
res += os.sep

View file

@ -24,6 +24,10 @@ try:
except ImportError:
# Python 3
from urllib import parse as urlparse
try:
from urllib import splituser
except ImportError: # Python 3
from urllib.parse import splituser
try:
from urllib2 import urlopen
except ImportError:
@ -392,7 +396,7 @@ class UrlBase (object):
Also checks for obfuscated IP addresses.
"""
# check userinfo@host:port syntax
self.userinfo, host = urllib.splituser(self.urlparts[1])
self.userinfo, host = splituser(self.urlparts[1])
port = urlutil.default_ports.get(self.scheme, 0)
host, port = urlutil.splitport(host, port=port)
if port is None: