Opened 15 years ago
Closed 14 years ago
#15214 closed Cleanup/optimization (duplicate)
CharField's widget_attrs should return an empty dict rather than None
| Reported by: | Gabriel Grant | Owned by: | Gabriel Grant |
|---|---|---|---|
| Component: | Forms | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
See http://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L217
When self.max_length is None or widget is not a TextInput or PasswordInput instance, no return value is specified.
Returning None can break things when a dict is expected. Theoretically, it should probably call the superclass' widget_attrs and update the dict with its own values (if the conditions are met). In practice, I'm not sure the super call really matters.
Change History (3)
comment:1 by , 15 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Cleanup/optimization |
comment:3 by , 14 years ago
| Easy pickings: | unset |
|---|---|
| Resolution: | → duplicate |
| Status: | new → closed |
| UI/UX: | unset |
This is a duplicate of #15912. Closing this one since the other has a patch.
In practice, this doesn't really matter -- the existing uses of widget_attrs (essentially just in the constructor for a field) check for a null response. However, that check could be removed entirely if CharField did the right thing.