      """
      if isinstance(value, six.string_types):  # Handle strings first for performance reasons.
          return value
      elif isinstance(value, bool):  # Don't treat booleans as numbers.
          return six.text_type(value)
      elif isinstance(value, (decimal.Decimal, float) + six.integer_types):
          return number_format(value)
      elif isinstance(value, datetime.datetime):
          value = datetime_safe.new_datetime(value)
          format = force_str(default or get_format('DATETIME_INPUT_FORMATS')[0])
          return value.strftime(format)
 
</s> remove     if isinstance(value, six.string_types):  # Handle strings first for performance reasons.
 </s> add     if isinstance(value, str):  # Handle strings first for performance reasons. </s> remove         return mark_safe(six.text_type(value))
    elif isinstance(value, (decimal.Decimal, float) + six.integer_types):
 </s> add         return mark_safe(str(value))
    elif isinstance(value, (decimal.Decimal, float, int)): </s> remove     if isinstance(value, six.string_types):  # Handle strings first for performance reasons.
 </s> add     if isinstance(value, str):  # Handle strings first for performance reasons. </s> remove     elif isinstance(value, six.integer_types + (decimal.Decimal, float)):
 </s> add     elif isinstance(value, (int, decimal.Decimal, float)): </s> remove         elif isinstance(value, six.string_types):
            return "'%s'" % six.text_type(value).replace("\'", "\'\'")
        elif isinstance(value, six.buffer_types):
 </s> add         elif isinstance(value, str):
            return "'%s'" % value.replace("\'", "\'\'")
        elif isinstance(value, (bytes, bytearray, memoryview)):
        return str(value)
    elif isinstance(value, (decimal.Decimal, float, int)):
      """
      if isinstance(value, six.string_types):  # Handle strings first for performance reasons.
          return value
      elif isinstance(value, bool):  # Don't treat booleans as numbers.
        return str(value)
    elif isinstance(value, (decimal.Decimal, float, int)):
        return str(value)
    elif isinstance(value, (decimal.Decimal, float, int)):
          return number_format(value)
      elif isinstance(value, datetime.datetime):
          value = datetime_safe.new_datetime(value)
          format = force_str(default or get_format('DATETIME_INPUT_FORMATS')[0])
          return value.strftime(format)
keep keep keep keep replace replace keep keep keep keep keep
 Refs #23919 -- Removed six.<various>_types usage

Thanks Tim Graham and Simon Charette for the reviews. 
django/utils/formats.py