1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #18719 -- Made force_bytes more consistent with force_text.

This commit is contained in:
Aymeric Augustin
2013-09-06 10:28:28 -05:00
parent bd8e1a354c
commit e492ab8e7e
2 changed files with 7 additions and 1 deletions

View File

@@ -122,7 +122,7 @@ def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
return s
else:
return s.decode('utf-8', errors).encode(encoding, errors)
if strings_only and (s is None or isinstance(s, int)):
if strings_only and is_protected_type(s):
return s
if isinstance(s, Promise):
return six.text_type(s).encode(encoding, errors)