Cleaned up redundant PY3 constants (#854)

* Cleaned up redundent PY3 constants in utils/encoding

* Cleaned up redundent PY3 constants in utils/json

* fixed flake8 error
This commit is contained in:
Asif Saifuddin Auvi 2018-04-29 22:01:35 +06:00 committed by GitHub
parent 0f6ef8c90b
commit 824491b972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View File

@ -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):

View File

@ -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