Filter: Fix @unhexlify for Python 3.

This commit is contained in:
Valentin Lorentz 2013-07-16 19:54:10 +00:00
parent cf6084e402
commit cc56645cf9
2 changed files with 3 additions and 1 deletions

View File

@ -196,7 +196,8 @@ class Filter(callbacks.Plugin):
<hexstring> must be a string of hexadecimal digits. <hexstring> must be a string of hexadecimal digits.
""" """
try: try:
irc.reply(self._hex_decoder(text.encode('utf8'))[0].decode('utf8')) irc.reply(self._hex_decoder(text.encode('utf8'))[0]
.decode('utf8', 'replace'))
except TypeError: except TypeError:
irc.error(_('Invalid input.')) irc.error(_('Invalid input.'))
unhexlify = wrap(unhexlify, ['text']) unhexlify = wrap(unhexlify, ['text'])

View File

@ -102,6 +102,7 @@ class FilterTest(ChannelPluginTestCase):
def testHexlifyUnhexlify(self): def testHexlifyUnhexlify(self):
for s in map(str, range(1000, 1010)): for s in map(str, range(1000, 1010)):
self.assertResponse('unhexlify [hexlify %s]' % s, s) self.assertResponse('unhexlify [hexlify %s]' % s, s)
self.assertNotError('unhexlify ff')
def testScramble(self): def testScramble(self):
s = 'the recalcitrant jamessan tests his scramble function' s = 'the recalcitrant jamessan tests his scramble function'