diff options
| author | Loic Bistuer <loic.bistuer@gmail.com> | 2014-07-01 20:48:00 +0700 |
|---|---|---|
| committer | Loic Bistuer <loic.bistuer@gmail.com> | 2014-07-04 17:05:31 +0700 |
| commit | 1966054febbb96b713db27513617eabdbd70957b (patch) | |
| tree | 77326d8d658b2f661bd12f5baba95130c8376378 /django | |
| parent | 1bb1d3168b813e050df757ff40cdaf2feab45fdb (diff) | |
Fixed #22915 -- Document backward incompatible changes in the ValidationError constructor.
This patch also fixes update_error_dict to better handle the use case described
in this ticket, previously the type of the provided container could be lost in
some conditions.
Thanks Russell Keith-Magee for the report and Tim Graham for review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/exceptions.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/django/core/exceptions.py b/django/core/exceptions.py index 552b0067c3..28e712e0a5 100644 --- a/django/core/exceptions.py +++ b/django/core/exceptions.py @@ -142,13 +142,10 @@ class ValidationError(Exception): def update_error_dict(self, error_dict): if hasattr(self, 'error_dict'): - if error_dict: - for field, errors in self.error_dict.items(): - error_dict.setdefault(field, []).extend(errors) - else: - error_dict = self.error_dict + for field, error_list in self.error_dict.items(): + error_dict.setdefault(field, []).extend(error_list) else: - error_dict[NON_FIELD_ERRORS] = self.error_list + error_dict.setdefault(NON_FIELD_ERRORS, []).extend(self.error_list) return error_dict def __iter__(self): |
