[ovs-dev] [PATCH 2/9] python: Stop use of tuple parameter unpacking

Russell Bryant russell at ovn.org
Wed Jan 6 20:50:22 UTC 2016


Python 3 removed support for tuple parameter unpacking.

https://www.python.org/dev/peps/pep-3113/

Instead of:

    def foo((a, b)):
        print(a)
        print(b)

you should do:

    def foo(a_b):
        a, b = a_b
        print(a)
        print(b)

but in both uses here, the values were never used so the fix is even
simpler.

Signed-off-by: Russell Bryant <russell at ovn.org>
---
 python/ovstest/udp.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/ovstest/udp.py b/python/ovstest/udp.py
index d6e6162..acd28d5 100644
--- a/python/ovstest/udp.py
+++ b/python/ovstest/udp.py
@@ -31,7 +31,7 @@ class UdpListener(DatagramProtocol):
     def __init__(self):
         self.stats = []
 
-    def datagramReceived(self, data, (_1, _2)):
+    def datagramReceived(self, data, _1_2):
         """This function is called each time datagram is received"""
         try:
             self.stats.append(struct.unpack_from("Q", data, 0))
@@ -67,7 +67,7 @@ class UdpSender(DatagramProtocol):
             self.looper.stop()
             self.looper = None
 
-    def datagramReceived(self, data, (host, port)):
+    def datagramReceived(self, data, host_port):
         pass
 
     def sendData(self):
-- 
2.5.0




More information about the dev mailing list