#33361: Redis cache backend doesn't allow storing bool values
-----------------------------------------------+------------------------
               Reporter:  Jeremy Lainé         |          Owner:  nobody
                   Type:  Bug                  |         Status:  new
              Component:  Core (Cache system)  |        Version:  4.0
               Severity:  Normal               |       Keywords:
           Triage Stage:  Unreviewed           |      Has patch:  0
    Needs documentation:  0                    |    Needs tests:  0
Patch needs improvement:  0                    |  Easy pickings:  0
                  UI/UX:  0                    |
-----------------------------------------------+------------------------
 The following code raises an exception:  `redis.exceptions.DataError:
 Invalid input of type: 'bool'. Convert to a bytes, string, int or float
 first.`

 {{{#!python
 from django.core.cache import cache
 cache.set("foo", True)
 }}}

 This contradicts the documentation which states that any data type
 supported by pickle can be stored to the cache.

 The root cause seems to be because instances of `int` are special-cased
 and not send through pickle, but redis-py cannot send booleans to redis:

 
https://github.com/django/django/blob/2f73e5406d54cb8945e187eff302a3a3373350be/django/core/cache/backends/redis.py#L14

 What was the rationale behind the `int` special-case? `django-redis` for
 instance consistently sends all data through pickle.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33361>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.d30996301155ceb98c43e6157ff6827f%40djangoproject.com.

Reply via email to