cannot use json() on request in python 3.7 (TypeError: must be str, not bytes)

Summary.

Calling this code is not working in python 3.6 on ubuntu.
There is  a change adding      .encode('ascii')
to the _null constant which causes the type error.

Removing the encoding call fixes the problem!

I am confused!

## Expected Result

no exception

## Actual Result
TypeError: must be str, not bytes


## Reproduction Steps

```python
import requests
jsonstr="{ 'bla' : 'blub'}"
resp = requests.Response()
resp._content = jsonstr
resp.json()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/requests/models.py", line 880, in json
    encoding = guess_json_utf(self.content)
  File "/usr/lib/python3/dist-packages/requests/utils.py", line 798, in guess_json_utf
    nullcount = sample.count(_null)
TypeError: must be str, not bytes
```

## System Information

    $ python3 -m requests.help

```
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.7"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.7"
  },
  "platform": {
    "release": "4.15.0-39-lowlatency",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "1010007f"
  },
  "urllib3": {
    "version": "1.21.1"
  },
  "using_pyopenssl": false
}

```

This command is only available on Requests v2.16.4 and greater. Otherwise,
please provide some basic information about your system (Python version,
operating system, &c).
ubuntu 18.04  (ubuntustudio)

OK I found the remark elsewhere to require requests.content to be bytes.
I just migrated to python3 and this was a hidden magic functional change from python 2.
When I added the byte conversion it worked.

How can we avoid such intransparent changes in the API?
How am I supposed to know this?

In java it would be totally transparent and annotated as @Deprecated
Due to the python autotyping this is not so easy.

How about a test for string type on the parameter and an appropriate error message instead of a type error? Or at least some more comment somewhere that the type has changed?
Like augmenting  line comment added to the encode() line with changed to byte as the content attribute!


So it is possible in python. Just nobody bothered.

This is what I found  in base64: 

    warnings.warn("encodestring() is a deprecated alias since 3.1, "
                  "use encodebytes()",
                  DeprecationWarning, 2)


Forgive me if I'm misunderstanding but setting `Response._content` to a value seems like mucking with internals which has no guarantees compared to the "public" interface. If the expected type of `_content` is bytes during regular usage by requests you would have to conform to that as well if you plan on using the code this way.

@SethMichaelLarson is correct, this is outside of Requests defined usage. You’re setting a private variable to an unepexcted type. This shouldn’t be possible with normal use of the Requests API.

@uvwild can you please provide some more details on how you reached this state. Is it reproducible without manually setting _content?

@nateprewitt spoiler, it's not reproducible without accessing otherwise private attributes.

Resolving since we haven't received a response in the last two weeks. Feel free to reopen if you have a concrete example that doesn't use private methods or variables. Thanks!

for anyone else who get this error - just make content bytes
```
resp = requests.Response()
resp._content = b"{ 'bla' : 'blub'}"
```

According commit msg bellow of commit  https://github.com/psf/requests/pull/909/commits/4decc7986e32bb8f3511df3dd0c9b1c1d57453c1. [And the type of native string in python2 is bytes but in python3 is text](https://portingguide.readthedocs.io/en/latest/strings.html#the-native-string), so we need to convert it into bytes explicitly in python3
"

"JSON *must* be encoded using UTF-8, UTF-16 or UTF-32 (see the [RFC][1]; detect the encoding based on the fact that JSON always starts with 2 ASCII characters."