#35395: Python 3.12 filter bug with Django 4.2.11
     Reporter:  Tim Richardson   |                    Owner:  nobody
         Type:  Bug              |                   Status:  closed
    Component:  Template system  |                  Version:  4.2
     Severity:  Normal           |               Resolution:  needsinfo
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
Comment (by Tim Richardson):

 the slice() function is being interpreted as key in 3.12 but not in prior
 python versions.

 the calculation of


 is identical.

 Python 3.12 docs say that slice objects are now hashable, so it gets
 treated as a key I suppose.
 I wonder how it worked in prior python versions.

 Including KeyError in the caught exceptions restores consistent behaviour.
 def slice_filter(value, arg):
     Return a slice of the list using the same syntax as Python's list
         bits = []
         for x in str(arg).split(":"):
             if not x:
         return value[slice(*bits)]
     except (ValueError, TypeError, KeyError):
         return value  # Fail silently.
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:4>
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 

Reply via email to