Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixes Paginator.validate_number not raising a PageNotAnInteger except…

…ion when passed a non-int-castable type.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 3b6c5e5 commit 13bb06984cdfb937d0eac13b78c7c2337442c561 @SmileyChris SmileyChris committed
2  django/core/
@@ -22,7 +22,7 @@ def validate_number(self, number):
"Validates the given 1-based page number."
number = int(number)
- except ValueError:
+ except (TypeError, ValueError):
raise PageNotAnInteger('That page number is not an integer')
if number < 1:
raise EmptyPage('That page number is less than 1')
11 tests/regressiontests/pagination_regress/
@@ -1,4 +1,4 @@
-from django.core.paginator import Paginator, EmptyPage
+from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.utils.unittest import TestCase
class PaginatorTests(TestCase):
@@ -27,6 +27,15 @@ def check_attribute(self, name, paginator, expected, params):
"For '%s', expected %s but got %s. Paginator parameters were: %s"
% (name, expected, got, params))
+ def test_invalid_page_number(self):
+ """
+ Tests that invalid page numbers result in the correct exception being
+ raised.
+ """
+ paginator = Paginator([1, 2, 3], 2)
+ self.assertRaises(PageNotAnInteger, paginator.validate_number, None)
+ self.assertRaises(PageNotAnInteger, paginator.validate_number, 'x')
def test_paginator(self):
Tests the paginator attributes using varying inputs.

0 comments on commit 13bb069

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