From 9def988a85d414e07e0ae42c9e294ccffad82b7d Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 5 May 2014 10:08:21 +0200 Subject: [PATCH] Flip conditional sides of helper definitions (no semantic change). --- rq/compat/__init__.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rq/compat/__init__.py b/rq/compat/__init__.py index ac9b7a9..a7817b4 100644 --- a/rq/compat/__init__.py +++ b/rq/compat/__init__.py @@ -41,21 +41,11 @@ else: return cls -PY2 = sys.version_info[0] < 3 - -if PY2: - string_types = (str, unicode) - text_type = unicode - - def as_text(v): - return v - - def decode_redis_hash(h): - return h - -else: - string_types = (str,) +PY2 = sys.version_info[0] == 2 +if not PY2: + # Python 3.x and up text_type = str + string_types = (str,) def as_text(v): if v is None: @@ -69,3 +59,13 @@ else: def decode_redis_hash(h): return dict((as_text(k), h[k]) for k in h) +else: + # Python 2.x + text_type = unicode + string_types = (str, unicode) + + def as_text(v): + return v + + def decode_redis_hash(h): + return h