1
0
mirror of https://github.com/django/django.git synced 2025-10-29 16:46:11 +00:00

Fixed #19607 - prefetch_related crash

Thanks to av@rdf.ru and flarno11@yahoo.de for the report.
This commit is contained in:
Luke Plant
2013-05-24 10:01:34 +01:00
parent 48424adaba
commit 4fd94969d8
3 changed files with 51 additions and 3 deletions

View File

@@ -1558,8 +1558,13 @@ def prefetch_related_objects(result_cache, related_lookups):
good_objects = False
break
else:
# We already did this list
break
# Since prefetching can re-use instances, it is possible to
# have the same instance multiple times in obj_list. So we
# can reach this branch either because we did all of
# obj_list already, or because we did 'obj' earlier in this
# iteration over obj_list. In the first case we could
# shortcut and exit the loop, but not in the second.
continue
if not good_objects:
break