diff --git a/django/views/debug.py b/django/views/debug.py
index efb3079..f6bf5b4 100644
a
|
b
|
from django.template import Template, Context, TemplateDoesNotExist
|
13 | 13 | from django.template.defaultfilters import force_escape, pprint |
14 | 14 | from django.utils.datastructures import MultiValueDict |
15 | 15 | from django.utils.html import escape |
16 | | from django.utils.encoding import force_bytes, smart_text |
| 16 | from django.utils.encoding import force_bytes, force_text, smart_text |
17 | 17 | from django.utils.module_loading import import_string |
18 | 18 | from django.utils import six |
19 | 19 | |
… |
… |
def cleanse_setting(key, value):
|
50 | 50 | cleansed = value |
51 | 51 | |
52 | 52 | if callable(cleansed): |
53 | | cleansed.do_not_call_in_templates = True |
| 53 | # For fixing #21345 and #23070 |
| 54 | cleansed = force_text(cleansed) |
54 | 55 | |
55 | 56 | return cleansed |
56 | 57 | |
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index b66bdac..f799325 100644
a
|
b
|
class ExceptionReporterFilterTests(TestCase, ExceptionReportTestMixin):
|
652 | 652 | response = self.client.get('/raises500/') |
653 | 653 | self.assertNotContains(response, "This should not be displayed", status_code=500) |
654 | 654 | |
| 655 | def test_callable_settings_forbidding_to_set_attributes(self): |
| 656 | """ |
| 657 | Callable settings which forbid to set attributes should not break |
| 658 | the debug page (#23070). |
| 659 | """ |
| 660 | class CallableSettingWithSlots(object): |
| 661 | __slots__ = [] |
| 662 | |
| 663 | def __call__(self): |
| 664 | return "This should not be displayed" |
| 665 | |
| 666 | with self.settings(DEBUG=True, WITH_SLOTS=CallableSettingWithSlots()): |
| 667 | response = self.client.get('/raises500/') |
| 668 | self.assertNotContains(response, "This should not be displayed", status_code=500) |
| 669 | |
655 | 670 | def test_dict_setting_with_non_str_key(self): |
656 | 671 | """ |
657 | 672 | A dict setting containing a non-string key should not break the |