Issue 1:
During an upgrade from python 3.7 to 3.9 I face an error similar to the one reported on #5297.

The proxies are defined on the system level (export http_proxy and export https_proxy).

It works fine on 3.7.

Expected Result

Requests respect the proxy

Actual Result

Proxy causes the request fo fail

Reproduction Steps

import requests
headers={}
payload={}
url='https://www.someurl.com'
response = requests.request("POST", url, headers=headers, data = payload)

System Information

$ python -m requests.help

{
"chardet": {
"version": "3.0.4"
},
"cryptography": {
"version": ""
},
"idna": {
"version": "2.8"
},
"implementation": {
"name": "CPython",
"version": "3.9.6"
},
"platform": {
"release": "20.6.0",
"system": "Darwin"
},
"pyOpenSSL": {
"openssl_version": "",
"version": null
},
"requests": {
"version": "2.22.0"
},
"system_ssl": {
"version": "101010bf"
},
"urllib3": {
"version": "1.25.11"
},
"using_pyopenssl": false
}

Traceback

response = requests.request("POST", url, headers=headers, data = payload)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 412, in send
conn = self.get_connection(request.url, proxies)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 309, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 193, in proxy_manager_for
manager = self.proxy_manager[proxy] = proxy_from_url(
File "/usr/local/lib/python3.9/site-packages/urllib3/poolmanager.py", line 492, in proxy_from_url
return ProxyManager(proxy_url=url, **kw)
File "/usr/local/lib/python3.9/site-packages/urllib3/poolmanager.py", line 429, in __init__
raise ProxySchemeUnknown(proxy.scheme)

Issue 2:
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

def prepend_scheme_if_needed(url, new_scheme):

With the old behavior, urlparse would return ParseResult(scheme='', netloc='', path='example.org:80', params='', query='', fragment='') and then prepend_scheme_if_needed would happily add the scheme, typically http. With the new behavior, you instead get ParseResult(scheme='example.org', netloc='', path='80', params='', query='', fragment=''), so prepend_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 of urllib.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 raises ProxySchemeUnknown

Reproduction Steps

import requests
session = requests.Session()
session.proxies = {'https': 'example.org:80'}
session.get('https://www.google.com/')

System Information

$ python -m requests.help

{
"implementation": {
"name": "CPython",
"version": "3.9.5"
},
"platform": {
"system": "Linux"
},
"requests": {
"version": "2.22.0"
},
"urllib3": {
"version": "1.25.3"
},
"using_pyopenssl": false
}