Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13689 -- Convert the per_page value to an integer upon initial…

…ization of the Paginator class to prevent unpleasant TypeErrors. Thanks, rbanffy, Eric Florenzano and Claude Paroz.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16073 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0e9692bc66ed7cfbbcb4c8031b36e82751685238 1 parent e744fec
Jannis Leidel authored April 22, 2011
4  django/core/paginator.py
@@ -13,8 +13,8 @@ class EmptyPage(InvalidPage):
13 13
 class Paginator(object):
14 14
     def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):
15 15
         self.object_list = object_list
16  
-        self.per_page = per_page
17  
-        self.orphans = orphans
  16
+        self.per_page = int(per_page)
  17
+        self.orphans = int(orphans)
18 18
         self.allow_empty_first_page = allow_empty_first_page
19 19
         self._num_pages = self._count = None
20 20
 
5  tests/regressiontests/pagination_regress/tests.py
@@ -94,6 +94,11 @@ def test_paginator(self):
94 94
             (([1, 2], 1, 1, True), (2, 1, [1])),
95 95
             (([1, 2, 3], 2, 1, True), (3, 1, [1])),
96 96
             ((eleven, 10, 1, True), (11, 1, [1])),
  97
+            # Non-integer inputs
  98
+            ((ten, '4', 1, False), (10, 3, [1, 2, 3])),
  99
+            ((ten, u'4', 1, False), (10, 3, [1, 2, 3])),
  100
+            ((ten, 4, '1', False), (10, 3, [1, 2, 3])),
  101
+            ((ten, 4, u'1', False), (10, 3, [1, 2, 3])),
97 102
         )
98 103
         for params, output in tests:
99 104
             self.check_paginator(params, output)

0 notes on commit 0e9692b

Please sign in to comment.
Something went wrong with that request. Please try again.