<p dir="auto">It seems like this change <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="981521878" data-permission-text="Title is private" data-url="https://github.com/psf/requests/issues/5917" data-hovercard-type="pull_request" data-hovercard-url="/psf/requests/pull/5917/hovercard" href="https://github.com/psf/requests/pull/5917">#5917</a> unfortunately broke production for us.</p>
<p dir="auto">We are using a proxy url that follows this scheme: <code class="notranslate">http://randomstring:randomstring@eu-west-static-04.example.com:9293</code> (from a service that provides static IPs)</p>
<h2 dir="auto">Expected Result</h2>
<p dir="auto">In 2.26.0 this still works:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; from requests.utils import prepend_scheme_if_needed
&gt;&gt;&gt; prepend_scheme_if_needed('http://randomstring:randomstring@eu-west-static-04.example.com:9293', 'http')
'http://randomstring:randomstring@eu-west-static-04.example.com:9293'"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; from requests.utils import prepend_scheme_if_needed
&gt;&gt;&gt; prepend_scheme_if_needed('http://randomstring:randomstring@eu-west-static-04.example.com:9293', 'http')
'http://randomstring:randomstring@eu-west-static-04.example.com:9293'
</code></pre></div>
<h2 dir="auto">Actual Result</h2>
<p dir="auto">In 2.27.0 it's broken:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; from requests.utils import prepend_scheme_if_needed
&gt;&gt;&gt; prepend_scheme_if_needed('http://randomstring:randomstring@eu-west-static-04.example.com:9293', 'http')
'http://eu-west-static-04.example.com:9293'"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; from requests.utils import prepend_scheme_if_needed
&gt;&gt;&gt; prepend_scheme_if_needed('http://randomstring:randomstring@eu-west-static-04.example.com:9293', 'http')
'http://eu-west-static-04.example.com:9293'
</code></pre></div>
<p dir="auto">This leads in the end to <code class="notranslate">ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))</code> because the url was cut.</p>
<h2 dir="auto">Reproduction Steps</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; from requests.utils import prepend_scheme_if_needed
&gt;&gt;&gt; prepend_scheme_if_needed('http://randomstring:randomstring@eu-west-static-04.example.com:9293', 'http')"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">from</span> <span class="pl-s1">requests</span>.<span class="pl-s1">utils</span> <span class="pl-k">import</span> <span class="pl-s1">prepend_scheme_if_needed</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-en">prepend_scheme_if_needed</span>(<span class="pl-s">'http://randomstring:randomstring@eu-west-static-04.example.com:9293'</span>, <span class="pl-s">'http'</span>)</pre></div>
<h2 dir="auto">System Information</h2>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: null
  },
  &quot;charset_normalizer&quot;: {
    &quot;version&quot;: &quot;2.0.9&quot;
  },
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;36.0.1&quot;
  },
  &quot;idna&quot;: {
    &quot;version&quot;: &quot;3.3&quot;
  },
  &quot;implementation&quot;: {
    &quot;name&quot;: &quot;CPython&quot;,
    &quot;version&quot;: &quot;3.9.9&quot;
  },
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;5.14.21-2-MANJARO&quot;,
    &quot;system&quot;: &quot;Linux&quot;
  },
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;101010df&quot;,
    &quot;version&quot;: &quot;21.0.0&quot;
  },
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.27.0&quot;
  },
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;101010df&quot;
  },
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.26.7&quot;
  },
  &quot;using_charset_normalizer&quot;: true,
  &quot;using_pyopenssl&quot;: true
}"><pre class="notranslate">{
  <span class="pl-ent">"chardet"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-c1">null</span>
  },
  <span class="pl-ent">"charset_normalizer"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.9<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"cryptography"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>36.0.1<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"idna"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.3<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"implementation"</span>: {
    <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>CPython<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.9.9<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"platform"</span>: {
    <span class="pl-ent">"release"</span>: <span class="pl-s"><span class="pl-pds">"</span>5.14.21-2-MANJARO<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"system"</span>: <span class="pl-s"><span class="pl-pds">"</span>Linux<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"pyOpenSSL"</span>: {
    <span class="pl-ent">"openssl_version"</span>: <span class="pl-s"><span class="pl-pds">"</span>101010df<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>21.0.0<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"requests"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.27.0<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"system_ssl"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>101010df<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"urllib3"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.26.7<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"using_charset_normalizer"</span>: <span class="pl-c1">true</span>,
  <span class="pl-ent">"using_pyopenssl"</span>: <span class="pl-c1">true</span>
}</pre></div>
<p dir="auto">When using proxies in python 3.8.12, I get an error 407. Using any other version of python works fine. I am assuming it could be to do with this <a href="https://docs.python.org/3/whatsnew/3.8.html#notable-changes-in-python-3-8-12" rel="nofollow">https://docs.python.org/3/whatsnew/3.8.html#notable-changes-in-python-3-8-12</a>.</p>

<p dir="auto">I should get a status of 200.</p>

<p dir="auto">I get a status code of 407.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import requests


r = requests.get('https://example.org/', proxies=proxies) # You will need a proxy to test with, I am using a paid service.
print(r.status_code)
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">requests</span>


<span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-s1">requests</span>.<span class="pl-en">get</span>(<span class="pl-s">'https://example.org/'</span>, <span class="pl-s1">proxies</span><span class="pl-c1">=</span><span class="pl-s1">proxies</span>) <span class="pl-c"># You will need a proxy to test with, I am using a paid service.</span>
<span class="pl-en">print</span>(<span class="pl-s1">r</span>.<span class="pl-s1">status_code</span>)</pre></div>
<h2 dir="auto">System Information</h2>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: null
  },
  &quot;charset_normalizer&quot;: {
    &quot;version&quot;: &quot;2.0.9&quot;
  },
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;&quot;
  },
  &quot;idna&quot;: {
    &quot;version&quot;: &quot;3.3&quot;
  },
  &quot;implementation&quot;: {
    &quot;name&quot;: &quot;CPython&quot;,
    &quot;version&quot;: &quot;3.8.12&quot;
  },
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;5.13.0-7620-generic&quot;,
    &quot;system&quot;: &quot;Linux&quot;
  },
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;&quot;,
    &quot;version&quot;: null
  },
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.27.0&quot;
  },
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;101010cf&quot;
  },
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.26.7&quot;
  },
  &quot;using_charset_normalizer&quot;: true,
  &quot;using_pyopenssl&quot;: false
}"><pre class="notranslate">{
  <span class="pl-ent">"chardet"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-c1">null</span>
  },
  <span class="pl-ent">"charset_normalizer"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.9<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"cryptography"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"idna"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.3<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"implementation"</span>: {
    <span class="pl-ent">"name"</span>: <span class="pl-s"><span class="pl-pds">"</span>CPython<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.8.12<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"platform"</span>: {
    <span class="pl-ent">"release"</span>: <span class="pl-s"><span class="pl-pds">"</span>5.13.0-7620-generic<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"system"</span>: <span class="pl-s"><span class="pl-pds">"</span>Linux<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"pyOpenSSL"</span>: {
    <span class="pl-ent">"openssl_version"</span>: <span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>,
    <span class="pl-ent">"version"</span>: <span class="pl-c1">null</span>
  },
  <span class="pl-ent">"requests"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.27.0<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"system_ssl"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>101010cf<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"urllib3"</span>: {
    <span class="pl-ent">"version"</span>: <span class="pl-s"><span class="pl-pds">"</span>1.26.7<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"using_charset_normalizer"</span>: <span class="pl-c1">true</span>,
  <span class="pl-ent">"using_pyopenssl"</span>: <span class="pl-c1">false</span>
}</pre></div>