From 3f44ab8e181ce12c9e55f361b1131699d1c97d05 Mon Sep 17 00:00:00 2001 From: Felix Yan Date: Fri, 30 Oct 2015 15:50:28 +0800 Subject: [PATCH] Fix unparse_color for python 3.5+ compatibility --- pygal/colors.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygal/colors.py b/pygal/colors.py index bc8ea55..7997b38 100644 --- a/pygal/colors.py +++ b/pygal/colors.py @@ -126,19 +126,20 @@ def unparse_color(r, g, b, a, type): if type == '#rgb': # Don't lose precision on rgb shortcut if r % 17 == 0 and g % 17 == 0 and b % 17 == 0: - return '#%x%x%x' % (r / 17, g / 17, b / 17) + return '#%x%x%x' % (int(r / 17), int(g / 17), int(b / 17)) type = '#rrggbb' if type == '#rgba': if r % 17 == 0 and g % 17 == 0 and b % 17 == 0: - return '#%x%x%x%x' % (r / 17, g / 17, b / 17, a * 15) + return '#%x%x%x%x' % (int(r / 17), int(g / 17), int(b / 17), + int(a * 15)) type = '#rrggbbaa' if type == '#rrggbb': return '#%02x%02x%02x' % (r, g, b) if type == '#rrggbbaa': - return '#%02x%02x%02x%02x' % (r, g, b, a * 255) + return '#%02x%02x%02x%02x' % (r, g, b, int(a * 255)) if type == 'rgb': return 'rgb(%d, %d, %d)' % (r, g, b)