Opened 4 years ago

Closed 4 years ago

Last modified 4 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 Changed 4 years ago by Jon Dufresne

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 Changed 4 years ago by Tim Graham

Triage Stage: UnreviewedReady for checkin
Type: UncategorizedBug

comment:3 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 76e19da:

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

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

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