Opened 12 years ago

Closed 12 years ago

#4053 closed (invalid)

implicitly control in paginator causes unexpected return values.

Reported by: meren@… Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: Keywords: paginator
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



Pagiantor doesn't check the 'page_number' value in "has_next_page" and "has_previous_page" functions. It causes this:

>>> from django.core.paginator import ObjectPaginator
>>> from import Entry
>>> e = Entry.objects.all()
>>> len(e)
>>> paginator_result = ObjectPaginator(e, 10)
>>> paginator_result.pages
>>> page_number = 0
>>> paginator_result.has_next_page(page_number)
>>> paginator_result.has_previous_page(page_number)
>>> page_number = "0"
>>> paginator_result.has_next_page(page_number)
>>> paginator_result.has_previous_page(page_number)

Please review the patch attached below (I'm sorry if ticket is in the wrong component, I couldn't find any closer).


  1. Murat Eren.

Attachments (1)

paginator-check_int.diff (942 bytes) - added by meren@… 12 years ago.

Download all attachments as: .zip

Change History (2)

Changed 12 years ago by meren@…

Attachment: paginator-check_int.diff added

comment:1 Changed 12 years ago by Brian Rosner <brosner@…>

Resolution: invalid
Status: newclosed

I think in this case that the type conversion should be done before passing it in to has_*_page methods. These methods shouldn't care where the data came from.

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