Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7746 closed (invalid)

Paginator QuerySet count regression

Reported by: chrisrbennett Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords: paginator
Cc: batiste@…, Adrian Holovaty, mrts Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The enhancement for #7478 committed in [7865] regresses on a previous bug fix in [7819] related to QuerySet paginiation.

I copied the try-wrapper fix from [7819] and this seems to handle the exception:

try:
    self._count = self.object_list.count()
except (AttributeError, TypeError):
    self._count = len(self.object_list)

I have no clue why .count() model deepcopy is failing, but it has been discussed previously in #7204. Perhaps there is a larger issue here:

Environment:
Django Version: 0.97-pre-SVN-7922
Python Version: 2.5.2

Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
  86.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/chris/src/msn/msn/../msn/search/views.py" in zipcode_search
  64.                "page": paginator.page(page_number),
File "/usr/lib/python2.5/site-packages/django/core/paginator.py" in page
  35.         number = self.validate_number(number)
File "/usr/lib/python2.5/site-packages/django/core/paginator.py" in validate_number
  26.         if number > self.num_pages:
File "/usr/lib/python2.5/site-packages/django/core/paginator.py" in _get_num_pages
  56.             hits = self.count - 1 - self.orphans
File "/usr/lib/python2.5/site-packages/django/core/paginator.py" in _get_count
  47.                 self._count = self.object_list.count()
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in count
  290.         return self.query.get_count()
File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py" in get_count
  215.         obj = self.clone()
File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py" in clone
  173.         obj.where = deepcopy(self.where)
File "/usr/lib/python2.5/copy.py" in deepcopy
  173.                 y = copier(memo)
File "/usr/lib/python2.5/site-packages/django/utils/tree.py" in __deepcopy__
  61.         obj.children = deepcopy(self.children, memodict)
File "/usr/lib/python2.5/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.5/copy.py" in _deepcopy_list
  227.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.5/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.5/copy.py" in _deepcopy_tuple
  234.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.5/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.5/copy.py" in _reconstruct
  337.             state = deepcopy(state, memo)
File "/usr/lib/python2.5/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.5/copy.py" in _deepcopy_dict
  254.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.5/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.5/copy.py" in _deepcopy_list
  227.         y.append(deepcopy(a, memo))
File "/usr/lib/python2.5/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.5/copy.py" in _reconstruct
  337.             state = deepcopy(state, memo)
File "/usr/lib/python2.5/copy.py" in deepcopy
  162.         y = copier(x, memo)
File "/usr/lib/python2.5/copy.py" in _deepcopy_dict
  254.         y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/usr/lib/python2.5/copy.py" in deepcopy
  189.                 y = _reconstruct(x, rv, 1, memo)
File "/usr/lib/python2.5/copy.py" in _reconstruct
  322.     y = callable(*args)
File "/usr/lib/python2.5/copy_reg.py" in __newobj__
  92.     return cls.__new__(cls, *args)

Exception Type: TypeError
Exception Value: object.__new__(generator) is not safe, use generator.__new__()

cc'ing those involved with #7478

Change History (4)

comment:1 by Marc Garcia, 16 years ago

milestone: 1.0 alpha1.0

Not nfa-blocker so setting milestone to 1.0

comment:2 by Gary Wilson, 16 years ago

Resolution: invalid
Status: newclosed

The fix in [7819] was for the legacy ObjectPaginator class. [7865] changed only the newer QuerySetPaginator and Paginator classes, so it was not a regression.

comment:3 by Gary Wilson, 16 years ago

...but you might be interested in [8121] (forgot to reference this ticket in the commit message).

comment:4 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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