[Django] #26890: forms.IntegerField does not support unicode numbers

25 views
Skip to first unread message

Django

unread,
Jul 12, 2016, 3:52:28 PM7/12/16
to django-...@googlegroups.com
#26890: forms.IntegerField does not support unicode numbers
-------------------------------+--------------------------
Reporter: byoungb | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Keywords: IntegerField
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------
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)

--
Ticket URL: <https://code.djangoproject.com/ticket/26890>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 12, 2016, 6:41:10 PM7/12/16
to django-...@googlegroups.com
#26890: forms.IntegerField does not support unicode numbers
-------------------------------+--------------------------------------

Reporter: byoungb | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Resolution:

Keywords: IntegerField | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by jdufresne):

* cc: jon.dufresne@… (added)
* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_tests: => 0
* needs_docs: => 0


Comment:

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>

--
Ticket URL: <https://code.djangoproject.com/ticket/26890#comment:1>

Django

unread,
Jul 12, 2016, 10:11:51 PM7/12/16
to django-...@googlegroups.com
#26890: forms.IntegerField does not support unicode numbers
-------------------------------------+-------------------------------------
Reporter: byoungb | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.9
Severity: Normal | Resolution:
Keywords: IntegerField | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* type: Uncategorized => Bug
* stage: Unreviewed => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/26890#comment:2>

Django

unread,
Jul 14, 2016, 9:39:09 AM7/14/16
to django-...@googlegroups.com
#26890: forms.IntegerField does not support unicode numbers
-------------------------------------+-------------------------------------
Reporter: byoungb | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: IntegerField | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"76e19da5b0385d4f8afda509e0b60f77f7ffc4c2" 76e19da]:
{{{
#!CommitTicketReference repository=""
revision="76e19da5b0385d4f8afda509e0b60f77f7ffc4c2"
Fixed #26890 -- Fixed IntegerField crash on Unicode numbers.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26890#comment:3>

Django

unread,
Jul 14, 2016, 9:39:35 AM7/14/16
to django-...@googlegroups.com
#26890: forms.IntegerField does not support unicode numbers
-------------------------------------+-------------------------------------
Reporter: byoungb | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.9

Severity: Normal | Resolution: fixed
Keywords: IntegerField | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"acb804e55290f9d3dda459fcfb7820f9e3fcbb6c" acb804e5]:
{{{
#!CommitTicketReference repository=""
revision="acb804e55290f9d3dda459fcfb7820f9e3fcbb6c"
[1.10.x] Fixed #26890 -- Fixed IntegerField crash on Unicode numbers.

Backport of 76e19da5b0385d4f8afda509e0b60f77f7ffc4c2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26890#comment:4>

Reply all
Reply to author
Forward
0 new messages