#22570 closed Cleanup/optimization (fixed)
Form.__getitem__ KeyError should be more descriptive
Reported by: | Ben Davis | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
When you try to access a nonexistent key on a Form, it raises this exception:
raise KeyError('Key %r not found in Form' % name)
This is vague in situations where you have multiple forms. You have to do a more digging to find out which form it is. It should be:
raise KeyError("Key %r not found in '%s'" % (name, self.__class__.__name__))
Change History (4)
comment:1 by , 11 years ago
Has patch: | set |
---|
comment:2 by , 11 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Test needs updating to pass on Python 3.
comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
PR for this ticket: https://github.com/django/django/pull/2629