-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error