Fix infinite recursion on github editing of pr #279

Fixes: 89632483a7
fix_request_path_info
Diederik van der Boor 2017-04-26 16:38:26 +02:00
parent b2b1e137b2
commit 09d785f5bb
1 changed files with 14 additions and 15 deletions

View File

@ -35,27 +35,26 @@ def _polymorhic_iterator(queryset, base_iter):
but it requests the objects in chunks from the database, but it requests the objects in chunks from the database,
with Polymorphic_QuerySet_objects_per_request per chunk with Polymorphic_QuerySet_objects_per_request per chunk
""" """
while True: # Make sure the base iterator is read in chunks instead of
# reading it completely, in case our caller read only a few objects.
for i in range(Polymorphic_QuerySet_objects_per_request):
base_result_objects = [] base_result_objects = []
reached_end = False reached_end = False
# Make sure the base iterator is read in chunks instead of try:
# reading it completely, in case our caller read only a few objects. o = next(base_iter)
for i in range(Polymorphic_QuerySet_objects_per_request): base_result_objects.append(o)
try: except StopIteration:
o = next(base_iter) reached_end = True
base_result_objects.append(o) break
except StopIteration:
reached_end = True
break
real_results = queryset._get_real_instances(base_result_objects) real_results = queryset._get_real_instances(base_result_objects)
for o in real_results: for o in real_results:
yield o yield o
if reached_end: if reached_end:
return return
if django.VERSION >= (1, 9): if django.VERSION >= (1, 9):