diff options
| author | Tim Graham <timograham@gmail.com> | 2025-03-05 20:02:23 -0500 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2025-03-05 22:03:01 -0300 |
| commit | b179c67860c6b834e5d35fadba4c905d8c6495d5 (patch) | |
| tree | fcc7fb1e9964c9f502d580911b7b7398f93c78b8 | |
| parent | d42b1870225ee0fac033742fd7f32ca0092675b1 (diff) | |
[5.2.x] Clarified cryptic comment in django/core/cache/backends/redis.py.
Backport of 9a729fb61add16d89a4b42b491aec2d22f1ae69a from main.
| -rw-r--r-- | django/core/cache/backends/redis.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/core/cache/backends/redis.py b/django/core/cache/backends/redis.py index eda8ac9457..bbf070a375 100644 --- a/django/core/cache/backends/redis.py +++ b/django/core/cache/backends/redis.py @@ -14,8 +14,9 @@ class RedisSerializer: self.protocol = pickle.HIGHEST_PROTOCOL if protocol is None else protocol def dumps(self, obj): - # Only skip pickling for integers, a int subclasses as bool should be - # pickled. + # For better incr() and decr() atomicity, don't pickle integers. + # Using type() rather than isinstance() matches only integers and not + # subclasses like bool. if type(obj) is int: return obj return pickle.dumps(obj, self.protocol) |
