summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorTim Richardson <tim@growtpath.com.au>2024-04-23 15:31:59 +1000
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-04-24 10:53:38 +0200
commite64d42e753e5c7763398d018f5ccaa95efc7588e (patch)
tree831e20cc0290d693c607f2d07dbcdbb79f525baf /django/template
parent16d0542bb6812b94895136d26f86b33d20e6a072 (diff)
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).
Diffstat (limited to 'django/template')
-rw-r--r--django/template/defaultfilters.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index a08ce2710d..02cac06bcf 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -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.