-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
GH-127090: Fix urllib.response.addinfourl.url value for opened file: URIs
#127091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
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 |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
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.