Opened 13 years ago
Closed 12 years ago
#17888 closed Cleanup/optimization (fixed)
CheckboxInput.render() shouldn't catch exceptions from check_test
Reported by: | Bruno Renié | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | marc.tamlyn@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
https://github.com/django/django/blob/master/django/forms/widgets.py#L502-505
As the docs state, check_test
is a callable that returns True
if the checkbox should be checked for a specific value. The default implementation doesn't do anything complicated and shouldn't raise exceptions. If user-provided callables break, it django shouldn't catch the error silently.
My proposal is to simply remove that bare except and let check_test
raise exceptions.
The current behaviour is actually expected and tested:
https://github.com/django/django/blob/master/tests/regressiontests/forms/tests/widgets.py#L218-224
I still think it's quite a bad API and should be changed. Since that exception-swallowing behaviour isn't documented (although tested), backwards compatibility isn't that much of a concern.
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | 17888.patch added |
---|
comment:1 by , 12 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Yes, and yes!
comment:2 by , 12 years ago
Pull request with tests and docs is at https://github.com/django/django/pull/125
comment:3 by , 12 years ago
Cc: | added |
---|---|
Needs documentation: | unset |
Needs tests: | unset |
Patch needs improvement: | unset |
Triage Stage: | Accepted → Ready for checkin |
There is an updated pull request at https://github.com/django/django/pull/130/. I think this is all good to go so I'm going to mark it as RFC.
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch that breaks the current regression tests