This change fixes an 'RuntimeError: dictionary changed size during
iteration' error that is raised because of different behaviour between
python2 and python3. An earlier attempt [1] to use the six library did
not fix the issue.
[1] https://review.opendev.org/660427
Resolves-Bug: #1829304
Change-Id: Ic4c5790a5d66e10a606327f4f4e4c92611f161d8