[Django] #29389: Paginator accepts floats as a page number

13 views
Skip to first unread message

Django

unread,
May 8, 2018, 9:53:47 AM5/8/18
to django-...@googlegroups.com
#29389: Paginator accepts floats as a page number
----------------------------------------+-----------------------------
Reporter: Nicolas Noé | Owner: Nicolas Noé
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+-----------------------------
According to the docs, the PageNotAnInteger exception is raised when
page() is given a value that isn’t an integer.

However, we can see that floats are silently converted to integers:


{{{
from django.core.paginator import Paginator
objects = ['john', 'paul', 'george', 'ringo']
p = Paginator(objects, 2)
p.page(1.2)
<Page 1 of 2>
}}}

If accepted, I'm willing to provide a patch.

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

Django

unread,
May 8, 2018, 11:12:50 AM5/8/18
to django-...@googlegroups.com
#29389: Make Paginator reject non-integer page numbers of type float
------------------------------+---------------------------------------

Reporter: Nicolas Noé | Owner: Nicolas Noé
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
May 9, 2018, 7:35:44 AM5/9/18
to django-...@googlegroups.com
#29389: Make Paginator reject non-integer page numbers of type float
------------------------------+---------------------------------------
Reporter: Nicolas Noé | Owner: Nicolas Noé
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------

Comment (by Nicolas Noé):

[https://github.com/django/django/pull/9935 PR]

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

Django

unread,
May 9, 2018, 7:36:11 AM5/9/18
to django-...@googlegroups.com
#29389: Make Paginator reject non-integer page numbers of type float
------------------------------+---------------------------------------
Reporter: Nicolas Noé | Owner: Nicolas Noé
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
Changes (by Nicolas Noé):

* has_patch: 0 => 1


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

Django

unread,
May 9, 2018, 9:54:02 AM5/9/18
to django-...@googlegroups.com
#29389: Make Paginator reject non-integer page numbers of type float
------------------------------+---------------------------------------
Reporter: Nicolas Noé | Owner: Nicolas Noé
Type: Bug | Status: closed

Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
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: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c629d4e9562e7b04b39ca5224af6fd08a3cb14bc" c629d4e9]:
{{{
#!CommitTicketReference repository=""
revision="c629d4e9562e7b04b39ca5224af6fd08a3cb14bc"
Fixed #29389 -- Made Paginator reject non-integer page numbers of type
float.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29389#comment:5>

Django

unread,
May 9, 2018, 9:54:02 AM5/9/18
to django-...@googlegroups.com
#29389: Make Paginator reject non-integer page numbers of type float
------------------------------+---------------------------------------
Reporter: Nicolas Noé | Owner: Nicolas Noé
Type: Bug | Status: assigned
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
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:"2134e7d4391c2279f6cfddadc2a0c1195cec16e4" 2134e7d4]:
{{{
#!CommitTicketReference repository=""
revision="2134e7d4391c2279f6cfddadc2a0c1195cec16e4"
Refs #29389 -- Added Paginator test for float page number.
}}}

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

Reply all
Reply to author
Forward
0 new messages