From 7d6fe18dde78d07e5f0249e21419f19a67ca4aa4 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Mon, 9 Jul 2018 11:26:22 +0500 Subject: [PATCH] Simplified force_bytes(). --- django/utils/encoding.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/django/utils/encoding.py b/django/utils/encoding.py index 4ff530c4067..1a1a6d06b13 100644 --- a/django/utils/encoding.py +++ b/django/utils/encoding.py @@ -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