mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +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>
(cherry picked from commit 01c8dc7f78
)
Signed-off-by: Daniel Folkinshteyn <nanotube@users.sourceforge.net>
This commit is contained in:
parent
f9377108b0
commit
50e4b6baf1
@ -81,7 +81,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