Bug report
Bug description:
When a file: URL is given to urllib.request.urlopen(), it returns an addinfourl object. This object's url attribute (and its deprecated geturl() method) usually return incorrect results. For example:
>>> from urllib.request import urlopen >>> urlopen('file:Doc/requirements.txt').url 'file://Doc/requirements.txt' # expected: 'file:Doc/requirements.txt' >>> urlopen('file:C:/requirements.txt').url 'file://C:/requirements.txt' # expected: 'file:C:/requirements.txt' or 'file:///C:/requirements.txt'
The code always prepends file://, but this might be too many slashes or too few depending on the path's drive and root.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response