mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-22 23:24:44 +00:00
Merge pull request #231 from cjmayo/python3_21
{python3_21} fix urllib imports
This commit is contained in:
commit
2bdd155d56
2 changed files with 10 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue