mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Revert "Fixed 19895 -- Made second iteration over invalid queryset raise an exception too"
This reverts commit 2cd0edaa47
.
This commit was the cause of a memory leak. See ticket for more details.
Thanks Anssi Kääriäinen for identifying the source of the bug.
This commit is contained in:
parent
ccb87f97ad
commit
23490a2394
2 changed files with 2 additions and 19 deletions
|
@ -104,7 +104,7 @@ class QuerySet(object):
|
|||
len(self)
|
||||
|
||||
if self._result_cache is None:
|
||||
self._iter = self._safe_iterator(self.iterator())
|
||||
self._iter = self.iterator()
|
||||
self._result_cache = []
|
||||
if self._iter:
|
||||
return self._result_iter()
|
||||
|
@ -341,18 +341,6 @@ class QuerySet(object):
|
|||
|
||||
yield obj
|
||||
|
||||
def _safe_iterator(self, iterator):
|
||||
# ensure result cache is cleared when iterating over a queryset
|
||||
# raises an exception
|
||||
try:
|
||||
for item in iterator:
|
||||
yield item
|
||||
except StopIteration:
|
||||
raise
|
||||
except Exception:
|
||||
self._result_cache = None
|
||||
raise
|
||||
|
||||
def aggregate(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a dictionary containing the calculations (aggregation)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue