Django

Code

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@debian.org>, 10 months ago)
  • a/django/core/validators.py

    old new  
    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])?' 
     
    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: