-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug-fix] ovs-monitor-ipsec Python2 code to Python3 #331
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to build lists for your iterations. You can iterate over the result of items()
, keys()
, values()
directly.
The reason why Python 2to3 is translating this:
for name, tunnel in self.tunnels.iteritems():
to that:
for name, tunnel in list(self.tunnels.items()):
Even though it is clear from the Python2 code that you are doing an iteration, is that the semantics of items
in Pyhton3 are different from the ones of iteritems
in Python2: faucetsdn/faucet#2372 (comment). But it only matters if you are modifying the dictionary while iterating over it.
So in a nutshell I think you can / should remove all the calls to list()
from your patch.
a698430
to
bdcc5ea
Compare
You are right, thank you! Code updated. |
bdcc5ea
to
5461662
Compare
Thanks for the patch. We need a Signed-off-by for this patch. The FAQ says:
|
Signed-off-by: lzhecheng <lzhecheng@vmware.com>
5461662
to
524de81
Compare
Thank you. I have updated the commit message. |
Submitted-at: openvswitch#331 Reported-at: openvswitch/ovs-issues#192 Fixes: 1ca0323 ("Require Python 3 and remove support for Python 2.") Signed-off-by: lzhecheng <lzhecheng@vmware.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Submitted-at: openvswitch#331 Reported-at: openvswitch/ovs-issues#192 Fixes: 1ca0323 ("Require Python 3 and remove support for Python 2.") Signed-off-by: lzhecheng <lzhecheng@vmware.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Submitted-at: openvswitch#331 Reported-at: openvswitch/ovs-issues#192 Fixes: 1ca0323 ("Require Python 3 and remove support for Python 2.") Signed-off-by: lzhecheng <lzhecheng@vmware.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Thanks! I applied this patch to master and backported down to 2.13. |
Submitted-at: openvswitch#331 Reported-at: openvswitch/ovs-issues#192 Fixes: 1ca0323 ("Require Python 3 and remove support for Python 2.") Signed-off-by: lzhecheng <lzhecheng@vmware.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
I am not a skilled Python programmer. I made these changes with 2to3 and debugging in another downstream project. Thanks.
Fixes: openvswitch/ovs-issues#192