Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #11783 -- ordinal template tag now catches TypeError. Thanks, r…

…ealpolitik and punteney

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12199 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8b9cf79ff645db608f92143d733df24d883a26e9 1 parent a4b0947
@adrianholovaty adrianholovaty authored
View
2  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
View
4 tests/regressiontests/humanize/tests.py
@@ -22,10 +22,10 @@ def humanize_tester(self, test_list, result_list, method):
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')
Please sign in to comment.
Something went wrong with that request. Please try again.