summaryrefslogtreecommitdiff
path: root/django/contrib/messages/storage/cookie.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/contrib/messages/storage/cookie.py')
-rw-r--r--django/contrib/messages/storage/cookie.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
index 6d5df1af9d..49270cac17 100644
--- a/django/contrib/messages/storage/cookie.py
+++ b/django/contrib/messages/storage/cookie.py
@@ -1,5 +1,4 @@
import json
-from contextlib import suppress
from django.conf import settings
from django.contrib.messages.storage.base import BaseStorage, Message
@@ -154,10 +153,12 @@ class CookieStorage(BaseStorage):
if len(bits) == 2:
hash, value = bits
if constant_time_compare(hash, self._hash(value)):
- with suppress(ValueError):
+ try:
# If we get here (and the JSON decode works), everything is
# good. In any other case, drop back and return None.
return json.loads(value, cls=MessageDecoder)
+ except ValueError:
+ pass
# Mark the data as used (so it gets removed) since something was wrong
# with the data.
self.used = True