barneygale · GitHub

Bug report

Bug description:

On Windows, urllib.request.url2pathname() has overly simplistic handling of DOS drives in URLs.

Per @eryksun:

>>> from urllib.request import url2pathname
>>> url2pathname('//host/share/spam.txt:eggs')
'T:\\eggs'  # expected: r'\\host\share\spam.txt:eggs'

Also:

>>> url2pathname('///c:/spam.txt:eggs')
OSError: Bad URL: ///c|/spam.txt|eggs  # expected: r'c:\spam.txt:eggs'

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Read the original on github.com ↗