From 1f305a00a0dabd352ad9ceda5a35dedef4f72eb1 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 31 Jan 2010 23:38:17 +0000 Subject: [PATCH] Fixed #12744 -- Improved the settings cleansing process the work with dictionary settings that are keyed by non-strings. Thanks to minmax for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12361 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/views/debug.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index 18ee28b1f3..6efed55927 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -26,13 +26,17 @@ def cleanse_setting(key, value): If the value is a dictionary, recursively cleanse the keys in that dictionary. """ - if HIDDEN_SETTINGS.search(key): - cleansed = '********************' - else: - if isinstance(value, dict): - cleansed = dict((k, cleanse_setting(k, v)) for k,v in value.items()) + try: + if HIDDEN_SETTINGS.search(key): + cleansed = '********************' else: - cleansed = value + if isinstance(value, dict): + cleansed = dict((k, cleanse_setting(k, v)) for k,v in value.items()) + else: + cleansed = value + except TypeError: + # If the key isn't regex-able, just return as-is. + cleansed = value return cleansed def get_safe_settings():