  
          def raise_exception(value):
              raise exceptions.ValidationError('Raised error')
  
          for validators in ([raise_exception], (raise_exception,), set([raise_exception])):
              class ExampleSerializer(serializers.Serializer):
                  char = serializers.CharField(validators=validators)
                  integer = serializers.IntegerField()
  
              serializer = ExampleSerializer(data=data)
 
</s> remove         for validators in ([raise_exception], (raise_exception,), set([raise_exception])):
 </s> add         for validators in ([raise_exception], (raise_exception,), {raise_exception}): </s> remove         class ExampleInstance(object):
 </s> add         class ExampleInstance: </s> remove         class ExampleInstance(object):
 </s> add         class ExampleInstance: </s> remove             six.text_type(key): key for key in self.choices
 </s> add             str(key): key for key in self.choices </s> remove         six.reraise(type(exc), exc, info[2])
 </s> add         raise exc.with_traceback(info[2])
        for validators in ([raise_exception], (raise_exception,), {raise_exception}):
  
          def raise_exception(value):
              raise exceptions.ValidationError('Raised error')
  
        for validators in ([raise_exception], (raise_exception,), {raise_exception}):
              class ExampleSerializer(serializers.Serializer):
                  char = serializers.CharField(validators=validators)
                  integer = serializers.IntegerField()
  
              serializer = ExampleSerializer(data=data)
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> 
tests/test_serializer.py