Fixed #27140 -- Prevented template rendering from hiding a property's TypeError.
This commit is contained in:
parent
65ec8fa8ca
commit
59afe61a97
|
@ -892,9 +892,8 @@ class Variable(object):
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
current = getattr(current, bit)
|
current = getattr(current, bit)
|
||||||
except (TypeError, AttributeError) as e:
|
except (TypeError, AttributeError) as e:
|
||||||
# Reraise an AttributeError raised by a @property
|
# Reraise if the exception was raised by a @property
|
||||||
if (isinstance(e, AttributeError) and
|
if not isinstance(current, BaseContext) and bit in dir(current):
|
||||||
not isinstance(current, BaseContext) and bit in dir(current)):
|
|
||||||
raise
|
raise
|
||||||
try: # list-index lookup
|
try: # list-index lookup
|
||||||
current = current[int(bit)]
|
current = current[int(bit)]
|
||||||
|
|
|
@ -237,3 +237,8 @@ class FilterSyntaxTests(SimpleTestCase):
|
||||||
"""
|
"""
|
||||||
with self.assertRaises(AttributeError):
|
with self.assertRaises(AttributeError):
|
||||||
self.engine.render_to_string('filter-syntax25', {'var': SomeClass()})
|
self.engine.render_to_string('filter-syntax25', {'var': SomeClass()})
|
||||||
|
|
||||||
|
@setup({'template': '{{ var.type_error_attribute }}'})
|
||||||
|
def test_type_error_attribute(self):
|
||||||
|
with self.assertRaises(TypeError):
|
||||||
|
self.engine.render_to_string('template', {'var': SomeClass()})
|
||||||
|
|
|
@ -137,6 +137,10 @@ class SomeClass:
|
||||||
def attribute_error_attribute(self):
|
def attribute_error_attribute(self):
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type_error_attribute(self):
|
||||||
|
raise TypeError
|
||||||
|
|
||||||
|
|
||||||
class OtherClass:
|
class OtherClass:
|
||||||
def method(self):
|
def method(self):
|
||||||
|
|
Loading…
Reference in New Issue