Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#37257 closed Bug (fixed)

Spurious `RemovedInDjango70Warning` for template string literals containing ".."

Reported by: Adam Johnson Owned by: Adam Johnson
Component: Template system Version: 6.1
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

#35738 deprecated double-dot variable lookups in templates, but the warning emits a spurious RemovedInDjango70Warning for templates whose variable expression is a literal containing two consecutive dots, like:

{{ "hello..world" }}
{{ 'a..b'|upper }}
{{ _("a..b") }}

Change History (5)

comment:1 by Adam Johnson, 3 weeks ago

Severity: NormalRelease blocker

comment:2 by Sarah Boyce, 3 weeks ago

Triage Stage: UnreviewedAccepted

comment:3 by Sarah Boyce, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:4 by Sarah Boyce <42296566+sarahboyce@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In b5388a3:

Fixed #37257, Refs #35738 -- Prevented double-dot deprecation warnings for template literals.

The deprecation warning for double-dot variable lookups checked
str(filter_expression.var), which for constants is the resolved literal
value rather than a variable lookup. Templates containing string or translated
string literals with two consecutive dots, such as {{ "a..b" }} or
{{ 'a..b'|upper }}, therefore incorrectly raised a RemovedInDjango70Warning.

The check now only applies when the filter expression's variable is a
Variable lookup.

Regression in 5d911f2d2fecc703be91b2b9b28acc59d34b35f3.

comment:5 by Sarah Boyce <42296566+sarahboyce@…>, 3 weeks ago

In 0060c6c:

[6.1.x] Fixed #37257, Refs #35738 -- Prevented double-dot deprecation warnings for template literals.

The deprecation warning for double-dot variable lookups checked
str(filter_expression.var), which for constants is the resolved literal
value rather than a variable lookup. Templates containing string or translated
string literals with two consecutive dots, such as {{ "a..b" }} or
{{ 'a..b'|upper }}, therefore incorrectly raised a RemovedInDjango70Warning.

The check now only applies when the filter expression's variable is a
Variable lookup.

Regression in 5d911f2d2fecc703be91b2b9b28acc59d34b35f3.

Backport of b5388a3a80cafcce2e34196d8e81cf5b48eb33bb from main.

Note: See TracTickets for help on using tickets.
Back to Top