Fix Issue4493 - urllib2 adds '/' to the path component of url, when it does not
starts with one. This behavior is exhibited by browser and other clients.
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 2ddd281..78f3084 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -699,7 +699,12 @@
_hostprog = re.compile('^//([^/?]*)(.*)$')
match = _hostprog.match(url)
- if match: return match.group(1, 2)
+ if match:
+ host_port = match.group(1)
+ path = match.group(2)
+ if path and not path.startswith('/'):
+ path = '/' + path
+ return host_port, path
return None, url
_userprog = None
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index f3fb7be..fe66a67 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -105,7 +105,7 @@
# check for SSL
try:
import ssl
-except:
+except ImportError:
_have_ssl = False
else:
_have_ssl = True