diff --git a/kombu/utils/encoding.py b/kombu/utils/encoding.py index b1ddeeb3..93788bde 100644 --- a/kombu/utils/encoding.py +++ b/kombu/utils/encoding.py @@ -10,9 +10,8 @@ from __future__ import absolute_import, unicode_literals import sys import traceback -from kombu.five import text_t +from kombu.five import PY3, text_t -is_py3k = sys.version_info >= (3, 0) #: safe_str takes encoding from this file by default. #: :func:`set_default_encoding_file` can used to set the @@ -43,7 +42,7 @@ else: file = file or get_default_encoding_file() return getattr(file, 'encoding', None) or sys.getfilesystemencoding() -if is_py3k: # pragma: no cover +if PY3: # pragma: no cover def str_to_bytes(s): """Convert str to bytes.""" @@ -111,7 +110,7 @@ def safe_str(s, errors='replace'): return _safe_str(s, errors) -if is_py3k: # pragma: no cover +if PY3: # pragma: no cover def _safe_str(s, errors='replace', file=None): if isinstance(s, str): diff --git a/kombu/utils/json.py b/kombu/utils/json.py index 3f9f194f..b2466a45 100644 --- a/kombu/utils/json.py +++ b/kombu/utils/json.py @@ -5,10 +5,9 @@ from __future__ import absolute_import, unicode_literals import datetime import decimal import json as stdjson -import sys import uuid -from kombu.five import buffer_t, text_t, bytes_t +from kombu.five import PY3, buffer_t, text_t, bytes_t try: from django.utils.functional import Promise as DjangoPromise @@ -27,7 +26,6 @@ except ImportError: # pragma: no cover class _DecodeError(Exception): # noqa pass -IS_PY3 = sys.version_info[0] == 3 _encoder_cls = type(json._default_encoder) _default_encoder = None # ... set to JSONEncoder below. @@ -71,7 +69,7 @@ def dumps(s, _dumps=json.dumps, cls=None, **dict(default_kwargs, **kwargs)) -def loads(s, _loads=json.loads, decode_bytes=IS_PY3): +def loads(s, _loads=json.loads, decode_bytes=PY3): """Deserialize json from string.""" # None of the json implementations supports decoding from # a buffer/memoryview, or even reading from a stream