[New-bugs-announce] [issue42215] urlparse with a Windows path returns the drive name as the scheme

Rangel Reale report at bugs.python.org
Fri Oct 30 20:11:40 EDT 2020


New submission from Rangel Reale <rangelspam at gmail.com>:

Passing a Windows path to urllib.parse.urlparse, without file://, makes it detect the drive as the scheme even it having '\' after the ':', which makes it completelly wrong for a url.

Probably this function shouldn't be used with non-uri paths, but it shouldn't return a result that is so wrong as this. I think at least it should return the same input string if the url doesn't start with ://.


Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
from urllib.parse import urlparse
urlparse('M:\\prog\\tests\\python\\json-ref-dict\\tests/schemas/master.yaml')
Out[3]: ParseResult(scheme='m', netloc='', path='\\prog\\tests\\python\\json-ref-dict\\tests/schemas/master.yaml', params='', query='', fragment='')
str(urlparse('M:\\prog\\tests\\python\\json-ref-dict\\tests/schemas/master.yaml'))
Out[4]: "ParseResult(scheme='m', netloc='', path='\\\\prog\\\\tests\\\\python\\\\json-ref-dict\\\\tests/schemas/master.yaml', params='', query='', fragment='')"
urlparse('M:\prog\tests\python\json-ref-dict\\tests/schemas/master.yaml')
Out[5]: ParseResult(scheme='m', netloc='', path='\\prog\tests\\python\\json-ref-dict\\tests/schemas/master.yaml', params='', query='', fragment='')

----------
components: Windows
messages: 380018
nosy: paul.moore, rangelspam, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: urlparse with a Windows path returns the drive name as the scheme
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42215>
_______________________________________


More information about the New-bugs-announce mailing list