On 2/29/20 12:20 AM, Ben Pfaff wrote: > On Tue, Feb 25, 2020 at 11:59:06AM -0800, William Tu wrote: >> Currently ovs-bugtool does not work due to Python2 deprecated. >> When moving to Python3, a couple of things are broken in ovs-bugtool, >> ex: import libraries issues such as StringIO and commands. >> Also there are some bytes to string convertion in this patch >> because in Python3,strings are now always Unicode and a new type 'bytes' >> is added for handling binary strings. >> >> Signed-off-by: William Tu <[email protected]> > > Some of these are a little puzzling. I see a lot more use of list() > than I would have expected to be necessary. > > For example, I don't know why this change is needed: >> - for (k, v) in data.items(): >> + for (k, v) in list(data.items()): >> cap = v['cap'] >> if 'cmd_args' in v:
This change is needed, because in python2 items() returns a new list, but in python3 it returns a 'view object' which is not exactly an iterator, but something similar. So, we can't use this view object for iteration while modifying original dictionary just like we can't use iteritems() in python2 for this purpose. replying here just because the same change proposed again: https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/ Best regards, Ilya Maximets. _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
