[ovs-dev] [PATCH 08/11] python: Resolve a deprecation warning.
Russell Bryant
russell at ovn.org
Tue Dec 22 17:17:30 UTC 2015
Resolve the following deprecation warning. This deprecation warning
advises to use an alternative syntax which is also compatible with
Python 3, where has_key() was removed.
W601 .has_key() is deprecated, use 'in'
Also fix this related error:
E713 test for membership should be 'not in'
Signed-off-by: Russell Bryant <russell at ovn.org>
---
Makefile.am | 2 +-
tests/test-jsonrpc.py | 4 ++--
tests/test-ovsdb.py | 2 +-
vtep/ovs-vtep | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 978bb7f..556d252 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -342,7 +342,7 @@ endif
if HAVE_FLAKE8
ALL_LOCAL += pep8-check
pep8-check: $(FLAKE8_PYFILES)
- if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E502,E703,E713,W601; then touch $@; else exit 1; fi
+ if flake8 $^ --ignore=E111,E112,E113,E123,E126,E127,E128,E129,E131,E502,E703; then touch $@; else exit 1; fi
endif
include $(srcdir)/manpages.mk
diff --git a/tests/test-jsonrpc.py b/tests/test-jsonrpc.py
index 86db4aa..8ba0703 100644
--- a/tests/test-jsonrpc.py
+++ b/tests/test-jsonrpc.py
@@ -86,7 +86,7 @@ def do_listen(name):
if error:
rpc.close()
dead_rpcs.append(rpc)
- rpcs = [rpc for rpc in rpcs if not rpc in dead_rpcs]
+ rpcs = [rpc for rpc in rpcs if rpc not in dead_rpcs]
if done and not rpcs:
break
@@ -187,7 +187,7 @@ notify REMOTE METHOD PARAMS send notification and exit
command_name = args.command[0]
args = args.command_args
- if not command_name in commands:
+ if command_name not in commands:
sys.stderr.write("%s: unknown command \"%s\" "
"(use --help for help)\n" % (argv[0], command_name))
sys.exit(1)
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index f121a0c..e240208 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -587,7 +587,7 @@ def main(argv):
command_name = args[0]
args = args[1:]
- if not command_name in commands:
+ if command_name not in commands:
sys.stderr.write("%s: unknown command \"%s\" "
"(use --help for help)\n" % (ovs.util.PROGRAM_NAME,
command_name))
diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep
index eb8e97b..07856c4 100755
--- a/vtep/ovs-vtep
+++ b/vtep/ovs-vtep
@@ -286,7 +286,7 @@ class Logical_Switch(object):
self.add_remote_mac(mac, remote_macs[mac])
for mac in self.remote_macs.keys():
- if not remote_macs.has_key(mac):
+ if mac not in remote_macs:
self.del_remote_mac(mac)
self.remote_macs = remote_macs
@@ -587,7 +587,7 @@ def handle_physical():
ls = Lswitches[ls_name]
new_bindings.add(binding)
- if Bindings.has_key(binding):
+ if binding in Bindings:
if Bindings[binding] == ls_name:
continue
else:
--
2.5.0
More information about the dev
mailing list