mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
Merged revisions 80362 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80362 | senthil.kumaran | 2010-04-22 17:40:13 +0530 (Thu, 22 Apr 2010) | 4 lines Changed tests to only urlparse one, which was enough, addressed Ezio's comment on Invalid url check statement and versionchanged string in docs. ........
This commit is contained in:
parent
dcb2403022
commit
7a1e09f60c
3 changed files with 12 additions and 11 deletions
|
|
@ -88,6 +88,9 @@ The :mod:`urllib.parse` module defines the following functions:
|
||||||
See section :ref:`urlparse-result-object` for more information on the result
|
See section :ref:`urlparse-result-object` for more information on the result
|
||||||
object.
|
object.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.2
|
||||||
|
Added IPv6 URL parsing capabilities.
|
||||||
|
|
||||||
|
|
||||||
.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False)
|
.. function:: parse_qs(qs, keep_blank_values=False, strict_parsing=False)
|
||||||
|
|
||||||
|
|
@ -329,7 +332,7 @@ The :mod:`urllib.parse` module defines the following functions:
|
||||||
:rfc:`3986` - Uniform Resource Identifiers
|
:rfc:`3986` - Uniform Resource Identifiers
|
||||||
This is the current standard (STD66). Any changes to urlparse module
|
This is the current standard (STD66). Any changes to urlparse module
|
||||||
should conform to this. Certain deviations could be observed, which are
|
should conform to this. Certain deviations could be observed, which are
|
||||||
mostly due backward compatiblity purposes and for certain to de-facto
|
mostly due backward compatiblity purposes and for certain de-facto
|
||||||
parsing requirements as commonly observed in major browsers.
|
parsing requirements as commonly observed in major browsers.
|
||||||
|
|
||||||
:rfc:`2732` - Format for Literal IPv6 Addresses in URL's.
|
:rfc:`2732` - Format for Literal IPv6 Addresses in URL's.
|
||||||
|
|
|
||||||
|
|
@ -273,10 +273,10 @@ class UrlParseTestCase(unittest.TestCase):
|
||||||
for invalid_url in [
|
for invalid_url in [
|
||||||
'http://::12.34.56.78]/',
|
'http://::12.34.56.78]/',
|
||||||
'http://[::1/foo/',
|
'http://[::1/foo/',
|
||||||
|
'ftp://[::1/foo/bad]/bad',
|
||||||
'http://[::1/foo/bad]/bad',
|
'http://[::1/foo/bad]/bad',
|
||||||
'http://[::ffff:12.34.56.78']:
|
'http://[::ffff:12.34.56.78']:
|
||||||
self.assertRaises(ValueError, lambda : urllib.parse.urlparse(invalid_url).hostname)
|
self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)
|
||||||
self.assertRaises(ValueError, lambda : urllib.parse.urlparse(invalid_url))
|
|
||||||
|
|
||||||
def test_urldefrag(self):
|
def test_urldefrag(self):
|
||||||
for url, defrag, frag in [
|
for url, defrag, frag in [
|
||||||
|
|
|
||||||
|
|
@ -181,10 +181,9 @@ def urlsplit(url, scheme='', allow_fragments=True):
|
||||||
url = url[i+1:]
|
url = url[i+1:]
|
||||||
if url[:2] == '//':
|
if url[:2] == '//':
|
||||||
netloc, url = _splitnetloc(url, 2)
|
netloc, url = _splitnetloc(url, 2)
|
||||||
if '[' in netloc :
|
if (('[' in netloc and ']' not in netloc) or
|
||||||
if not ']' in netloc: raise ValueError("Invalid IPv6 URL")
|
(']' in netloc and '[' not in netloc)):
|
||||||
if ']' in netloc:
|
raise ValueError("Invalid IPv6 URL")
|
||||||
if not '[' in netloc: raise ValueError("Invalid IPv6 URL")
|
|
||||||
if allow_fragments and '#' in url:
|
if allow_fragments and '#' in url:
|
||||||
url, fragment = url.split('#', 1)
|
url, fragment = url.split('#', 1)
|
||||||
if '?' in url:
|
if '?' in url:
|
||||||
|
|
@ -199,10 +198,9 @@ def urlsplit(url, scheme='', allow_fragments=True):
|
||||||
scheme, url = url[:i].lower(), url[i+1:]
|
scheme, url = url[:i].lower(), url[i+1:]
|
||||||
if url[:2] == '//':
|
if url[:2] == '//':
|
||||||
netloc, url = _splitnetloc(url, 2)
|
netloc, url = _splitnetloc(url, 2)
|
||||||
if '[' in netloc:
|
if (('[' in netloc and ']' not in netloc) or
|
||||||
if not ']' in netloc: raise ValueError("Invalid IPv6 URL")
|
(']' in netloc and '[' not in netloc)):
|
||||||
if ']' in netloc:
|
raise ValueError("Invalid IPv6 URL")
|
||||||
if not '[' in netloc: raise ValueError("Invalid IPv6 URL")
|
|
||||||
if allow_fragments and scheme in uses_fragment and '#' in url:
|
if allow_fragments and scheme in uses_fragment and '#' in url:
|
||||||
url, fragment = url.split('#', 1)
|
url, fragment = url.split('#', 1)
|
||||||
if scheme in uses_query and '?' in url:
|
if scheme in uses_query and '?' in url:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue