GH-127090: Fix urllib.response.addinfourl.url value for opened file: URIs#127091
GH-127090: Fix urllib.response.addinfourl.url value for opened file: URIs#127091barneygale merged 8 commits intopython:mainfrom
urllib.response.addinfourl.url value for opened file: URIs#127091Conversation
The original `file:` URL that was passed to `urlopen()` is now used as the `url` attribute of the returned `addinfourl` object. The `addinfourl.url` attribute *always* reflects the original `file:`, `data:` or `ftp:` URL now.
urllib.request.addinfourl.url value for opened file: URIsurllib.response.addinfourl.url value for opened file: URIs
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM in general, but there are not enough tests.
I think that you can add checks for url in test_file_notexists and maybe in test_basic and test_copy in urlretrieve_FileTests.
|
Thank you Serhiy, that's very helpful. I'll mark this PR as a draft for now. Once #127125 and #127194 land, I'll adjust this patch to call |
I've expanded
The existing code raises |
|
Shouldn't it be backported? |
|
On the issue, Barney decided that it was not worth backporting: #127090 (comment). |
…d `file:` URIs (python#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.
The canonical
file:URL (as generated bypathname2url()) is now used as theurlattribute of the returnedaddinfourlobject. Theaddinfourl.urlattribute reflects the resolved URL for bothfile:orhttp[s]:URLs now.