diff options
author | Daniel Axtens <dja@axtens.net> | 2017-08-28 14:11:27 +1000 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2017-08-28 09:12:15 +0100 |
commit | 0901378a0aa32fbd9c0e6a937219199dab759ce0 (patch) | |
tree | bbd93685f40e9e3b4df6d878ac6cb0f8105467db | |
parent | 606022a305875f5cceae1f135f3a34b738305fd3 (diff) | |
download | patchwork-0901378a0aa32fbd9c0e6a937219199dab759ce0.tar patchwork-0901378a0aa32fbd9c0e6a937219199dab759ce0.tar.gz |
Handle EmptyPage exceptions
If a user asks for a page beyond the range of pages, an EmptyPage
exception is thrown. Catch this and clamp the page number
appropriately.
Reported-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Tested-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Stephen Finucane <stephen@that.guru>
-rw-r--r-- | patchwork/paginator.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/patchwork/paginator.py b/patchwork/paginator.py index 609e908..e4cf556 100644 --- a/patchwork/paginator.py +++ b/patchwork/paginator.py @@ -55,6 +55,12 @@ class Paginator(paginator.Paginator): except ValueError: page_no = 1 self.current_page = self.page(page_no) + except paginator.EmptyPage: + if page_no < 1: + page_no = 1 + else: + page_no = self.num_pages + self.current_page = self.page(page_no) self.leading_set = self.trailing_set = [] |