Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#14046 closed (fixed)

Template tag errors masked if including based on context variable name

Reported by: defcube Owned by: mariarchi
Component: Template system Version: 1.2
Severity: Keywords: template exception sprintdec2010
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I have a template tag that raises a RuntimeError. Normally, this gets displayed properly to the user, but I have found a case where it doesn't. If I {% include includefilename %} where includefilename is a context variable pointing to a template, then template tag errors are masked. If I do the very same include, but specify the template name directly without using the context variable, things work properly.

I have attached a barebones demo of the problem. To see the demo, runserver and check the template files. You can uncomment my includes in index.html to see the problem.

Attachments (3)

template_error_examples.tar.gz (4.2 KB) - added by defcube 5 years ago.
patch.diff (1.7 KB) - added by mariarchi 5 years ago.
patch.2.diff (215.3 KB) - added by mariarchi 5 years ago.

Download all attachments as: .zip

Change History (11)

Changed 5 years ago by defcube

comment:1 Changed 5 years ago by mariarchi

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to mariarchi
  • Patch needs improvement unset
  • Status changed from new to assigned

I've seen something similar in my projects before; i'll try to look into it

Changed 5 years ago by mariarchi

comment:2 Changed 5 years ago by mariarchi

  • Has patch set

should work now.

comment:3 Changed 5 years ago by russellm

  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

Patch looks good,but needs tests.

comment:4 Changed 5 years ago by mariarchi

..and tests would in turn require rewriting a chunk of template tests, because currently they test for things only with "TEMPLATE_DEBUG=False".

I'll try to finish that tomorrow.

Changed 5 years ago by mariarchi

comment:5 Changed 5 years ago by mariarchi

  • Keywords sprintdec2010 added
  • Needs tests unset
  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 5 years ago by mariarchi

Russel says "ready for check-in"

comment:7 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from assigned to closed

In [15413]:

Fixed #14046 -- Made {% include %} behave the same, regardless of whether the template included is named by variable or constant string. Thanks to defcube for the report, and George Karpenkov for the draft patch.

comment:8 Changed 5 years ago by russellm

In [15414]:

[1.2.X] Fixed #14046 -- Made {% include %} behave the same, regardless of whether the template included is named by variable or constant string. Thanks to defcube for the report, and George Karpenkov for the draft patch.

Backport of r15413 from trunk.

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