Ticket #12645: bugfix.diff

File bugfix.diff, 1002 bytes (added by Alan Justino da Silva, 15 years ago)

Bugfix - use a try-catch to workarround hasattr ASCII limitation

  • django/forms/forms.py

     
    275275                else:
    276276                    value = field.clean(value)
    277277                self.cleaned_data[name] = value
    278                 if hasattr(self, 'clean_%s' % name):
    279                     value = getattr(self, 'clean_%s' % name)()
    280                     self.cleaned_data[name] = value
     278                try:
     279                    if hasattr(self, 'clean_%s' % name):
     280                        value = getattr(self, 'clean_%s' % name)()
     281                        self.cleaned_data[name] = value
     282                except UnicodeEncodeError, e:
     283                    # hasattr can't handle non-ascii characters: just pass.
     284                    pass
    281285            except ValidationError, e:
    282286                self._errors[name] = self.error_class(e.messages)
    283287                if name in self.cleaned_data:
Back to Top