GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `urllib.parse.urlparse` output named tuples description is wrong for Python 3.9 and 3.10 · Issue #91708 · python/cpython

urllib.parse.urlparse output named tuples description is wrong for Python 3.9 and 3.10 #91708

New issue
Copy link
New issue
Copy link
Closed
Closed
urllib.parse.urlparse output named tuples description is wrong for Python 3.9 and 3.10#91708
Copy link
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir

Description

@dnicolodi
dnicolodi
opened on Apr 19, 2022
Issue body actions

The documentation for urllib.parse.urlparse states that:

The return value is a named tuple, which means that its items can be accessed by index or as named attributes, which are:

Attribute Index Value Value if not present
...
params 3 No longer used always an empty string

However it seems that the documentation does not reflect reality:

>>> 
>>> import urllib.parse
>>> p = urllib.parse.urlparse('http://foo.test/test;param')
>>> p
ParseResult(scheme='http', netloc='foo.test', path='/test', params='param', query='', fragment='')
>>> p[3]
'param'

and the returned named tuple has a populated params field.

Reacted by Federico Caselli and xmo-odoo

Activity

  1. dnicolodi
    added
    docsDocumentation in the Doc dirDocumentation in the Doc dir
    on Apr 19, 2022
  2. domdfcoding commented on Apr 20, 2022

    @domdfcoding
    domdfcoding
    on Apr 20, 2022
    Contributor
    More actions

    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 urlparse always return an empty string for params. 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 which urlparse will parse the path params, per the list on line 59:

    cpython/Lib/urllib/parse.py

    Lines 59 to 61 in d7d7e6c

    uses_params = ['', 'ftp', 'hdl', 'prospero', 'http', 'imap',
    'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
    'mms', 'sftp', 'tel']

    urlparse checks if the scheme is in that list; if it isn't params will be an empty string, but in other cases it will be parsed from the URL:

    cpython/Lib/urllib/parse.py

    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 params is 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 Stanley
  3. xmo-odoo commented on Aug 29, 2022

    @xmo-odoo
    xmo-odoo
    on Aug 29, 2022
    More actions

    And if params should be de-emphasized, wouldn't it make sense to reorganise the documentation to promote urlsplit instead (despite its worse naming), and mark urlparse, urlunparse, and ParseResult* as deprecated?

    Also possibly urlunsplit, under the assumption that most users have stopped using raw tuples, and thus could just call geturl.

  4. ambv
    added a commit that references this issue on Oct 7, 2022

    gh-91708: Revert params note in urllib.parse.urlparse table (#96699)

    eed8045
  5. miss-islington
    added 3 commits that reference this issue on Oct 7, 2022

    pythongh-91708: Revert params note in urllib.parse.urlparse table (py…

    df88fb0

    pythongh-91708: Revert params note in urllib.parse.urlparse table (py…

    3266007

    pythongh-91708: Revert params note in urllib.parse.urlparse table (py…

    c2c3e15
  6. ambv
    added 3 commits that reference this issue on Oct 7, 2022

    [3.11] gh-91708: Revert params note in urllib.parse.urlparse table (G…

    40d5e89

    [3.9] gh-91708: Revert params note in urllib.parse.urlparse table (GH…

    1db2d95

    [3.10] gh-91708: Revert params note in urllib.parse.urlparse table (G…

    0239440
  7. ambv
    closed this as completedon Oct 7, 2022
  8. ambv commented on Oct 7, 2022

    @ambv
    ambv
    on Oct 7, 2022
    Contributor
    More actions

    Thanks! ✨ 🍰 ✨

  9. carljm
    added a commit that references this issue on Oct 8, 2022

    Merge branch 'main' into typewatch

    27a4980
  10. mpage
    added a commit that references this issue on Oct 11, 2022

    pythongh-91708: Revert params note in urllib.parse.urlparse table (py…

    8ce4739
  11. pablogsal
    added a commit that references this issue on Oct 22, 2022

    [3.11] gh-91708: Revert params note in urllib.parse.urlparse table (G…

    c634cd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.