[telepathy-idle-0.2] telepathy-idle: Avoid errors from Python caused by the deliberatly invalid Unicode
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Oct 31 22:13:15 UTC 2020
Module: telepathy-idle
Branch: telepathy-idle-0.2
Commit: 0ce3a8fa2bd3f4e72358bb53ecd0acf8fe448483
URL: http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=0ce3a8fa2bd3f4e72358bb53ecd0acf8fe448483
Author: Diane Trout <diane at ghic.org>
Date: Sat Nov 4 23:32:32 2017 -0700
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.
---
tests/twisted/messages/invalid-utf8.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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
More information about the telepathy-commits
mailing list