summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authoridomic <michael.ido@gmail.com>2020-02-16 19:17:58 (GMT)
committerGitHub <noreply@github.com>2020-02-16 19:17:58 (GMT)
commitc33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad (patch)
treed182940a01914670c90eeb79a44a24fb2ee6507a /Lib
parenta5cbab552d294d99fde864306632d7e511a75d3c (diff)
downloadcpython-c33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad.zip
cpython-c33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad.tar.gz
cpython-c33bdbb20cf55b3a2aa7a91bd3d91fcb59796fad.tar.bz2
bpo-37970: update and improve urlparse and urlsplit doc-strings (GH-16458)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib/parse.py41
1 files changed, 35 insertions, 6 deletions
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 34d5f95..779278b 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -366,9 +366,23 @@ del _fix_result_transcoding
def urlparse(url, scheme='', allow_fragments=True):
"""Parse a URL into 6 components:
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
- Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
- Note that we don't break the components up in smaller bits
- (e.g. netloc is a single string) and we don't expand % escapes."""
+
+ The result is a named 6-tuple with fields corresponding to the
+ above. It is either a ParseResult or ParseResultBytes object,
+ depending on the type of the url parameter.
+
+ The username, password, hostname, and port sub-components of netloc
+ can also be accessed as attributes of the returned object.
+
+ The scheme argument provides the default value of the scheme
+ component when no scheme is found in url.
+
+ If allow_fragments is False, no attempt is made to separate the
+ fragment component from the previous component, which can be either
+ path or query.
+
+ Note that % escapes are not expanded.
+ """
url, scheme, _coerce_result = _coerce_args(url, scheme)
splitresult = urlsplit(url, scheme, allow_fragments)
scheme, netloc, url, query, fragment = splitresult
@@ -417,9 +431,24 @@ def _checknetloc(netloc):
def urlsplit(url, scheme='', allow_fragments=True):
"""Parse a URL into 5 components:
<scheme>://<netloc>/<path>?<query>#<fragment>
- Return a 5-tuple: (scheme, netloc, path, query, fragment).
- Note that we don't break the components up in smaller bits
- (e.g. netloc is a single string) and we don't expand % escapes."""
+
+ The result is a named 5-tuple with fields corresponding to the
+ above. It is either a SplitResult or SplitResultBytes object,
+ depending on the type of the url parameter.
+
+ The username, password, hostname, and port sub-components of netloc
+ can also be accessed as attributes of the returned object.
+
+ The scheme argument provides the default value of the scheme
+ component when no scheme is found in url.
+
+ If allow_fragments is False, no attempt is made to separate the
+ fragment component from the previous component, which can be either
+ path or query.
+
+ Note that % escapes are not expanded.
+ """
+
url, scheme, _coerce_result = _coerce_args(url, scheme)
allow_fragments = bool(allow_fragments)
key = url, scheme, allow_fragments, type(url), type(scheme)