def convert_body_to_bytes(resp):
    try:
        if not isinstance(resp['body']['string'], six.binary_type):
            resp['body']['string'] = resp['body']['string'].encode('utf-8')
    except (KeyError, TypeError, UnicodeEncodeError):
        # The thing we were converting either wasn't a dictionary or didn't
        # have the keys we were expecting.  Some of the tests just serialize
        # and deserialize a string.

        # Also, sometimes the thing actually is binary, so if you can't encode
        # it, just give up.
        pass
    return resp
If the request body is a string, encode it to bytes (for python3 support)
dataset/ETHPy150Open kevin1024/vcrpy/vcr/serializers/compat.py/convert_body_to_bytes