summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiane Trout <diane@ghic.org>2017-11-04 23:32:32 -0700
committerDiane Trout <diane@ghic.org>2017-11-04 23:32:32 -0700
commit0ce3a8fa2bd3f4e72358bb53ecd0acf8fe448483 (patch)
tree0ff1715f8e56f1b416967aaa59b6911baaa03137
parent5a2510ddea8f165f0808a8841e1dca311c003e20 (diff)
downloadtelepathy-idle-0ce3a8fa2bd3f4e72358bb53ecd0acf8fe448483.tar.gz
Avoid errors from Python caused by the deliberatly invalid Unicode
Because stream.nick is Unicode when sendMessage combines the command, nick, and invalid utf8 python 2.7 ends up converting everything to Unicode. Since this test deliberately includes invalid Unicode, Python notices and throws an exception. In Python 3, network traffic is usually encoded as bytes. So I thought coercing the nick to bytes would be appropriate, and as bytes can contain anything including invalid Unicode, Python doesn't throw an exception.
-rw-r--r--tests/twisted/messages/invalid-utf8.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/twisted/messages/invalid-utf8.py b/tests/twisted/messages/invalid-utf8.py
index a48c2f4..725e3bd 100644
--- a/tests/twisted/messages/invalid-utf8.py
+++ b/tests/twisted/messages/invalid-utf8.py
@@ -33,7 +33,7 @@ def test_with_message(q, stream, parts):
# Idle's default character set is UTF-8. We send it a message which is
# basically UTF-8, except that one of its code points is invalid.
- stream.sendMessage('PRIVMSG', stream.nick, ':%s' % invalid_utf8,
+ stream.sendMessage('PRIVMSG', bytes(stream.nick), ':%s' % invalid_utf8,
prefix='remoteuser')
# Idle should signal that *something* was received. If it hasn't validated