      def to_internal_value(self, data):
          # We're lenient with allowing basic numerics to be coerced into strings,
          # but other types should fail. Eg. unclear if booleans should represent as `true` or `True`,
          # and composites such as lists are likely user error.
          if isinstance(data, bool) or not isinstance(data, six.string_types + six.integer_types + (float,)):
              self.fail('invalid')
          value = six.text_type(data)
          return value.strip() if self.trim_whitespace else value
  
      def to_representation(self, value):
 
</s> remove         value = six.text_type(data)
 </s> add         value = str(data) </s> remove     value = unicode_repr(value)
 </s> add     value = repr(value) </s> remove         if isinstance(data, six.text_type) or not hasattr(data, '__iter__'):
 </s> add         if isinstance(data, str) or not hasattr(data, '__iter__'): </s> remove         if output_format is None or isinstance(value, six.string_types):
 </s> add         if output_format is None or isinstance(value, str): </s> remove         if isinstance(data, six.text_type) and len(data) > self.MAX_STRING_LENGTH:
 </s> add         if isinstance(data, str) and len(data) > self.MAX_STRING_LENGTH:
        if isinstance(data, bool) or not isinstance(data, (str, int, float,)):
      def to_internal_value(self, data):
          # We're lenient with allowing basic numerics to be coerced into strings,
          # but other types should fail. Eg. unclear if booleans should represent as `true` or `True`,
          # and composites such as lists are likely user error.
        if isinstance(data, bool) or not isinstance(data, (str, int, float,)):
              self.fail('invalid')
          value = six.text_type(data)
          return value.strip() if self.trim_whitespace else value
  
      def to_representation(self, value):
keep keep keep keep 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/fields.py