Skip to content

urllib.request.url2pathname() mishandles non-empty authority sections on POSIX #126838

Closed as not planned

Description

@barneygale

Bug report

Bug description:

URLs supplied to urllib.request.url2pathname() may include a non-empty authority (netloc), such as a hostname.

On Windows, these are correctly decoded (mostly):

>>> url2pathname('//localhost/c:/foo.txt')
'C:\\foo.txt'  # OK
>>> url2pathname('//server/share')
'\\\\server\\share'  # OK

But on POSIX, any non-empty authority except localhost is preserved in the path:

>>> url2pathname('//myhostname/etc/hosts')
'//myhostname/etc/hosts'  # expected '/etc/hosts'
>>> url2pathname('//server/share')
'//server/share'  # expected URLError ('server' is not local)

Per RFC 8089 this isn't correct.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bug
    stdlib
    3.12
    3.13
    3.14
    on Nov 14, 2024
  2. added 3 commits that reference this issue on Nov 14, 2024
  3. barneygale commented on Nov 27, 2024

    @barneygale
    ContributorAuthor

    Closing - dupe of #123599

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

    3.123.133.14stdlibtype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions