diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-11-22 04:53:57 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-11-22 04:53:57 (GMT) |
commit | d17ebdba4a4443a523c0344440d37d472ed82b5a (patch) | |
tree | 73014b8ca980538f33d2de4a6d4fc54909b15668 /Lib/urllib | |
parent | f30fd1078289dccc746d989264938ae23806ab38 (diff) | |
download | cpython-d17ebdba4a4443a523c0344440d37d472ed82b5a.zip cpython-d17ebdba4a4443a523c0344440d37d472ed82b5a.tar.gz cpython-d17ebdba4a4443a523c0344440d37d472ed82b5a.tar.bz2 |
Merged revisions 86676 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86676 | senthil.kumaran | 2010-11-22 12:48:26 +0800 (Mon, 22 Nov 2010) | 4 lines
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.
........
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/parse.py | 7 | ||||
-rw-r--r-- | Lib/urllib/request.py | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index b437d6f..cfd47f9 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -688,7 +688,12 @@ def splithost(url): _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 5a67c0b..7edfa1b 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -105,7 +105,7 @@ from urllib.response import addinfourl, addclosehook # check for SSL try: import ssl -except: +except ImportError: _have_ssl = False else: _have_ssl = True |