Fix encoding issues with Alias containing non-ascii characters.

This commit is contained in:
Valentin Lorentz 2013-05-31 15:42:57 +02:00
parent b360871378
commit cefd91d4f1
2 changed files with 6 additions and 2 deletions

View File

@ -68,6 +68,8 @@ class AliasTestCase(ChannelPluginTestCase):
def testAliasHelp(self):
self.assertNotError('alias add slashdot foo')
self.assertRegexp('help slashdot', "Alias for .*foo")
self.assertNotError('alias add nonascii echo éé')
self.assertRegexp('help nonascii', "Alias for .*echo éé")
def testRemove(self):
self.assertNotError('alias add foo echo bar')

View File

@ -444,10 +444,12 @@ def format(s, *args, **kwargs):
char = match.group(1)
if char == 's':
token = args.pop()
if isinstance(token, unicode) or isinstance(token, str):
if isinstance(token, str):
return token
elif sys.version_info[0] < 3 and isinstance(token, unicode):
return token.encode('utf8')
else:
return unicode(token)
return str(token)
elif char == 'i':
# XXX Improve me!
return str(args.pop())