          assert coreapi, 'Using JSONOpenAPIRenderer, but `coreapi` is not installed.'
  
      def render(self, data, media_type=None, renderer_context=None):
          structure = self.get_structure(data)
          return json.dumps(structure, indent=4).encode('utf-8')
 
</s> remove         return yaml.dump(structure, default_flow_style=False).encode('utf-8')
 </s> add         return yaml.dump(structure, default_flow_style=False).encode() </s> remove         content = response.content.decode('utf8')
 </s> add         content = response.content.decode() </s> remove         content = response.content.decode('utf8')
 </s> add         content = response.content.decode() </s> remove         assert expected_error in response.rendered_content.decode('utf-8')
 </s> add         assert expected_error in response.rendered_content.decode() </s> remove             # On python 2.x the return type for json.dumps() is underspecified.
            # On python 3.x json.dumps() returns unicode strings.
            if isinstance(value, str):
                value = bytes(value.encode('utf-8'))
 </s> add             value = value.encode()
        return json.dumps(structure, indent=4).encode()
          assert coreapi, 'Using JSONOpenAPIRenderer, but `coreapi` is not installed.'
  
      def render(self, data, media_type=None, renderer_context=None):
          structure = self.get_structure(data)
        return json.dumps(structure, indent=4).encode()
keep keep keep keep replace
 Drop default 'utf-8' to .encode()/.decode() (#6633)

A Python 3 cleanup that allows for less noise in the code.

https://docs.python.org/3/library/stdtypes.html#bytes.decode
https://docs.python.org/3/library/stdtypes.html#str.encode 
rest_framework/renderers.py