Commits

Andriy Kornatskyy committed ab0dcd7

If format provider is unknown apply str_type.

  • Participants
  • Parent commits bea5a9b

Comments (0)

Files changed (1)

File src/wheezy/html/utils.py

         ['1', '2', '7']
         >>> format_value([])
         ()
+
+        If format provider is unknown apply str_type.
+
+        >>> str(format_value({}))
+        '{}'
     """
     # TODO: probably there is better check since attribute check for
     # __iter__ is not valid in python 3.2, str support it.
     else:
         if format_provider is None:
             formatter_name = type(value).__name__
-            format_provider = format_providers[formatter_name]
+            if formatter_name in format_providers:
+                format_provider = format_providers[formatter_name]
+            else:
+                return str_type(value)
         return format_provider(value, format_spec)