This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urlparse with a Windows path returns the drive name as the scheme
Type: behavior Stage:
Components: Windows Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: paul.moore, rangelspam, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-10-31 00:11 by rangelspam, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg380018 - (view) Author: Rangel Reale (rangelspam) Date: 2020-10-31 00:11
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='')
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86381
2020-10-31 00:11:40rangelspamcreate