Skip to content

Commit c33bdbb

Browse files
authored
bpo-37970: update and improve urlparse and urlsplit doc-strings (GH-16458)
1 parent a5cbab5 commit c33bdbb

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

Lib/urllib/parse.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,23 @@ def _fix_result_transcoding():
366366
def urlparse(url, scheme='', allow_fragments=True):
367367
"""Parse a URL into 6 components:
368368
<scheme>://<netloc>/<path>;<params>?<query>#<fragment>
369-
Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
370-
Note that we don't break the components up in smaller bits
371-
(e.g. netloc is a single string) and we don't expand % escapes."""
369+
370+
The result is a named 6-tuple with fields corresponding to the
371+
above. It is either a ParseResult or ParseResultBytes object,
372+
depending on the type of the url parameter.
373+
374+
The username, password, hostname, and port sub-components of netloc
375+
can also be accessed as attributes of the returned object.
376+
377+
The scheme argument provides the default value of the scheme
378+
component when no scheme is found in url.
379+
380+
If allow_fragments is False, no attempt is made to separate the
381+
fragment component from the previous component, which can be either
382+
path or query.
383+
384+
Note that % escapes are not expanded.
385+
"""
372386
url, scheme, _coerce_result = _coerce_args(url, scheme)
373387
splitresult = urlsplit(url, scheme, allow_fragments)
374388
scheme, netloc, url, query, fragment = splitresult
@@ -417,9 +431,24 @@ def _checknetloc(netloc):
417431
def urlsplit(url, scheme='', allow_fragments=True):
418432
"""Parse a URL into 5 components:
419433
<scheme>://<netloc>/<path>?<query>#<fragment>
420-
Return a 5-tuple: (scheme, netloc, path, query, fragment).
421-
Note that we don't break the components up in smaller bits
422-
(e.g. netloc is a single string) and we don't expand % escapes."""
434+
435+
The result is a named 5-tuple with fields corresponding to the
436+
above. It is either a SplitResult or SplitResultBytes object,
437+
depending on the type of the url parameter.
438+
439+
The username, password, hostname, and port sub-components of netloc
440+
can also be accessed as attributes of the returned object.
441+
442+
The scheme argument provides the default value of the scheme
443+
component when no scheme is found in url.
444+
445+
If allow_fragments is False, no attempt is made to separate the
446+
fragment component from the previous component, which can be either
447+
path or query.
448+
449+
Note that % escapes are not expanded.
450+
"""
451+
423452
url, scheme, _coerce_result = _coerce_args(url, scheme)
424453
allow_fragments = bool(allow_fragments)
425454
key = url, scheme, allow_fragments, type(url), type(scheme)

0 commit comments

Comments
 (0)