Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26890 closed Bug (fixed)

forms.IntegerField does not support unicode numbers

Reported by: Ben Youngblut Owned by: nobody
Component: Forms Version: 1.9
Severity: Normal Keywords: IntegerField
Cc: jon.dufresne@… 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

A Japanese user on our site just tried to submit a form with u'50'
Python's int() function correctly handles it (as well as python's \d+ in regular expressions).
But in IntegerField's to_python the value is cast to a string before being run through a regex substitution to remove ".00000" .

I found a quick workaround I changed it to forms.FloatField and then I cast to an int in the clean_XXX function. (it is just for page number in my case so I don't care if it auto truncates/rounds)

Change History (4)

comment:1 by Jon Dufresne, 8 years ago

Cc: jon.dufresne@… added
Has patch: set

I believe this is just a matter of coercing the value to a text type instead of str to handle Python2.

<https://github.com/django/django/pull/6908>

comment:2 by Tim Graham, 8 years ago

Triage Stage: UnreviewedReady for checkin
Type: UncategorizedBug

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

Resolution: fixed
Status: newclosed

In 76e19da:

Fixed #26890 -- Fixed IntegerField crash on Unicode numbers.

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

In acb804e5:

[1.10.x] Fixed #26890 -- Fixed IntegerField crash on Unicode numbers.

Backport of 76e19da5b0385d4f8afda509e0b60f77f7ffc4c2 from master

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