mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-127090: Fix urllib.response.addinfourl.url
value for opened file:
URIs (#127091)
The canonical `file:` URL (as generated by `pathname2url()`) is now used as the `url` attribute of the returned `addinfourl` object. The `addinfourl.url` attribute reflects the resolved URL for both `file:` or `http[s]:` URLs now.
This commit is contained in:
parent
27d0d21413
commit
79b7cab50a
5 changed files with 25 additions and 28 deletions
|
@ -1488,10 +1488,7 @@ class FileHandler(BaseHandler):
|
|||
host, port = _splitport(host)
|
||||
if not host or \
|
||||
(not port and _safe_gethostbyname(host) in self.get_names()):
|
||||
if host:
|
||||
origurl = 'file://' + host + filename
|
||||
else:
|
||||
origurl = 'file://' + filename
|
||||
origurl = 'file:' + pathname2url(localfile)
|
||||
return addinfourl(open(localfile, 'rb'), headers, origurl)
|
||||
except OSError as exp:
|
||||
raise URLError(exp, exp.filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue