Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Fixed 19895 -- Made second iteration over invalid queryset ra…

…ise an exception too"

This reverts commit 2cd0eda.
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.
  • Loading branch information...
commit 23490a2394bf03e119e4c9a7a09a9ba35edad430 1 parent ccb87f9
@claudep claudep authored
Showing with 2 additions and 19 deletions.
  1. +1 −13 django/db/models/query.py
  2. +1 −6 tests/basic/tests.py
View
14 django/db/models/query.py
@@ -104,7 +104,7 @@ def __iter__(self):
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 @@ def iterator(self):
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)
View
7 tests/basic/tests.py
@@ -3,7 +3,7 @@
from datetime import datetime
import threading
-from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError
+from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.db import connections, DEFAULT_DB_ALIAS
from django.db.models.fields import Field, FieldDoesNotExist
from django.db.models.query import QuerySet, EmptyQuerySet, ValuesListQuerySet
@@ -689,11 +689,6 @@ def test_emptyqs_distinct(self):
with self.assertNumQueries(0):
self.assertEqual(len(Article.objects.none().distinct('headline', 'pub_date')), 0)
- def test_invalid_qs_list(self):
- qs = Article.objects.order_by('invalid_column')
- self.assertRaises(FieldError, list, qs)
- self.assertRaises(FieldError, list, qs)
-
class ConcurrentSaveTests(TransactionTestCase):
@skipUnlessDBFeature('test_db_allows_multiple_connections')
def test_concurrent_delete_with_save(self):
Please sign in to comment.
Something went wrong with that request. Please try again.