Closed
Description
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