Opened 5 weeks ago
Last modified 2 weeks ago
#36559 closed Bug
partialdef tag embedded in verbatim tag is treated as the source property for that named partial — at Version 1
Reported by: | Jacob Walls | Owned by: | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Release blocker | Keywords: | partials |
Cc: | Carlton Gibson, Farhan Ali | 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 (last modified by )
Although partial
and partialdef
are correctly ignored when rendered if embedded within {% verbatim %}
, the PartialTemplate.source
property is fooled, potentially impacting error reporting:
-
tests/template_tests/syntax_tests/test_partials.py
diff --git a/tests/template_tests/syntax_tests/test_partials.py b/tests/template_tests/syntax_tests/test_partials.py index a2cd3ae96a..6098531ed9 100644
a b class PartialTagTests(SimpleTestCase): 484 484 { 485 485 "partial_with_syntax_error": ( 486 486 "<h1>Title</h1>\n" 487 "{% verbatim %}\n" 488 "{% partialdef syntax_error_partial %}\n" 489 "VERBATIM\n" 490 "{% endpartialdef %}\n" 491 "{% endverbatim %}\n" 487 492 "{% partialdef syntax_error_partial %}\n" 488 493 " {% if user %}\n" 489 494 " <p>User: {{ user.name }}</p>\n" … … class PartialTagTests(SimpleTestCase): 506 511 self.assertIn("endpartialdef", exc_debug["during"]) 507 512 self.assertEqual(exc_debug["name"], "partial_with_syntax_error") 508 513 self.assertIn("endif", exc_debug["message"].lower()) 514 self.assertNotIn("verbatim", exc_debug["source_lines"][0][1]) 509 515 510 516 @setup( 511 517 {
====================================================================== FAIL: test_partial_with_syntax_error_exception_info (template_tests.syntax_tests.test_partials.PartialTagTests.test_partial_with_syntax_error_exception_info) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/jwalls/django/django/test/utils.py", line 458, in inner return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/jwalls/django/tests/template_tests/utils.py", line 76, in inner func(self) File "/Users/jwalls/django/tests/template_tests/syntax_tests/test_partials.py", line 514, in test_partial_with_syntax_error_exception_info self.assertNotIn("verbatim", exc_debug["source_lines"][0][1]) AssertionError: 'verbatim' unexpectedly found in '{% verbatim %}\n'
The use case presented here isn't very serious, so I'm loathe to really mark this as a release blocker, but as it's a new feature and that's our process, and I'm not sure if there are other more important uses of the source property, I'll start there.
Change History (1)
comment:1 by , 5 weeks ago
Description: | modified (diff) |
---|---|
Summary: | partialdef tag embedded in verbatim tag is treated as the source attribute for that named partial → partialdef tag embedded in verbatim tag is treated as the source property for that named partial |
Note:
See TracTickets
for help on using tickets.