From bbf91d4ceea5afa5c7f16182e94143b1915935f8 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Sun, 17 Oct 2010 10:04:32 +0000 Subject: XoColor: don't choke if passed the wrong type (SL#1408) Color data is stored in the Journal as a JSON dump, so we can get back arbitrary types. XoColor already checks the color string for validity and handles invalid strings gracefully, so it makes sense to enhance this to invalid types as well. --- diff --git a/src/sugar/graphics/xocolor.py b/src/sugar/graphics/xocolor.py index df60917..395e345 100644 --- a/src/sugar/graphics/xocolor.py +++ b/src/sugar/graphics/xocolor.py @@ -209,6 +209,10 @@ colors = [ def _parse_string(color_string): + if not isinstance(color_string, (str, unicode)): + logging.error('Invalid color string: %r', color_string) + return None + if color_string == 'white': return ['#ffffff', '#414141'] elif color_string == 'insensitive': -- cgit v0.9.1