From f86d57bfe18254037997f7f19b08564ee8cfe16c Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sun, 23 Feb 2020 18:19:19 -0500 Subject: [PATCH 01/11] Added documentation fixes --- Doc/library/urllib.parse.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index 02f0c01e224ddf8..9945adebcb86159 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -37,11 +37,12 @@ URL Parsing The URL parsing functions focus on splitting a URL string into its components, or on combining URL components into a URL string. -.. function:: urlparse(urlstring, scheme='', allow_fragments=True) +.. function:: urlparse(url, scheme='', allow_fragments=True) Parse a URL into six components, returning a 6-item :term:`named tuple`. This corresponds to the general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``. + Each tuple item is a string, possibly empty. The components are not broken up into smaller parts (for example, the network location is a single string), and % escapes are not expanded. The delimiters as shown above are not part of the @@ -81,7 +82,7 @@ or on combining URL components into a URL string. The *scheme* argument gives the default addressing scheme, to be used only if the URL does not specify one. It should be the same type - (text or bytes) as *urlstring*, except that the default value ``''`` is + (text or bytes) as *url*, except that the default value ``''`` is always allowed, and is automatically converted to ``b''`` if appropriate. If the *allow_fragments* argument is false, fragment identifiers are not @@ -245,7 +246,7 @@ or on combining URL components into a URL string. states that these are equivalent). -.. function:: urlsplit(urlstring, scheme='', allow_fragments=True) +.. function:: urlsplit(url, scheme='', allow_fragments=True) This is similar to :func:`urlparse`, but does not split the params from the URL. This should generally be used instead of :func:`urlparse` if the more recent URL From ece6c2f6276f8bbfd614649a0f8ced06af55e4c9 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sun, 15 Mar 2020 10:11:52 -0400 Subject: [PATCH 02/11] Fixing rst comment + Merging master --- Doc/library/urllib.parse.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index 9945adebcb86159..a736de71886c986 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -43,11 +43,12 @@ or on combining URL components into a URL string. corresponds to the general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``. - Each tuple item is a string, possibly empty. The components are not broken up - into smaller parts (for example, the network location is a single string), and % - escapes are not expanded. The delimiters as shown above are not part of the - result, except for a leading slash in the *path* component, which is retained if - present. For example: + Each tuple item is a string, possibly empty. The components are broken up into + smaller parts (for example, the components of the network location variable - + username, password, hostname, and port - are available as extra attributes in the + ParseResult/ParseResultBytes object). % escapes are not expanded. + The delimiters as shown above are not part of the result, except for a leading slash + in the *path* component, which is retained if present. For example: >>> from urllib.parse import urlparse >>> o = urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') @@ -248,7 +249,9 @@ or on combining URL components into a URL string. .. function:: urlsplit(url, scheme='', allow_fragments=True) - This is similar to :func:`urlparse`, but does not split the params from the URL. + This is similar to :func:`urlparse`, the returned SplitResult/SplitResultBytes object + will split the parameters from the URL, for example, the components of the network location + variable - username, password, hostname, and port - are available as extra attributes. This should generally be used instead of :func:`urlparse` if the more recent URL syntax allowing parameters to be applied to each segment of the *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function is needed to From c2e2b1025c91048cd211cf27b0e999a2ce2a6f46 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sun, 22 Mar 2020 17:35:41 -0400 Subject: [PATCH 03/11] Edited the description and pulled master --- Doc/library/urllib.parse.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index a736de71886c986..b5b68ffd4dd0a3b 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -43,12 +43,11 @@ or on combining URL components into a URL string. corresponds to the general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``. - Each tuple item is a string, possibly empty. The components are broken up into - smaller parts (for example, the components of the network location variable - - username, password, hostname, and port - are available as extra attributes in the - ParseResult/ParseResultBytes object). % escapes are not expanded. - The delimiters as shown above are not part of the result, except for a leading slash - in the *path* component, which is retained if present. For example: + Each of the above tuple items is used as-is for the tuple fields. Only the netloc item + is broken down into: username, password, hostname, and port. These are added as additional + attributes of the returned object. % escapes are not expanded. The delimiters as shown above + are not part of the result, except for a leading slash in the *path* component, which is + retained if present. For example: >>> from urllib.parse import urlparse >>> o = urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') From 1ea442d19e7eb6cd89e9a731679b0c939aa0eaa0 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Mon, 25 May 2020 10:10:37 -0400 Subject: [PATCH 04/11] Added correct description --- Doc/library/urllib.parse.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index b5b68ffd4dd0a3b..378e630f1c54e2f 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -43,11 +43,15 @@ or on combining URL components into a URL string. corresponds to the general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``. - Each of the above tuple items is used as-is for the tuple fields. Only the netloc item - is broken down into: username, password, hostname, and port. These are added as additional - attributes of the returned object. % escapes are not expanded. The delimiters as shown above - are not part of the result, except for a leading slash in the *path* component, which is - retained if present. For example: + The delimiters as shown above are not part of the result, except for a leading slash in the path + component, which is retained if present. + + Additionally, the netloc property is broken down into these additional attributes added to + the returned object: username, password, hostname, and port. + + % escapes are not decoded. + + For example: >>> from urllib.parse import urlparse >>> o = urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') From c393c5fda1a37e507798bed2f7ca38a2d0405796 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Mon, 25 May 2020 10:54:40 -0400 Subject: [PATCH 05/11] Changed the urlsplit doc as well --- Doc/library/urllib.parse.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index 378e630f1c54e2f..fd6a4c72e7a9fe4 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -252,9 +252,16 @@ or on combining URL components into a URL string. .. function:: urlsplit(url, scheme='', allow_fragments=True) - This is similar to :func:`urlparse`, the returned SplitResult/SplitResultBytes object - will split the parameters from the URL, for example, the components of the network location - variable - username, password, hostname, and port - are available as extra attributes. + Parse a URL into six components, returning a 6-item :term:`named tuple`. This + corresponds to the general structure of a URL: + ``scheme://netloc/path;parameters?query#fragment``. + + The delimiters as shown above are not part of the result, except for a leading slash in the path + component, which is retained if present. + + Additionally, the netloc property is broken down into these additional attributes added to + the returned object: username, password, hostname, and port. + This should generally be used instead of :func:`urlparse` if the more recent URL syntax allowing parameters to be applied to each segment of the *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function is needed to From 7596c94336631ce8aacf3f096ecdeb7b0352913a Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Fri, 5 Jun 2020 08:34:39 -0400 Subject: [PATCH 06/11] Fixed URL split to the right description --- Doc/library/urllib.parse.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index fd6a4c72e7a9fe4..ed9c5ffaa78231e 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -252,9 +252,11 @@ or on combining URL components into a URL string. .. function:: urlsplit(url, scheme='', allow_fragments=True) - Parse a URL into six components, returning a 6-item :term:`named tuple`. This + Similar to :func:`urlparse`, witout splitting the URL parameters. + + Parse a URL into five components, returning a 5-item :term:`named tuple`. This corresponds to the general structure of a URL: - ``scheme://netloc/path;parameters?query#fragment``. + ``scheme://netloc/path?query#fragment``. The delimiters as shown above are not part of the result, except for a leading slash in the path component, which is retained if present. @@ -266,9 +268,7 @@ or on combining URL components into a URL string. syntax allowing parameters to be applied to each segment of the *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function is needed to separate the path segments and parameters. This function returns a 5-item - :term:`named tuple`:: - - (addressing scheme, network location, path, query, fragment identifier). + :term:`named tuple`:: (addressing scheme, network location, path, query, fragment identifier). The return value is a :term:`named tuple`, its items can be accessed by index or as named attributes: From 0ceb65ae4d04ecf712405f6f4feb73e7dfbb82ea Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Fri, 5 Jun 2020 08:43:08 -0400 Subject: [PATCH 07/11] Fixed URL split to the right description --- Doc/library/urllib.parse.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index ed9c5ffaa78231e..24117e311ce1d6e 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -264,11 +264,22 @@ or on combining URL components into a URL string. Additionally, the netloc property is broken down into these additional attributes added to the returned object: username, password, hostname, and port. + % escapes are not decoded. + + The *scheme* argument gives the default addressing scheme, to be + used only if the URL does not specify one. It should be the same type + (text or bytes) as *url*, except that the default value ``''`` is + always allowed, and is automatically converted to ``b''`` if appropriate. + + If the *allow_fragments* argument is false, fragment identifiers are not + recognized. Instead, they are parsed as part of the path, parameters + or query component, and :attr:`fragment` is set to the empty string in + the return value. + This should generally be used instead of :func:`urlparse` if the more recent URL syntax allowing parameters to be applied to each segment of the *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function is needed to - separate the path segments and parameters. This function returns a 5-item - :term:`named tuple`:: (addressing scheme, network location, path, query, fragment identifier). + separate the path segments and parameters. The return value is a :term:`named tuple`, its items can be accessed by index or as named attributes: From f5b626e07535e339dd2708be42391a554dda6624 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sat, 27 Jun 2020 14:13:21 -0400 Subject: [PATCH 08/11] Fixed typo + reverted the url parse last section --- Doc/library/urllib.parse.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index 24117e311ce1d6e..a32b60916361a43 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -252,14 +252,14 @@ or on combining URL components into a URL string. .. function:: urlsplit(url, scheme='', allow_fragments=True) - Similar to :func:`urlparse`, witout splitting the URL parameters. + Similar to :func:`urlparse`, without splitting the URL parameters. - Parse a URL into five components, returning a 5-item :term:`named tuple`. This - corresponds to the general structure of a URL: + Parse a URL into five components, returning a 5-item :term:`named tuple`. + This corresponds to the general structure of a URL: ``scheme://netloc/path?query#fragment``. - The delimiters as shown above are not part of the result, except for a leading slash in the path - component, which is retained if present. + The delimiters as shown above are not part of the result, except for a + leading slash in the path component, which is retained if present. Additionally, the netloc property is broken down into these additional attributes added to the returned object: username, password, hostname, and port. @@ -276,10 +276,14 @@ or on combining URL components into a URL string. or query component, and :attr:`fragment` is set to the empty string in the return value. + This is similar to :func:`urlparse`, but does not split the params from the URL. This should generally be used instead of :func:`urlparse` if the more recent URL syntax allowing parameters to be applied to each segment of the *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function is needed to - separate the path segments and parameters. + separate the path segments and parameters. This function returns a 5-item + :term:`named tuple`:: + + (addressing scheme, network location, path, query, fragment identifier). The return value is a :term:`named tuple`, its items can be accessed by index or as named attributes: From cc2e202b2788c618a99d37b4f18752f8ea95efb5 Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sun, 28 Jun 2020 10:20:50 -0400 Subject: [PATCH 09/11] Wrapped text to 80 chars --- Doc/library/urllib.parse.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index a32b60916361a43..6bf1be8b77da52e 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -39,15 +39,16 @@ or on combining URL components into a URL string. .. function:: urlparse(url, scheme='', allow_fragments=True) - Parse a URL into six components, returning a 6-item :term:`named tuple`. This - corresponds to the general structure of a URL: + Parse a URL into six components, returning a 6-item :term:`named tuple`. + This corresponds to the general structure of a URL: ``scheme://netloc/path;parameters?query#fragment``. - The delimiters as shown above are not part of the result, except for a leading slash in the path - component, which is retained if present. + The delimiters as shown above are not part of the result, except for a + leading slash in the path component, which is retained if present. - Additionally, the netloc property is broken down into these additional attributes added to - the returned object: username, password, hostname, and port. + Additionally, the netloc property is broken down into these additional + attributes added to the returned object: username, password, hostname, and + port. % escapes are not decoded. From bf774a3a8726565e25c8c017d00e18d93427b2da Mon Sep 17 00:00:00 2001 From: Ido Michael Date: Sun, 28 Jun 2020 10:23:17 -0400 Subject: [PATCH 10/11] Wrapped text to 80 chars --- Doc/library/urllib.parse.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index 6bf1be8b77da52e..0e3a116d8bfcf26 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -262,8 +262,9 @@ or on combining URL components into a URL string. The delimiters as shown above are not part of the result, except for a leading slash in the path component, which is retained if present. - Additionally, the netloc property is broken down into these additional attributes added to - the returned object: username, password, hostname, and port. + Additionally, the netloc property is broken down into these additional + attributes added to the returned object: username, password, hostname, + and port. % escapes are not decoded. @@ -277,12 +278,12 @@ or on combining URL components into a URL string. or query component, and :attr:`fragment` is set to the empty string in the return value. - This is similar to :func:`urlparse`, but does not split the params from the URL. - This should generally be used instead of :func:`urlparse` if the more recent URL - syntax allowing parameters to be applied to each segment of the *path* portion - of the URL (see :rfc:`2396`) is wanted. A separate function is needed to - separate the path segments and parameters. This function returns a 5-item - :term:`named tuple`:: + This is similar to :func:`urlparse`, but does not split the params from the + URL. This should generally be used instead of :func:`urlparse` if the more + recent URL syntax allowing parameters to be applied to each segment of the + *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function + is needed to separate the path segments and parameters. + This function returns a 5-item :term:`named tuple`:: (addressing scheme, network location, path, query, fragment identifier). From b090eb84e7b649444a9c88ae6403762c648a83fd Mon Sep 17 00:00:00 2001 From: Carol Willing Date: Fri, 1 Nov 2024 15:58:25 -0700 Subject: [PATCH 11/11] Apply suggestions from code review --- Doc/library/urllib.parse.rst | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index badcc8c5c8efb66..ae2fd419a64ea8d 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -46,11 +46,6 @@ or on combining URL components into a URL string. The delimiters as shown above are not part of the result, except for a leading slash in the path component, which is retained if present. - Additionally, the netloc property is broken down into these additional - attributes added to the returned object: username, password, hostname, and - port. - - % escapes are not decoded. For example: @@ -308,11 +303,6 @@ or on combining URL components into a URL string. or query component, and :attr:`fragment` is set to the empty string in the return value. - This is similar to :func:`urlparse`, but does not split the params from the - URL. This should generally be used instead of :func:`urlparse` if the more - recent URL syntax allowing parameters to be applied to each segment of the - *path* portion of the URL (see :rfc:`2396`) is wanted. A separate function - is needed to separate the path segments and parameters. This function returns a 5-item :term:`named tuple`:: (addressing scheme, network location, path, query, fragment identifier).