workflow: Do not touch dict during iteration

Django 3.2 stored the field information as dict instead OrderedDict
because python 3.7+ ensure the field order of dict as the language spec.
We cannot touch dict itself during iteration. We need to pass a list
instead of a value from .items() itself to avoid the error.

Change-Id: Ie22865995d14fa60c16cf2cea582aa0eec46b65d
Closes-Bug: #1944548
This commit is contained in:
Akihiro Motoki 2021-09-22 19:37:44 +09:00
parent 0f34f6e7ed
commit a20c4f6f22

View File

@ -169,7 +169,7 @@ class Action(forms.Form, metaclass=ActionMetaclass):
return "<%s: %s>" % (self.__class__.__name__, self.slug)
def _populate_choices(self, request, context):
for field_name, bound_field in self.fields.items():
for field_name, bound_field in list(self.fields.items()):
meth = getattr(self, "populate_%s_choices" % field_name, None)
if meth is not None and callable(meth):
bound_field.choices = meth(request, context)