Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#34758 closed Uncategorized (invalid)

Paginator.validate_number implementation has undocumented change in 4.2

Reported by: ruidc Owned by: nobody
Component: Core (Other) Version: 4.2
Severity: Normal Keywords: pagination
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://github.com/django/django/commit/9101adc8ba66556c98f3955138d72b3492a6a60c#commitcomment-123385537

This for me at least was an undesirable behavior change from 4.1
The previous behavior should either be reinstated or the change documented.

If there is agreement on direction, happy to make the PR either way.

Change History (3)

comment:1 by Mariusz Felisiak, 15 months ago

Resolution: invalid
Status: newclosed

In the current implementation num_pages cannot be less than 1, so this branch was unused. This looks like an issue in your custom paginator.

in reply to:  1 ; comment:2 by ruidc, 15 months ago

Replying to Mariusz Felisiak:

In the current implementation num_pages cannot be less than 1, so this branch was unused. This looks like an issue in your custom paginator.

From the code in main, that doesn't seem to be the case:
`
@cached_property

def num_pages(self):

"""Return the total number of pages."""
if self.count == 0 and not self.allow_empty_first_page:

return 0

...

`
Even so, the behavior for this public function changed when a valid integer of zero is passed. Is documentation of this change not in order at least?

Version 0, edited 15 months ago by ruidc (next)

in reply to:  2 comment:3 by Mariusz Felisiak, 15 months ago

Replying to ruidc:

Replying to Mariusz Felisiak:

In the current implementation num_pages cannot be less than 1, so this branch was unused. This looks like an issue in your custom paginator.

From the code in main, that doesn't seem to be the case:

    @cached_property
    def num_pages(self):
        """Return the total number of pages."""
        if self.count == 0 and not self.allow_empty_first_page:
            return 0
       ...

It's not possible when allow_empty_first_page is True.

Even so, the behavior for this public function changed when a valid integer of zero is passed.

I don't agree, this branch was unreachable.

Note: See TracTickets for help on using tickets.
Back to Top