summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2021-12-13 17:09:13 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-12-14 08:46:16 +0100
commit3b03bce122b0f7336a90e3cc111a717c1a8f3700 (patch)
treed7ca770172bce7ca5ee25aa7ecddab28ff6a9b98 /django
parentcc5bbd447bec57165d5bdf062128fdee0df81ee4 (diff)
[4.0.x] Fixed #33361 -- Fixed Redis cache backend crash on booleans.
Backport of 2f33217ea2cad688040dd6044cdda946c62e5b65 from main
Diffstat (limited to 'django')
-rw-r--r--django/core/cache/backends/redis.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/django/core/cache/backends/redis.py b/django/core/cache/backends/redis.py
index 16556b1ded..ec2fb06102 100644
--- a/django/core/cache/backends/redis.py
+++ b/django/core/cache/backends/redis.py
@@ -10,8 +10,14 @@ from django.utils.module_loading import import_string
class RedisSerializer(PickleSerializer):
+ """
+ Similar to PickSerializer, except integers are serialized as native Redis
+ integers for better incr() and decr() atomicity.
+ """
def dumps(self, obj):
- if isinstance(obj, int):
+ # Only skip pickling for integers, a int subclasses as bool should be
+ # pickled.
+ if type(obj) is int:
return obj
return super().dumps(obj)