def clean(self, value):
        """
        Validate that the value is in self.choices and can be coerced to the
        right type.
        """
        value = super(TypedChoiceField, self).clean(value)
        if value == self.empty_value or value in EMPTY_VALUES:
            return self.empty_value

        # Hack alert: This field is purpose-made to use with Field.to_python as
        # a coercion function so that ModelForms with choices work. However,
        # Django's Field.to_python raises
        # django.core.exceptions.ValidationError, which is a *different*
        # exception than django.forms.util.ValidationError. So we need to catch
        # both.
        try:
            value = self.coerce(value)
        except (ValueError, TypeError, django.core.exceptions.ValidationError):
            raise ValidationError({'value': value} % self.error_messages['invalid_choice'])
        return value
dataset/ETHPy150Open CollabQ/CollabQ/vendor/django/forms/fields.py/TypedChoiceField.clean/swapped operands of `%`