From 8c5a41baf0bd2a1388d601e5b49d06b91997ccb8 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 6 Aug 2020 15:15:02 -0700 Subject: Remove support for end-of-life Python 2.7 (#1318) Remove support for end-of-life Python 2.7 Python 2.7 is end of life. It is no longer receiving bug fixes, including for security issues. Python 2.7 went EOL on 2020-01-01. For additional details on support Python versions, see: Supported: https://devguide.python.org/#status-of-python-branches EOL: https://devguide.python.org/devcycle/#end-of-life-branches Removing support for EOL Pythons will reduce testing and maintenance resources while allowing the library to move towards a modern Python 3 style. Python 2.7 users can continue to use the previous version of redis-py. Was able to simplify the code: - Removed redis._compat module - Removed __future__ imports - Removed object from class definition (all classes are new style) - Removed long (Python 3 unified numeric types) - Removed deprecated __nonzero__ method - Use simpler Python 3 super() syntax - Use unified OSError exception - Use yield from syntax Co-authored-by: Andy McCurdy --- redis/utils.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'redis/utils.py') diff --git a/redis/utils.py b/redis/utils.py index 6ef6fd4..3664708 100644 --- a/redis/utils.py +++ b/redis/utils.py @@ -26,8 +26,13 @@ def pipeline(redis_obj): p.execute() -class dummy(object): - """ - Instances of this class can be used as an attribute container. - """ - pass +def str_if_bytes(value): + return ( + value.decode('utf-8', errors='replace') + if isinstance(value, bytes) + else value + ) + + +def safe_str(value): + return str(str_if_bytes(value)) -- cgit v1.2.1