Fix regression in API caused by commit 85400d8d6751071ef78f042d1efa72…

…bdcf76cc0e

  - The added optional parameter changes API and should default to None

    This utility call is used by for example requestbuilder package directly
    which breaks because it passes only one argument to the function as it
    used to be.

I don't believe this is a public API, and therefore we don't gaurentee API compatibility.

But, I could be wrong — either way, it seems like a nice change to make if it doesn't hurt anything. 

@nateprewitt any objections?

I think this is a good idea, but we should work out why the builders are failing first. ;)

Yeah, I don't see any issue with this, even if we're not supporting this API publicly.

As for the build, something in our dependency pipeline must have changed yesterday or earlier. Python <= 3.3 builds started failing on `test_https_warnings`, but I wasn't able to determine why at a quick glance. @Lukasa probably has more background about the architecture underneath this.

I think this has to be a pytest-httpbin thing. The error is ultimately because we now believe that the cert that pytest-httpbin is presenting on the secure endpoint now has a subjectAlternativeName field. I'm trying to locate it and work out why that warning isn't firing.

Hrm, no, that's not true. This test passes if run by itself, so this is a new state based test failure for some reason.

Ok I have a theory, testing now.

The new release of Pytest from yesterday has some interesting notes in the [changelog](https://docs.pytest.org/en/latest/changelog.html).

* The pytest-warnings plugin has been integrated into the core, so now pytest automatically captures and displays warnings at the end of the test session. Thanks @nicoddemus for the PR.

 * pytest.warns now checks for subclass relationship rather than class equality. Thanks @lesteve for the PR (#2166)

Yeah, this is the warning issue: see #4056.

Ok cool, can we rebase this on the new master?

@Lukasa no conflicts!

@kennethreitz, I kicked the Travis builds and they seem to be working with the changes to master. If you can kick appveyor, we should be able to merge.

Hi everyone, sorry for barging in, but was this regression related to pytest's 3.1.0 warnings capture?

Hey @nicoddemus, no need to apologize 😊 The regression is unrelated to the pytest 3.1.0 changes but those changes were effecting our build when this PR was opened. We've since implemented the suggested workaround in #4056.

Great, thanks for the answer! 👍 

So I'm not in favor of merging this. As was said earlier, this is not a public API.

@sigmavirus24, if we're not going to maintain this as a public API, it should probably be moved to `_internal_utils.py`? The doctstring for `utils.py` states "This module provides utility functions that are used within Requests that are also useful for external consumption." which to me reads they're fair game for public use.

Edit: or modify the docstring. There's a fair amount of stuff in `utils.py` that probably shouldn't be depended on externally.

# [Codecov](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=h1) Report
> Merging [#4052](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=desc) into [master](https://codecov.io/gh/kennethreitz/requests/commit/0ba21a79c49117495e2c4f70264f366dea6e480e?src=pr&el=desc) will **increase** coverage by `1.5%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/kennethreitz/requests/pull/4052/graphs/tree.svg?src=pr&token=mZGswIiXLa&width=650&height=150)](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##           master    #4052     +/-   ##
=========================================
+ Coverage   88.15%   89.65%   +1.5%     
=========================================
  Files          15       16      +1     
  Lines        1941     1962     +21     
=========================================
+ Hits         1711     1759     +48     
+ Misses        230      203     -27
```


| [Impacted Files](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [requests/utils.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvdXRpbHMucHk=) | `86% <100%> (ø)` | :arrow_up: |
| [requests/\_\_version\_\_.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvX192ZXJzaW9uX18ucHk=) | `100% <0%> (ø)` | |
| [requests/adapters.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvYWRhcHRlcnMucHk=) | `92.92% <0%> (+0.47%)` | :arrow_up: |
| [requests/models.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvbW9kZWxzLnB5) | `93.42% <0%> (+2.26%)` | :arrow_up: |
| [requests/\_internal\_utils.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvX2ludGVybmFsX3V0aWxzLnB5) | `100% <0%> (+6.25%)` | :arrow_up: |
| [...es/urllib3/packages/ssl\_match\_hostname/\_\_init\_\_.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvcGFja2FnZXMvdXJsbGliMy9wYWNrYWdlcy9zc2xfbWF0Y2hfaG9zdG5hbWUvX19pbml0X18ucHk=) | `92.68% <0%> (+9.34%)` | :arrow_up: |
| [requests/packages/chardet/compat.py](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=tree#diff-cmVxdWVzdHMvcGFja2FnZXMvY2hhcmRldC9jb21wYXQucHk=) | `100% <0%> (+35.13%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=footer). Last update [0ba21a7...a9470fe](https://codecov.io/gh/kennethreitz/requests/pull/4052?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).