#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 -------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak): Replying to [comment:2 Jeremy Lainé]: > 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) > > }}} Yes, looks good, a small comment could de helpful. -- Ticket URL: <https://code.djangoproject.com/ticket/33361#comment:3> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.f7171970a4a57d85a09277807c02e5ea%40djangoproject.com.