From 8f5496b32242a13c8144ea7b794b7803ba58fd91 Mon Sep 17 00:00:00 2001
From: Bastian Kleineidam <calvin@debian.org>
Date: Fri, 25 Jan 2008 21:46:36 +0100
Subject: isValidFloat() should handle Unicode data
The isValidFloat() can receive Unicode data in which case str() fails.
The patch uses smart_str() to cope with this.
Signed-off-by: Bastian Kleineidam <calvin@debian.org>
diff --git a/django/core/validators.py b/django/core/validators.py
index a051077..b5c4516 100644
a
|
b
|
except ImportError:
|
18 | 18 | from django.conf import settings |
19 | 19 | from django.utils.translation import ugettext as _, ugettext_lazy, ungettext |
20 | 20 | from django.utils.functional import Promise, lazy |
21 | | from django.utils.encoding import force_unicode |
| 21 | from django.utils.encoding import force_unicode, smart_str |
22 | 22 | |
23 | 23 | _datere = r'\d{4}-\d{1,2}-\d{1,2}' |
24 | 24 | _timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?' |
… |
… |
class IsValidDecimal(object):
|
451 | 451 | "Please enter a valid decimal number with at most %s decimal places.", self.decimal_places) % self.decimal_places |
452 | 452 | |
453 | 453 | def isValidFloat(field_data, all_data): |
454 | | data = str(field_data) |
| 454 | data = smart_str(field_data) |
455 | 455 | try: |
456 | 456 | float(data) |
457 | 457 | except ValueError: |