Ticket #6492: 0023-isValidFloat-should-handle-Unicode-data.patch

File 0023-isValidFloat-should-handle-Unicode-data.patch, 1.3 KB (added by Bastian Kleineidam <calvin@…>, 17 years ago)
  • django/core/validators.py

    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:  
    1818from django.conf import settings
    1919from django.utils.translation import ugettext as _, ugettext_lazy, ungettext
    2020from django.utils.functional import Promise, lazy
    21 from django.utils.encoding import force_unicode
     21from django.utils.encoding import force_unicode, smart_str
    2222
    2323_datere = r'\d{4}-\d{1,2}-\d{1,2}'
    2424_timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
    class IsValidDecimal(object):  
    451451                "Please enter a valid decimal number with at most %s decimal places.", self.decimal_places) % self.decimal_places
    452452
    453453def isValidFloat(field_data, all_data):
    454     data = str(field_data)
     454    data = smart_str(field_data)
    455455    try:
    456456        float(data)
    457457    except ValueError:
Back to Top