From e48cdb8d7e20eb6a09fa095449a6c60006612d5b Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 9 Sep 2016 15:36:17 -0700 Subject: [PATCH] Fix python 3 compatibility in logging code. Detected by mypy. --- zerver/lib/logging_util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zerver/lib/logging_util.py b/zerver/lib/logging_util.py index 79630ecdd5..c4d0493edd 100644 --- a/zerver/lib/logging_util.py +++ b/zerver/lib/logging_util.py @@ -4,6 +4,7 @@ import hashlib import logging import traceback from datetime import datetime, timedelta +from zerver.lib.str_utils import force_bytes # Adapted http://djangosnippets.org/snippets/2242/ by user s29 (October 25, 2010) @@ -28,7 +29,7 @@ class _RateLimitFilter(object): use_cache = False if use_cache: - tb = '\n'.join(traceback.format_exception(*record.exc_info)) + tb = force_bytes('\n'.join(traceback.format_exception(*record.exc_info))) key = self.__class__.__name__.upper() + hashlib.sha1(tb).hexdigest() duplicate = cache.get(key) == 1 if not duplicate: