mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 03:33:11 +01:00
String.decode: Only encode('utf-8') when the decode string is unicode
Closes: Sf#3165718 Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
parent
8f7c4bdf7f
commit
01c8dc7f78
@ -79,7 +79,12 @@ class String(callbacks.Plugin):
|
||||
<http://docs.python.org/library/codecs.html#standard-encodings>.
|
||||
"""
|
||||
try:
|
||||
irc.reply(text.decode(encoding).encode('utf-8'))
|
||||
s = text.decode(encoding)
|
||||
# Not all encodings decode to a unicode object. Only encode those
|
||||
# that do.
|
||||
if isinstance(s, unicode):
|
||||
s = s.encode('utf-8')
|
||||
irc.reply(s)
|
||||
except LookupError:
|
||||
irc.errorInvalid('encoding', encoding)
|
||||
except binascii.Error:
|
||||
|
Loading…
Reference in New Issue
Block a user