Skip to content

urllib.request.pathname2url() raises on NTFS alternate data stream #126601

Closed
@barneygale

Description

@barneygale

Bug report

Bug description:

On Windows, urllib.request.pathname2url() raises OSError when given a path with a colon in any position other than the second character. This excludes paths with NTFS alternate data streams, which are valid in other path-processing functions (e.g. in os.path and pathlib):

>>> from urllib.request import pathname2url
>>> pathname2url(r'C:\foo:bar')
OSError: Bad path: C:/foo:bar  # expected: ///C:/foo%3Abar
>>> pathname2url(r'foo:bar')
OSError: Bad path: foo:bar  # expected: foo%3Abar

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions