-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
proxy URLs without schemes break under Python 3.9 #5855
Comments
"soon 3.7 and 3.8" in the issue title isn't correct. The behavior change was present in 3.8.1 and 3.7.6 but reverted in 3.8.2 and 3.7.7. |
Oh good, I missed that, thanks. (There were a lot of bugs to read and I ended up skimming past that piece of history) |
@sethmlarson am I correct in that urllib3's url parsing is not a public API we can rely on? |
|
I did a bit of work around this last night. I have a draft PR up (#5917) that has the minimal fix for
|
Now that #5917 is merged, this should be set to go out on Monday with Requests 2.27.0. Resolving as fixed. |
In https://bugs.python.org/issue27657 it was decided to reverse an earlier decision about how
urllib.parse.urlparse
handles URLs that don't specify a scheme (e.g.example.org:80
). This behavior change is in Python 3.9.One way this can present to a user is by confusing requests's attempt to add the scheme if it's missing:
requests/requests/utils.py
Line 904 in 1466ad7
With the old behavior,
urlparse
would returnParseResult(scheme='', netloc='', path='example.org:80', params='', query='', fragment='')
and thenprepend_scheme_if_needed
would happily add the scheme, typicallyhttp
. With the new behavior, you instead getParseResult(scheme='example.org', netloc='', path='80', params='', query='', fragment='')
, soprepend_scheme_if_needed
thinks it has a scheme, and does nothing. Then later, if this is used as a proxy URL,urllib3
will complain here, because it has its own URL parser that is now I think out of sync with the stdlib.(I guess this means you could fix this by making requests use
urllib3.util.url.parse_url
instead ofurllib.parse.urlparse
, but that's maybe an antisocial fix)Expected Result
If user code has given requests a proxy dict like
{'http': 'example.org:80'}
, the request is sent through that proxy.Actual Result
urllib3
raisesProxySchemeUnknown
Reproduction Steps
System Information
The text was updated successfully, but these errors were encountered: