All pastes #28925 Raw Edit

patch kiwi.datatype

public text v1 · immutable
#28925 ·published 2005-11-16 17:19 UTC
rendered paste body
Index: datatypes.py
===================================================================
--- datatypes.py	(revisão 1638)
+++ datatypes.py	(cópia de trabalho)
@@ -153,10 +153,7 @@
         # Check so we only have one decimal point
         decimal_point = conv["decimal_point"]
         decimal_points = value.count(decimal_point)
-        if decimal_points == 1:
-            # Replace the decimal point with a dot, which float() can handle
-            value = value.replace(decimal_point, '.')
-        elif decimal_points > 1:
+        if decimal_points > 1:
             raise ValidationError(
                 'You have more than one decimal point ("%s") '
                 ' in your number "%s"' % (decimal_point, value))
@@ -192,7 +189,9 @@
                                       "separators") 

         # Remove all thousand separators
-        return value.replace(thousands_sep, '')
+        value = value.replace(thousands_sep, '')        
+        value = value.replace(decimal_point, '.')
+        return value
 
     def as_string(self, value, format='%f'):
         """Convert a float to a string"""