1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #35395 -- slice filter crashes on an empty dict with Python 3.12.

Keep consistent behaviour of slice() filter between python 3.12 and prior
versions in the case of a dict passed to the filter (catch the new to python
3.12 KeyError exception).
This commit is contained in:
Tim Richardson
2024-04-23 15:31:59 +10:00
committed by Sarah Boyce
parent 16d0542bb6
commit e64d42e753
2 changed files with 4 additions and 1 deletions

View File

@@ -644,7 +644,7 @@ def slice_filter(value, arg):
bits.append(int(x))
return value[slice(*bits)]
except (ValueError, TypeError):
except (ValueError, TypeError, KeyError):
return value # Fail silently.