diff options
| author | Mads Jensen <mje@inducks.org> | 2017-03-09 16:17:41 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-28 14:07:55 -0400 |
| commit | 550cb3a365dee4edfdd1563224d5304de2a57fda (patch) | |
| tree | fb532f38774ff7619edd2a4532c3daae1ee0ac5a /django/forms/formsets.py | |
| parent | 43a4835edf32c57eb74c0eb207c276734a34abcf (diff) | |
Fixed #27818 -- Replaced try/except/pass with contextlib.suppress().
Diffstat (limited to 'django/forms/formsets.py')
| -rw-r--r-- | django/forms/formsets.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 49febc2b2e..0531d50204 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -1,3 +1,5 @@ +from contextlib import suppress + from django.core.exceptions import ValidationError from django.forms import Form from django.forms.fields import BooleanField, IntegerField @@ -160,10 +162,8 @@ class BaseFormSet: defaults['data'] = self.data defaults['files'] = self.files if self.initial and 'initial' not in kwargs: - try: + with suppress(IndexError): defaults['initial'] = self.initial[i] - except IndexError: - pass # Allow extra forms to be empty, unless they're part of # the minimum forms. if i >= self.initial_form_count() and i >= self.min_num: |
