Opened 8 years ago

Closed 8 years ago

#26173 closed Bug (fixed)

localize_input() shouldn't put thousands separator in boolean values

Reported by: Marcin Markiewicz Owned by: Marcin Markiewicz
Component: Utilities Version:
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

django.utils.formats localize_input inserts thousands_separator into boolean values

The problem is in django.utils.formats localize_input that is used in widgets to render value

There is a check there like so:

if isinstance(value, (decimal.Decimal, float, int, long)):

which evaluates to True for Booleans (because booleans are ints, see "issubclass(bool, int)")

This was reported: https://code.djangoproject.com/ticket/14807
but this is old closed history.

It touched us again, so maybe this time will be better to solve this

Attachments (1)

26173-test.diff (528 bytes ) - added by Tim Graham 8 years ago.

Download all attachments as: .zip

Change History (5)

by Tim Graham, 8 years ago

Attachment: 26173-test.diff added

comment:1 by Tim Graham, 8 years ago

Component: FormsUtilities
Easy pickings: set
Has patch: unset
Summary: Don't localize boolean valueslocalize_input() shouldn't put thousands separator in boolean values
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

I've attached a regression test. That just needs to be combined with the fix and sent as a pull request.

comment:2 by Marcin Markiewicz, 8 years ago

Owner: changed from nobody to Marcin Markiewicz
Status: newassigned

comment:3 by Marcin Markiewicz, 8 years ago

I make pull request with this change
https://github.com/django/django/pull/6080

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In f7a9872b:

Fixed #26173 -- Prevented localize_input() from formatting booleans as numbers.

Note: See TracTickets for help on using tickets.
Back to Top