resolve django encoding deprecation warnings (#853)

https://docs.djangoproject.com/en/3.0/ref/utils/#django.utils.encoding.force_text
This commit is contained in:
luto 2020-01-20 22:05:20 +01:00 committed by Jonathan Kim
parent 08f67797d8
commit 62ecbae614

View File

@ -6,7 +6,7 @@ from threading import local
from time import time from time import time
import six import six
from django.utils.encoding import force_text from django.utils.encoding import force_str
from .types import DjangoDebugSQL from .types import DjangoDebugSQL
@ -78,7 +78,7 @@ class NormalCursorWrapper(object):
def _quote_expr(self, element): def _quote_expr(self, element):
if isinstance(element, six.string_types): if isinstance(element, six.string_types):
return "'%s'" % force_text(element).replace("'", "''") return "'%s'" % force_str(element).replace("'", "''")
else: else:
return repr(element) return repr(element)
@ -91,7 +91,7 @@ class NormalCursorWrapper(object):
def _decode(self, param): def _decode(self, param):
try: try:
return force_text(param, strings_only=True) return force_str(param, strings_only=True)
except UnicodeDecodeError: except UnicodeDecodeError:
return "(encoded string)" return "(encoded string)"