Kaydet (Commit) 7c4289d0 authored tarafından Ryan O’Hara's avatar Ryan O’Hara Kaydeden (comit) Tim Graham

Fixed #27783 -- Switched VariableDoesNotExist.__str__() to repr() context.

Using __str__() and then repr'ing the result looks strange and can lead
to recursive rendering of forms.
üst 2757209c
......@@ -119,7 +119,7 @@ class VariableDoesNotExist(Exception):
self.params = params
def __str__(self):
return self.msg % tuple(force_text(p, errors='replace') for p in self.params)
return self.msg % self.params
class Origin:
......
from django.template.base import VariableDoesNotExist
from django.test import SimpleTestCase
class VariableDoesNotExistTests(SimpleTestCase):
def test_str(self):
exc = VariableDoesNotExist(msg='Failed lookup in %r', params=({'foo': 'bar'},))
self.assertEqual(str(exc), "Failed lookup in {'foo': 'bar'}")
......@@ -75,7 +75,7 @@ class VariableResolveLoggingTests(BaseTemplateLoggingTestCase):
raised_exception = self.test_handler.log_record.exc_info[1]
self.assertEqual(
str(raised_exception),
'Failed lookup for key [author] in %r' % ("{%r: %r}" % ('section', 'News'))
"Failed lookup for key [author] in {'section': 'News'}"
)
def test_no_log_when_variable_exists(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment