Closed
Description
Bug report
Bug description:
urllib.request.pathname2url()
unexpectedly removes doubled and trailing slashes, but only on Windows, and only for DOS device paths (not UNC paths):
>>> from urllib.request import pathname2url, url2pathname >>> pathname2url('C:\\') '///C:' # This is *not* the same path! >>> pathname2url('C:\\foo\\') '///C:/foo' >>> pathname2url('C:\\foo\\\\bar') '///C:/foo/bar'
url2pathname()
does almost the same thing, except that it specially preserves a slash immediately after a DOS drive (but not elsewhere):
>>> url2pathname('///c:/') 'C:\\' # OK >>> url2pathname('///c:/foo/') 'C:\\foo' >>> url2pathname('///c:/foo//bar') 'C:\\foo\\bar'
This behaviour makes no sense and has no equivalent on POSIX, where all slashes are preserved.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows