Ticket #6014: decimal_v6710.patch

File decimal_v6710.patch, 1.4 KB (added by Maciej Wiśniowski, 17 years ago)

patch with tests against revision 6710

  • django/newforms/fields.py

     
    1717    from sets import Set as set
    1818
    1919from django.utils.translation import ugettext_lazy as _
    20 from django.utils.encoding import StrAndUnicode, smart_unicode
     20from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str
    2121
    2222from util import ErrorList, ValidationError
    2323from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput
     
    235235        super(DecimalField, self).clean(value)
    236236        if not self.required and value in EMPTY_VALUES:
    237237            return None
    238         value = str(value).strip()
     238        value = smart_str(value).strip()
    239239        try:
    240240            value = Decimal(value)
    241241        except DecimalException:
  • tests/regressiontests/forms/fields.py

     
    323323Traceback (most recent call last):
    324324...
    325325ValidationError: [u'Enter a number.']
     326>>> f.clean(u'łąść')
     327Traceback (most recent call last):
     328...
     329ValidationError: [u'Enter a number.']
    326330>>> f.clean('1.0 ')
    327331Decimal("1.0")
    328332>>> f.clean(' 1.0')
Back to Top