Filter: Fix encoding issue on Python 3.

This commit is contained in:
Valentin Lorentz 2013-07-30 17:35:45 +00:00
parent 4d801a02c5
commit 53c7c9beaa

View File

@ -412,8 +412,12 @@ class Filter(callbacks.Plugin):
Returns <text> colorized like a rainbow. Returns <text> colorized like a rainbow.
""" """
if sys.version_info[0] < 3:
text = text.decode('utf-8')
colors = utils.iter.cycle(['04', '07', '08', '03', '02', '12', '06']) colors = utils.iter.cycle(['04', '07', '08', '03', '02', '12', '06'])
L = [self._color(c, fg=colors.next()) for c in text] L = [self._color(c, fg=colors.next()) for c in text]
if sys.version_info[0] < 3:
L = [c.encode('utf-8') for c in L]
irc.reply(''.join(L) + '\x03') irc.reply(''.join(L) + '\x03')
rainbow = wrap(rainbow, ['text']) rainbow = wrap(rainbow, ['text'])