Repository navigation
urllib.parse.urlparse output named tuples description is wrong for Python 3.9 and 3.10 #91708
Description
Activity
The example and table changed to what they are now in gh-29816, but I cannot see any related changes in https://github.com/python/cpython/blob/main/Lib/urllib/parse.py which would make
urlparsealways return an empty string forparams. I think the change to the table in gh-29816 is incorrect.The example in the docs (
urlparse("scheme://netloc/path;parameters?query#fragment")) shows correct output (params='') solely because "scheme" is not a scheme for whichurlparsewill parse the path params, per the list on line 59:Lines 59 to 61 in d7d7e6c
uses_params = ['', 'ftp', 'hdl', 'prospero', 'http', 'imap', 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', 'mms', 'sftp', 'tel'] urlparsechecks if the scheme is in that list; if it isn'tparamswill be an empty string, but in other cases it will be parsed from the URL:Lines 389 to 392 in d7d7e6c
if scheme in uses_params and ';' in url: url, params = _splitparams(url) else: params = '' I find it a little confusing that
paramsis only parsed for known schemes, but it's probably too late now to change it without breakage. The docs would benefit from clarification of when it is and isn't parsed, with an example to demonstrate the parsing.Reacted by StanleyAnd if
paramsshould be de-emphasized, wouldn't it make sense to reorganise the documentation to promoteurlsplitinstead (despite its worse naming), and markurlparse,urlunparse, andParseResult*as deprecated?Also possibly
urlunsplit, under the assumption that most users have stopped using raw tuples, and thus could just callgeturl.- added a commit that references this issue
on Oct 7, 2022 - added 3 commits that reference this issue
on Oct 7, 2022 Thanks! ✨ 🍰 ✨
- added a commit that references this issue
on Oct 8, 2022 - added a commit that references this issue
on Oct 22, 2022
The documentation for
urllib.parse.urlparsestates that:However it seems that the documentation does not reflect reality:
and the returned named tuple has a populated
paramsfield.