aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-10-19 16:58:30 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2017-10-19 17:19:26 +0200
commita5b918d210965d95291d6e1a983b964db593ccd5 (patch)
tree933ded2781fe05dc50c833ede0f660c733d5b477
parent504411f48ebf1c5a6b8679153cca05a642e19d2e (diff)
downloadwee-slack-a5b918d210965d95291d6e1a983b964db593ccd5.tar.gz
Preserve mapping types in decode_from_utf8/encode_to_utf8
-rw-r--r--wee_slack.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 2ac50c0..2448c6e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -113,7 +113,7 @@ def encode_to_utf8(data):
if isinstance(data, bytes):
return data
elif isinstance(data, collections.Mapping):
- return dict(map(encode_to_utf8, data.iteritems()))
+ return type(data)(map(encode_to_utf8, data.iteritems()))
elif isinstance(data, collections.Iterable):
return type(data)(map(encode_to_utf8, data))
else:
@@ -126,7 +126,7 @@ def decode_from_utf8(data):
if isinstance(data, unicode):
return data
elif isinstance(data, collections.Mapping):
- return dict(map(decode_from_utf8, data.iteritems()))
+ return type(data)(map(decode_from_utf8, data.iteritems()))
elif isinstance(data, collections.Iterable):
return type(data)(map(decode_from_utf8, data))
else: