#36559: partialdef tag embedded in verbatim tag is treated as the source 
attribute
for that named partial
-----------------------------+-------------------------------------------
     Reporter:  Jacob Walls  |                     Type:  Bug
       Status:  new          |                Component:  Template system
      Version:  dev          |                 Severity:  Release blocker
     Keywords:               |             Triage Stage:  Unreviewed
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+-------------------------------------------
 Although `partial` and `partialdef` are correctly ignored when rendered if
 embedded within `{% verbatim %}`, the `PartialTemplate.source` attribute
 is fooled, potentially impacting error reporting:

 {{{#!diff
 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/tests/template_tests/syntax_tests/test_partials.py
 +++ b/tests/template_tests/syntax_tests/test_partials.py
 @@ -484,6 +484,11 @@ class PartialTagTests(SimpleTestCase):
          {
              "partial_with_syntax_error": (
                  "<h1>Title</h1>\n"
 +                "{% verbatim %}\n"
 +                "{% partialdef syntax_error_partial %}\n"
 +                "VERBATIM\n"
 +                "{% endpartialdef %}\n"
 +                "{% endverbatim %}\n"
                  "{% partialdef syntax_error_partial %}\n"
                  "    {% if user %}\n"
                  "        <p>User: {{ user.name }}</p>\n"
 @@ -506,6 +511,7 @@ class PartialTagTests(SimpleTestCase):
              self.assertIn("endpartialdef", exc_debug["during"])
              self.assertEqual(exc_debug["name"],
 "partial_with_syntax_error")
              self.assertIn("endif", exc_debug["message"].lower())
 +            self.assertNotIn("verbatim", exc_debug["source_lines"][0][1])

      @setup(
          {
 }}}

 {{{#!py
 ======================================================================
 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 attribute, I'll start there.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36559>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070198b8426c2e-6ec6791f-d55c-4fa8-82ce-f2ca3fd6526f-000000%40eu-central-1.amazonses.com.

Reply via email to