Filter & Google: Fix Python 3.2 compatibility.

This commit is contained in:
Valentin Lorentz 2015-08-10 19:14:22 +02:00
parent 8ad16701ce
commit 23ddfbc7e3
3 changed files with 5 additions and 4 deletions

View File

@ -703,7 +703,7 @@ class Filter(callbacks.Plugin):
if c in self._uniudMap: if c in self._uniudMap:
tmp = self._uniudMap[c] tmp = self._uniudMap[c]
if not len(tmp): if not len(tmp):
tmp = u'\ufffd' tmp = '\ufffd'
turned.append(tmp) turned.append(tmp)
tlen += 1 tlen += 1
elif c == '\t': elif c == '\t':
@ -713,7 +713,7 @@ class Filter(callbacks.Plugin):
elif ord(c) >= 32: elif ord(c) >= 32:
turned.append(c) turned.append(c)
tlen += 1 tlen += 1
s = u'%s \x02 \x02' % u''.join(reversed(turned)) s = '%s \x02 \x02' % ''.join(reversed(turned))
irc.reply(s) irc.reply(s)
uniud = wrap(uniud, ['text']) uniud = wrap(uniud, ['text'])
Filter = internationalizeDocstring(Filter) Filter = internationalizeDocstring(Filter)

View File

@ -37,6 +37,7 @@ import codecs
import supybot.utils as utils import supybot.utils as utils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
from supybot.minisix import u
class FilterTest(ChannelPluginTestCase): class FilterTest(ChannelPluginTestCase):
plugins = ('Filter', 'Utilities', 'Reply') plugins = ('Filter', 'Utilities', 'Reply')
@ -98,7 +99,7 @@ class FilterTest(ChannelPluginTestCase):
self.assertResponse('rot13 [rot13 %s]' % s, s) self.assertResponse('rot13 [rot13 %s]' % s, s)
def testRot13HandlesNonAsciiStuff(self): def testRot13HandlesNonAsciiStuff(self):
self.assertNotError(u'rot13 é') self.assertNotError(u('rot13 é'))
def testHexlifyUnhexlify(self): def testHexlifyUnhexlify(self):
for s in map(str, range(1000, 1010)): for s in map(str, range(1000, 1010)):

View File

@ -152,7 +152,7 @@ class Google(callbacks.PluginRegexp):
elif onetoone: elif onetoone:
return results return results
else: else:
return [u'; '.join(results)] return [minisix.u('; ').join(results)]
@internationalizeDocstring @internationalizeDocstring
def lucky(self, irc, msg, args, opts, text): def lucky(self, irc, msg, args, opts, text):