refactor: Remove dict_with_str_keys().

This function is no longer needed in python3, as it was decoding
keys that already came for a JSON-decoded string.
This commit is contained in:
Steve Howell
2017-11-04 11:22:54 -07:00
committed by Tim Abbott
parent b0bb09cdb8
commit 8eaeba8615
2 changed files with 1 additions and 7 deletions

View File

@@ -15,7 +15,6 @@ from zerver.lib.cache import (
to_dict_cache_key_id,
)
from zerver.lib.request import JsonableError
from zerver.lib.str_utils import dict_with_str_keys
from zerver.lib.stream_subscription import (
get_stream_subscriptions_for_user,
)
@@ -111,7 +110,7 @@ def sew_messages_and_reactions(messages, reactions):
def extract_message_dict(message_bytes):
# type: (bytes) -> Dict[str, Any]
return dict_with_str_keys(ujson.loads(zlib.decompress(message_bytes).decode("utf-8")))
return ujson.loads(zlib.decompress(message_bytes).decode("utf-8"))
def stringify_message_dict(message_dict):
# type: (Dict[str, Any]) -> bytes

View File

@@ -66,11 +66,6 @@ def force_str(s, encoding='utf-8'):
else:
raise TypeError("force_str expects a string type")
def dict_with_str_keys(dct, encoding='utf-8'):
# type: (Mapping[NonBinaryStr, Any], str) -> Dict[str, Any]
"""applies force_str on the keys of a dict (non-recursively)"""
return {force_str(key, encoding): value for key, value in dct.items()}
class ModelReprMixin:
"""
This mixin provides a python 2 and 3 compatible way of handling string representation of a model.