From 2bdbd719a796777e72627281c163bf51b6d03114 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Wed, 27 Mar 2019 13:18:11 +0100 Subject: Make encode_to/decode_from_utf8 noop in python 3 Python 3 receives unicode strings as arguments in weechat callbacks, websocet receive etc. and we can send unicode strings to weechat functions, websocket etc., so we don't need to do any of this converting. --- wee_slack.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'wee_slack.py') diff --git a/wee_slack.py b/wee_slack.py index 8b659f6..758c522 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -143,7 +143,9 @@ EMOJI = [] def encode_to_utf8(data): - if isinstance(data, unicode): + if sys.version_info.major > 2: + return data + elif isinstance(data, unicode): return data.encode('utf-8') if isinstance(data, bytes): return data @@ -156,7 +158,9 @@ def encode_to_utf8(data): def decode_from_utf8(data): - if isinstance(data, bytes): + if sys.version_info.major > 2: + return data + elif isinstance(data, bytes): return data.decode('utf-8') if isinstance(data, unicode): return data -- cgit