Commits

Andriy Kornatskyy committed 2bc064b

Convert original_value to unicode before using gettext for errors.

Comments (0)

Files changed (3)

i18n/en/LC_MESSAGES/validation.po

 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:131 src/wheezy/validation/model.py:135
+#: src/wheezy/validation/model.py:131 src/wheezy/validation/model.py:132
+#: src/wheezy/validation/model.py:135
 msgid "Multiple input was not in a correct format."
 msgstr "Multiple input was not in a correct format."
 
-#: src/wheezy/validation/model.py:146 src/wheezy/validation/model.py:150
+#: src/wheezy/validation/model.py:146 src/wheezy/validation/model.py:147
+#: src/wheezy/validation/model.py:150
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/model.py:154 src/wheezy/validation/model.py:158
+#: src/wheezy/validation/model.py:154 src/wheezy/validation/model.py:155
+#: src/wheezy/validation/model.py:158
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:157 src/wheezy/validation/model.py:161
+#: src/wheezy/validation/model.py:157 src/wheezy/validation/model.py:159
+#: src/wheezy/validation/model.py:161
 msgid "Input was not in a correct format."
 msgstr "Input was not in a correct format."
 

i18n/validation.po

 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:131 src/wheezy/validation/model.py:135
+#: src/wheezy/validation/model.py:131 src/wheezy/validation/model.py:132
+#: src/wheezy/validation/model.py:135
 msgid "Multiple input was not in a correct format."
 msgstr "Multiple input was not in a correct format."
 
-#: src/wheezy/validation/model.py:146 src/wheezy/validation/model.py:150
+#: src/wheezy/validation/model.py:146 src/wheezy/validation/model.py:147
+#: src/wheezy/validation/model.py:150
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/model.py:154 src/wheezy/validation/model.py:158
+#: src/wheezy/validation/model.py:154 src/wheezy/validation/model.py:155
+#: src/wheezy/validation/model.py:158
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:157 src/wheezy/validation/model.py:161
+#: src/wheezy/validation/model.py:157 src/wheezy/validation/model.py:159
+#: src/wheezy/validation/model.py:161
 msgid "Input was not in a correct format."
 msgstr "Input was not in a correct format."
 

src/wheezy/validation/model.py

 from decimal import Decimal
 from time import strptime
 
+from wheezy.validation.comp import ntos
 from wheezy.validation.comp import null_translations
 from wheezy.validation.comp import ref_gettext
 from wheezy.validation.format import decimal_separator
                 if value is None:
                     results[name] = [gettext(
                         "The value '%s' is not in one of supported formats."
-                        % original_value)]
+                        % ntos(original_value))]
                     succeed = False
                 else:
                     setter(model, name, value)
             except (ArithmeticError, ValueError):
                 if original_value:
                     results[name] = [gettext(
-                        "The value '%s' is invalid.") % original_value]
+                        "The value '%s' is invalid."
+                        ) % ntos(original_value)]
                 else:
                     results[name] = [gettext(
                         "Input was not in a correct format.")]
 
 value_providers = {
         'str': lambda str_value, gettext: str_value,
-        'unicode': lambda str_value, gettext: str_value.decode('utf-8'),
+        'unicode': lambda str_value, gettext: str_value.decode('UTF-8'),
         'int': int_value_provider,
         'Decimal': decimal_value_provider,
         'bool': bool_value_provider,