Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #6014 -- More robust error handling when validating decimal fie…


Thanks, pigletto.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 29892d02fa9c9ab3e48a18a143408abc3c88716e 1 parent 7a166f1
@malcolmt malcolmt authored
4 django/newforms/
@@ -17,7 +17,7 @@
from sets import Set as set
from django.utils.translation import ugettext_lazy as _
-from django.utils.encoding import StrAndUnicode, smart_unicode
+from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str
from util import ErrorList, ValidationError
from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput
@@ -235,7 +235,7 @@ def clean(self, value):
super(DecimalField, self).clean(value)
if not self.required and value in EMPTY_VALUES:
return None
- value = str(value).strip()
+ value = smart_str(value).strip()
value = Decimal(value)
except DecimalException:
4 tests/regressiontests/forms/
@@ -323,6 +323,10 @@
Traceback (most recent call last):
ValidationError: [u'Enter a number.']
+>>> f.clean(u'łąść')
+Traceback (most recent call last):
+ValidationError: [u'Enter a number.']
>>> f.clean('1.0 ')
>>> f.clean(' 1.0')
Please sign in to comment.
Something went wrong with that request. Please try again.