Code

Ticket #13689: 13689.diff

File 13689.diff, 1.4 KB (added by claudep, 3 years ago)

Attaching Eric's patch as of comment #2

Line 
1diff --git a/django/core/paginator.py b/django/core/paginator.py
2index 495cdf2..27051e9 100644
3--- a/django/core/paginator.py
4+++ b/django/core/paginator.py
5@@ -12,8 +12,8 @@ class EmptyPage(InvalidPage):
6 class Paginator(object):
7     def __init__(self, object_list, per_page, orphans=0, allow_empty_first_page=True):
8         self.object_list = object_list
9-        self.per_page = per_page
10-        self.orphans = orphans
11+        self.per_page = int(per_page)
12+        self.orphans = int(orphans)
13         self.allow_empty_first_page = allow_empty_first_page
14         self._num_pages = self._count = None
15 
16diff --git a/tests/regressiontests/pagination_regress/tests.py b/tests/regressiontests/pagination_regress/tests.py
17index 28fe316..dd6210e 100644
18--- a/tests/regressiontests/pagination_regress/tests.py
19+++ b/tests/regressiontests/pagination_regress/tests.py
20@@ -85,6 +85,11 @@ class PaginatorTests(TestCase):
21             (([1, 2], 1, 1, True), (2, 1, [1])),
22             (([1, 2, 3], 2, 1, True), (3, 1, [1])),
23             ((eleven, 10, 1, True), (11, 1, [1])),
24+            # Non-integer inputs
25+            ((ten, '4', 1, False), (10, 3, [1, 2, 3])),
26+            ((ten, u'4', 1, False), (10, 3, [1, 2, 3])),
27+            ((ten, 4, '1', False), (10, 3, [1, 2, 3])),
28+            ((ten, 4, u'1', False), (10, 3, [1, 2, 3])),
29         )
30         for params, output in tests:
31             self.check_paginator(params, output)