New submission from Rangel Reale <rangels...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue42215>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to