diff options
Diffstat (limited to 'django/template/defaultfilters.py')
| -rw-r--r-- | django/template/defaultfilters.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py index b18b41c293..b172be6239 100644 --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -1,7 +1,6 @@ """Default variable filters.""" import random as random_module import re -from contextlib import suppress from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation from functools import wraps from operator import itemgetter @@ -609,7 +608,7 @@ def unordered_list(value, autoescape=True): def walk_items(item_list): item_iterator = iter(item_list) - with suppress(StopIteration): + try: item = next(item_iterator) while True: try: @@ -628,6 +627,8 @@ def unordered_list(value, autoescape=True): continue yield item, None item = next_item + except StopIteration: + pass def list_formatter(item_list, tabs=1): indent = '\t' * tabs @@ -877,9 +878,11 @@ def pluralize(value, arg='s'): except ValueError: # Invalid string that's not a number. pass except TypeError: # Value isn't a string or a number; maybe it's a list? - with suppress(TypeError): # len() of unsized object. + try: if len(value) != 1: return plural_suffix + except TypeError: # len() of unsized object. + pass return singular_suffix |
