Re: [Django] #35395: slice filter crashes on an empty dict with Python 3.12

10 views
Skip to first unread message

Django

unread,
Apr 23, 2024, 12:48:52 AMApr 23
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
---------------------------------+------------------------------------
Reporter: Tim Richardson | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by Tim Richardson):

When I submit a patch for this, is there a preferred way I can request
that it be backported to 4.2 LTS, so at least someone considers it?
--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 23, 2024, 12:53:13 AMApr 23
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: assigned
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Richardson):

* owner: nobody => Tim Richardson
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:7>

Django

unread,
Apr 23, 2024, 1:49:20 AMApr 23
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: assigned
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Richardson):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:8>

Django

unread,
Apr 23, 2024, 1:55:09 AMApr 23
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: assigned
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Richardson):

PR link

https://github.com/django/django/pull/18096
--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:9>

Django

unread,
Apr 24, 2024, 2:45:52 AMApr 24
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: assigned
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce):

Hello, thank you for the PR!

> When I submit a patch for this, is there a preferred way I can request
that it be backported to 4.2 LTS, so at least someone considers it?

Requesting on the ticket is fine. I have considered it, however I agree
with Tim Graham that this doesn't qualify for a backport. 4.2 is only
receiving security and data loss fixes.
`slice` is also documented to be for lists
(https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#slice), so
I agree this is unexpected usage. I think you will need to make a custom
template filter in your code for 4.2.
--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:10>

Django

unread,
Apr 24, 2024, 3:11:30 AMApr 24
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: assigned
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:11>

Django

unread,
Apr 24, 2024, 4:48:28 AMApr 24
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: assigned
Component: Template system | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Richardson):

thanks. That was my first PR and it was a very well documented, clear and
easy process.
--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:12>

Django

unread,
Apr 24, 2024, 4:53:47 AMApr 24
to django-...@googlegroups.com
#35395: slice filter crashes on an empty dict with Python 3.12
-------------------------------------+-------------------------------------
Reporter: Tim Richardson | Owner: Tim
| Richardson
Type: Bug | Status: closed
Component: Template system | Version: 4.2
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"e64d42e753e5c7763398d018f5ccaa95efc7588e" e64d42e]:
{{{#!CommitTicketReference repository=""
revision="e64d42e753e5c7763398d018f5ccaa95efc7588e"
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).
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35395#comment:13>
Reply all
Reply to author
Forward
0 new messages