1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Simplified force_bytes().

This commit is contained in:
Sergey Fedoseev 2018-07-09 11:26:22 +05:00 committed by Tim Graham
parent 09199734d3
commit 7d6fe18dde

View File

@ -99,10 +99,7 @@ def force_bytes(s, encoding='utf-8', strings_only=False, errors='strict'):
return s
if isinstance(s, memoryview):
return bytes(s)
if isinstance(s, Promise) or not isinstance(s, str):
return str(s).encode(encoding, errors)
else:
return s.encode(encoding, errors)
return str(s).encode(encoding, errors)
smart_str = smart_text