summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/template/defaultfilters.py4
-rw-r--r--tests/regressiontests/templates/filters.py6
2 files changed, 5 insertions, 5 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 3606942add..77a3224157 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -665,8 +665,8 @@ def add(value, arg):
except (ValueError, TypeError):
try:
return value + arg
- except:
- return value
+ except Exception:
+ return ''
add.is_safe = False
def get_digit(value, arg):
diff --git a/tests/regressiontests/templates/filters.py b/tests/regressiontests/templates/filters.py
index 65f98e9ede..6b7934935d 100644
--- a/tests/regressiontests/templates/filters.py
+++ b/tests/regressiontests/templates/filters.py
@@ -346,10 +346,10 @@ def get_filter_tests():
#Ticket 9520: Make sure |date doesn't blow up on non-dates
'date03': (r'{{ d|date:"m" }}', {'d': 'fail_string'}, ''),
- # Tests for #11687
+ # Tests for #11687 and #16676
'add01': (r'{{ i|add:"5" }}', {'i': 2000}, '2005'),
- 'add02': (r'{{ i|add:"napis" }}', {'i': 2000}, '2000'),
- 'add03': (r'{{ i|add:16 }}', {'i': 'not_an_int'}, 'not_an_int'),
+ 'add02': (r'{{ i|add:"napis" }}', {'i': 2000}, ''),
+ 'add03': (r'{{ i|add:16 }}', {'i': 'not_an_int'}, ''),
'add04': (r'{{ i|add:"16" }}', {'i': 'not_an_int'}, 'not_an_int16'),
'add05': (r'{{ l1|add:l2 }}', {'l1': [1, 2], 'l2': [3, 4]}, '[1, 2, 3, 4]'),
'add06': (r'{{ t1|add:t2 }}', {'t1': (3, 4), 't2': (1, 2)}, '(3, 4, 1, 2)'),