Opened 12 years ago
Closed 12 years ago
#18303 closed Bug (invalid)
Wrong comparison in render method of CheckboxInput class.
Reported by: | blind | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In line 511 of django.forms.widget, inside the 'render' method of CheckboxInput class, you can see this comparison:
if not (value is True or value is False or value is None or value == ''):
Because in Python the 'is' keyword tests object identity, if value is an object which is emulating a bool type, the comparison wont work.
I think, it should be:
if not (value == True or value == False or value == None or value == ''):
What do you think?
Attachments (1)
Change History (2)
by , 12 years ago
Attachment: | widgets.py added |
---|
comment:1 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Doesn't work: 0 == False -> True, 0 is False -> False. The current code relies on this, 0 is wanted as value. Closing this as invalid. The code might use some more comments at least, and if you think you have some backwards compatible solution you want to present, feel free to reopen this ticket.
patch