diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2019-03-27 13:18:11 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-04-08 15:11:57 +0200 |
commit | 2bdbd719a796777e72627281c163bf51b6d03114 (patch) | |
tree | 1782862a61993b27d1efec7d08e44b38406a6df8 /wee_slack.py | |
parent | e40cfb66a19c2bf3b8c01f3e056ea56914aea18c (diff) | |
download | wee-slack-2bdbd719a796777e72627281c163bf51b6d03114.tar.gz |
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.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 8 |
1 files changed, 6 insertions, 2 deletions
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 |