summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2021-03-12 09:00:39 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-03-15 13:10:30 +0100
commit775b796d8d13841059850d73986d5dcc2e593077 (patch)
tree4995814379868b299cd9ab643cd867b44801554b /django/utils
parent2cd0ccef04767ebfc3f6619f39f5b7dbee9a783b (diff)
Refs #32508 -- Raised ValueError instead of using "assert" in lazy().
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/functional.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 5c8a0c233f..5f12aa08ff 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -119,8 +119,10 @@ def lazy(func, *resultclasses):
setattr(cls, method_name, meth)
cls._delegate_bytes = bytes in resultclasses
cls._delegate_text = str in resultclasses
- assert not (cls._delegate_bytes and cls._delegate_text), (
- "Cannot call lazy() with both bytes and text return types.")
+ if cls._delegate_bytes and cls._delegate_text:
+ raise ValueError(
+ 'Cannot call lazy() with both bytes and text return types.'
+ )
if cls._delegate_text:
cls.__str__ = cls.__text_cast
elif cls._delegate_bytes: