1
0
mirror of https://github.com/django/django.git synced 2025-10-25 14:46:09 +00:00

Fixed #24836 -- Made force_text() resolve lazy objects.

This commit is contained in:
Tim Graham
2015-05-26 16:46:13 -04:00
parent 10945ebeb8
commit 70be31bba7
4 changed files with 25 additions and 2 deletions

View File

@@ -77,12 +77,12 @@ def force_text(s, encoding='utf-8', strings_only=False, errors='strict'):
If strings_only is True, don't convert (some) non-string-like objects.
"""
# Handle the common case first for performance reasons.
if isinstance(s, six.text_type):
if issubclass(type(s), six.text_type):
return s
if strings_only and is_protected_type(s):
return s
try:
if not isinstance(s, six.string_types):
if not issubclass(type(s), six.string_types):
if six.PY3:
if isinstance(s, bytes):
s = six.text_type(s, encoding, errors)