<p dir="auto">It appears commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/psf/requests/commit/329a5cfdd4500fb1ce405a3242ef95f9197d24ba/hovercard" href="https://github.com/psf/requests/commit/329a5cfdd4500fb1ce405a3242ef95f9197d24ba"><tt>329a5cf</tt></a> has broken <code class="notranslate">_basic_auth_str</code> and it now throws an exception <code class="notranslate">TypeError</code> (see below) when the supplied username and password is <code class="notranslate">None</code>.</p>
<p dir="auto">Befor this commit, in requests 2.1.1, it was possible to supply None values for username and password when authentication is optional - in this particular case Home Assistant writing to InfluxDB with default configuration.</p>
<p dir="auto">Exception thrown:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="TypeError: sequence item 0: expected a bytes-like object, NoneType found"><pre class="notranslate"><span class="pl-v">TypeError</span>: <span class="pl-s1">sequence</span> <span class="pl-s1">item</span> <span class="pl-c1">0</span>: <span class="pl-s1">expected</span> <span class="pl-s1">a</span> <span class="pl-s1">bytes</span><span class="pl-c1">-</span><span class="pl-s1">like</span> <span class="pl-s1">object</span>, <span class="pl-v">NoneType</span> <span class="pl-s1">found</span></pre></div>
<p dir="auto">Possibly just a previously quirkly behavior that intentionally no longer works.</p>
<p dir="auto">For <code class="notranslate">requests&lt;2.12.2</code> having <code class="notranslate">None</code> for username and password still resulted in a BasicAuth authstr being created. Starting in <code class="notranslate">2.12.2</code> it will raise an exception.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  ...
  File &quot;/blah/lib/python2.7/site-packages/requests/auth.py&quot;, line 38, in _basic_auth_str
    b64encode(b':'.join((username, password))).strip()
TypeError: sequence item 0: expected string, NoneType found"><pre lang="Traceback" class="notranslate"><code class="notranslate">  ...
  File "/blah/lib/python2.7/site-packages/requests/auth.py", line 38, in _basic_auth_str
    b64encode(b':'.join((username, password))).strip()
TypeError: sequence item 0: expected string, NoneType found
</code></pre></div>
<p dir="auto">here's the change, (which certainly seems desirable), but caused our upstream (<code class="notranslate">python-gitlab</code>) to break.<br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/kennethreitz/requests/commit/329a5cfdd4500fb1ce405a3242ef95f9197d24ba/hovercard" href="https://github.com/kennethreitz/requests/commit/329a5cfdd4500fb1ce405a3242ef95f9197d24ba">kennethreitz@<tt>329a5cf</tt></a></p>