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