#35522: 'NoneType' object has no attribute 'lstrip' when loading single template
with relative include without origin
-------------------------------------------+------------------------
Reporter: Hovi | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
Behaviour described by this test:
{{{
from django.template import Template, Origin, TemplateSyntaxError
from django.test import TestCase
class TestInclude(TestCase):
def test_passes(self):
Template(
"""
{% include "question.html" %}
"""
)
def test_also_passes(self):
Template(
"""
{% include "./question.html" %}
""",
origin=Origin(
name="doesntmatter.html", template_name="need-to-be-
set.html"
),
)
def test_fails_correctly(self):
with self.assertRaises(TemplateSyntaxError) as cm:
Template(
"""
{% include "../question.html" %}
""",
origin=Origin(
name="doesntmatter.html", template_name="need-to-be-
set.html"
),
)
self.assertIn("points outside the file hierarchy that
template", str(cm.exception))
def test_fails(self):
with self.assertRaises(AttributeError) as cm:
Template(
"""
{% include "./question.html" %}
"""
)
self.assertIn("'NoneType' object has no attribute 'lstrip'",
str(cm.exception))
def test_fails_on_incorrect_error(self):
with self.assertRaises(AttributeError) as cm:
Template(
"""
{% include "../question.html" %}
"""
)
self.assertIn("'NoneType' object has no attribute 'lstrip'",
str(cm.exception))
--
Ticket URL: <
https://code.djangoproject.com/ticket/35522>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.