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://github.com/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
Linked PRs
Bug report
Bug description:
When a
file:URL is given tourllib.request.urlopen(), it returns anaddinfourlobject. This object'surlattribute (and its deprecatedgeturl()method) usually return incorrect results. For example: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
Linked PRs
urllib.response.addinfourl.urlvalue for openedfile:URIs #127091