          ret[3 - precedence].add(media_type)
      return [media_types for media_types in ret if media_types]
  
  
  @python_2_unicode_compatible
  class _MediaType(object):
      def __init__(self, media_type_str):
          self.orig = '' if (media_type_str is None) else media_type_str
          self.full_type, self.params = parse_header(self.orig.encode(HTTP_HEADER_ENCODING))
          self.main_type, sep, self.sub_type = self.full_type.partition('/')
  
 
</s> remove         return super(URLPathVersioning, self).reverse(
 </s> add         return super().reverse( </s> remove         super(DurationField, self).__init__(**kwargs)
 </s> add         super().__init__(**kwargs) </s> remove             raise ParseError('JSON parse error - %s' % six.text_type(exc))
 </s> add             raise ParseError('JSON parse error - %s' % str(exc)) </s> remove             for name, value in six.iteritems(headers):
 </s> add             for name, value in headers.items(): </s> remove         super(SimpleRouter, self).__init__()
 </s> add         super().__init__()
class _MediaType:
          ret[3 - precedence].add(media_type)
      return [media_types for media_types in ret if media_types]
  
  
class _MediaType:
class _MediaType:
      def __init__(self, media_type_str):
          self.orig = '' if (media_type_str is None) else media_type_str
          self.full_type, self.params = parse_header(self.orig.encode(HTTP_HEADER_ENCODING))
          self.main_type, sep, self.sub_type = self.full_type.partition('/')
  
keep keep keep keep replace replace keep keep keep keep keep
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
rest_framework/utils/mediatypes.py