Fix decoding of strings in ircmsgs. Thanks to monodemono.

This commit is contained in:
Valentin Lorentz 2013-02-25 11:37:15 +00:00
parent f65c0539d8
commit 8444e76468

View File

@ -536,7 +536,7 @@ def kick(channel, nick, s='', prefix='', msg=None):
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='KICK',
@ -554,7 +554,7 @@ def kicks(channel, nicks, s='', prefix='', msg=None):
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='KICK',
@ -569,7 +569,7 @@ def privmsg(recipient, s, prefix='', msg=None):
assert (isChannel(recipient) or isNick(recipient)), repr(recipient)
assert s, 's must not be empty.'
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(s, str)
if msg and not prefix:
prefix = msg.prefix
@ -601,7 +601,7 @@ def notice(recipient, s, prefix='', msg=None):
assert (isChannel(recipient) or isNick(recipient)), repr(recipient)
assert s, 'msg must not be empty.'
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(s, str)
if msg and not prefix:
prefix = msg.prefix
@ -651,7 +651,7 @@ def part(channel, s='', prefix='', msg=None):
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
@ -667,7 +667,7 @@ def parts(channels, s='', prefix='', msg=None):
if msg and not prefix:
prefix = msg.prefix
if sys.version_info[0] < 3 and isinstance(s, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
@ -696,7 +696,7 @@ def topic(channel, topic=None, prefix='', msg=None):
args=(channel,), msg=msg)
else:
if sys.version_info[0] < 3 and isinstance(topic, unicode):
s = s.decode('utf8')
s = s.encode('utf8')
assert isinstance(topic, str)
return IrcMsg(prefix=prefix, command='TOPIC',
args=(channel, topic), msg=msg)