Skip to content

Commit

Permalink
Fix regression crashing adj allocations on first move
Browse files Browse the repository at this point in the history
Fixes BACKEND-3WN

This error is "dictionary keys changed during iteration". The offending
lines have been there for 2 years and it's still working fine in 2.4,
so I'm guessing it's some package upgrade for 2.5 being stricter or
something?
  • Loading branch information
czlee committed Oct 5, 2020
1 parent a6b5c6c commit 6839ca5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tabbycat/draw/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def receive_importance(self, content):
d_or_p.save()

serialized = self.importance_serializer(debates_or_panels, many=True)
del content['importance'] # Reserialise as debatesOrPanels
self.return_attributes(content, serialized)
content_to_return = content.copy()
del content_to_return['importance'] # Reserialise as debatesOrPanels
self.return_attributes(content_to_return, serialized)

def delete_adjudicators(self, debate_or_panel, adj_ids):
return debate_or_panel.related_adjudicator_set.exclude(
Expand Down Expand Up @@ -95,8 +96,9 @@ def receive_adjudicators(self, content):
# TODO: is it necessary to re-fetch? Or should the objects be returned?
debates_or_panels = self.get_debates_or_panels(changes)
serialized = self.adjudicators_serializer(debates_or_panels, many=True)
del content['adjudicators']
self.return_attributes(content, serialized)
content_to_return = content.copy()
del content_to_return['adjudicators']
self.return_attributes(content_to_return, serialized)

def return_attributes(self, original_content, serialized_content):
""" Return the original JSON but with the generic debatesOrPanels key """
Expand Down

0 comments on commit 6839ca5

Please sign in to comment.