summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2010-01-10 21:37:20 +0000
committerAdrian Holovaty <adrian@holovaty.com>2010-01-10 21:37:20 +0000
commit8b9cf79ff645db608f92143d733df24d883a26e9 (patch)
treea2d563744bb02dee7c825f57dc600bc4bbfa688f
parenta4b0947a92df5649ed3cafc669a7b6a8cf0e50f2 (diff)
Fixed #11783 -- ordinal template tag now catches TypeError. Thanks, realpolitik and punteney
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12199 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/humanize/templatetags/humanize.py2
-rw-r--r--tests/regressiontests/humanize/tests.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index 05d322363b..3e19fed823 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -14,7 +14,7 @@ def ordinal(value):
"""
try:
value = int(value)
- except ValueError:
+ except (TypeError, ValueError):
return value
t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
if value % 100 in (11, 12, 13): # special case
diff --git a/tests/regressiontests/humanize/tests.py b/tests/regressiontests/humanize/tests.py
index 6f60c6d6f9..8b454719a1 100644
--- a/tests/regressiontests/humanize/tests.py
+++ b/tests/regressiontests/humanize/tests.py
@@ -22,10 +22,10 @@ class HumanizeTests(unittest.TestCase):
def test_ordinal(self):
test_list = ('1','2','3','4','11','12',
'13','101','102','103','111',
- 'something else')
+ 'something else', None)
result_list = ('1st', '2nd', '3rd', '4th', '11th',
'12th', '13th', '101st', '102nd', '103rd',
- '111th', 'something else')
+ '111th', 'something else', None)
self.humanize_tester(test_list, result_list, 'ordinal')