Ticket #7777: code_and_tests.diff
File code_and_tests.diff, 1.3 KB (added by , 15 years ago) |
---|
-
django/forms/fields.py
249 249 except DecimalException: 250 250 raise ValidationError(self.error_messages['invalid']) 251 251 252 # value != value => NaN is never equal to itself, all other decimals are. 253 if value != value or value == Decimal("Inf") or value == Decimal("-Inf"): 254 raise ValidationError(self.error_messages['invalid']) 255 252 256 sign, digittuple, exponent = value.as_tuple() 253 257 decimals = abs(exponent) 254 258 # digittuple doesn't include any leading zeros. -
tests/regressiontests/forms/fields.py
320 320 True 321 321 >>> f.clean(Decimal('3.14')) == Decimal("3.14") 322 322 True 323 >>> f.clean('NaN') 324 Traceback (most recent call last): 325 ... 326 ValidationError: [u'Enter a number.'] 327 >>> f.clean('Inf') 328 Traceback (most recent call last): 329 ... 330 ValidationError: [u'Enter a number.'] 331 >>> f.clean('-Inf') 332 Traceback (most recent call last): 333 ... 334 ValidationError: [u'Enter a number.'] 323 335 >>> f.clean('a') 324 336 Traceback (most recent call last): 325 337 ...