Opened 5 months ago

Last modified 5 months ago

#35395 closed Bug

Python 3.12 filter bug with Django 4.2.11 — at Version 1

Reported by: Tim Richardson Owned by: nobody
Component: Template system Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Tim Richardson)

I have a template with a fragment like this:

<span

class="fs-6">Supplier: {{ po_metadata|get_item:dict_item.PONumber|get_item:"supplier" }} PO Date: {{ po_metadata|get_item:dict_item.PONumber|get_item:"order_date" | slice:":10" }} </span>

When using python 3.13.2, I get an exception in django/template/defaultfilters.py slice_filter()

This code does not throw an exception with 3.11

The exception is a Key Error and it happens because instead a list being passed to the filter, a dictionary is. An empty dict in my case.

In python 3.11, the breakpoints in slice_filter() are not hit. Somehow the preceeding filters are behaving differently in case of po_metadata being an empty dict.

Change History (1)

comment:1 by Tim Richardson, 5 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top