Opened 7 years ago

Closed 7 years ago

#29389 closed Bug (fixed)

Make Paginator reject non-integer page numbers of type float

Reported by: Nicolas Noé Owned by: Nicolas Noé
Component: Core (Other) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (5)

comment:1 by Tim Graham, 7 years ago

Summary: Paginator accepts floats as a page numberMake Paginator reject non-integer page numbers of type float
Triage Stage: UnreviewedAccepted

comment:2 by Nicolas Noé, 7 years ago

comment:3 by Nicolas Noé, 7 years ago

Has patch: set

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

In 2134e7d4:

Refs #29389 -- Added Paginator test for float page number.

comment:5 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In c629d4e9:

Fixed #29389 -- Made Paginator reject non-integer page numbers of type float.

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