#33361: Redis cache backend doesn't allow storing bool values
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  Jeremy
                                     |  Lainé
         Type:  Bug                  |                   Status:  assigned
    Component:  Core (Cache system)  |                  Version:  4.0
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Jeremy Lainé):

 * owner:  nobody => Jeremy Lainé
 * status:  new => assigned


Comment:

 Thanks for the reply and the link to the discussion. I'm assigning myself
 to the ticket as I'd be happy to prepare a patch and corresponding test.

 Regarding the proposed fix, it feels like we're just moving the problem as
 I'd expect similar issues with an user-defined subclasses of `int`. Would
 it be acceptable to do:

 {{{#!diff
 diff --git a/django/core/cache/backends/redis.py
 b/django/core/cache/backends/redis.py
 index 16556b1ded..bbb0e0320d 100644
 --- a/django/core/cache/backends/redis.py
 +++ b/django/core/cache/backends/redis.py
 @@ -11,7 +11,7 @@ from django.utils.module_loading import import_string

  class RedisSerializer(PickleSerializer):
      def dumps(self, obj):
 -        if isinstance(obj, int):
 +        if type(obj) is int:
              return obj
          return super().dumps(obj)

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33361#comment:2>
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/064.6086b8a8a24d972571dc8206cdf41089%40djangoproject.com.

Reply via email to