Opened 14 years ago
Closed 12 years ago
#15166 closed Bug (invalid)
Code error in ValidationError.update_error_dict
Reported by: | zvikico | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.3-beta |
Severity: | Normal | Keywords: | |
Cc: | bmispelon@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
There's a minor bug in ValidationError.update_error_dict. The code receives an error_dict which might be None (and perhaps it should have a default None value).
The code has two options, one when a message_dict exists and one that it doesn't.
If the message_dict exists, the code checks for a null error_dict and returns the message_dict instead.
If the message_dict does not exist, the code assumes the error_dict input is a dict without checking for None.
Here's a suggested alternative for the code:
def update_error_dict(self, error_dict = None): if hasattr(self, 'message_dict'): if error_dict: for k, v in self.message_dict.items(): error_dict.setdefault(k, []).extend(v) else: error_dict = self.message_dict else: if error_dict: error_dict[NON_FIELD_ERRORS] = self.messages else: error_dict = { NON_FIELD_ERRORS: self.messages, } return error_dict
Change History (5)
comment:1 by , 14 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:3 by , 13 years ago
UI/UX: | unset |
---|
comment:5 by , 12 years ago
Cc: | added |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Validation.update_error_dict
is only used in Model.full_clean
, where it always passes a dictionary (never None
).
For this reason, I'm marking this as invalid.
Feel free to reopen this bug if you can provide a concrete example of how this affects you.
Change UI/UX from NULL to False.