MergeDict should give key as argument to KeyError
|Reported by:||mark.harviston@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Normally when a dict raises a KeyError it passes the key to .args, but MergeDict does not do this.
to fix simply change raise KeyError to raise KeyError(key) on line 23 of utils/datastructures.py
I'm making a REST-like API that takes input on either POST or GET I wanted to wrap my whole thing in a try...except KeyError, and then give an appropriate error message with the missing field, but unlike request.GET and response.POST which are real dicts, request.REQUEST is a MergeDict and does not pass they key that failed as an argument.
Change History (2)
comment:1 Changed 2 years ago by claudep
- Has patch unset
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Bug to Cleanup/optimization