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:19:12 +0700 |
| commit | b68c7a5abbb737c54dff91e56e0e56e67cd3f718 (patch) | |
| tree | d7073ca09c5f4640aaa9c0d31f4fa8abac553ed5 /django | |
| parent | f99267e5e6779d192959569155846f8b0ca5eb07 (diff) | |
[1.7.x] 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.
Backport of eb7df6b8d7 from master
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): |
