Paginator last_on_page fails when .hits hasn't been called
|Reported by:||sago||Owned by:||Adrian Holovaty|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Because the last_on_page method relies on self._hits, it crashes when self._hits hasn't been set up yet.
This probably hasn't been seen before because most people call paginator.hits (which sets the ._hits attribute) before calling last_on_page.
All that's needed is to make sure ._hits is valid before proceeding. Calls to ._hits could be
exchanged for calls to .hits, but that would involve multiple calls to the property (and therefore the checking logic) in one go. Better, IMHO, to call self.hits once, then use the value throughout the method.
Patch shows this.