map() has been changed to return an iterator in python3.  Iterators aren't
JSON serializable, and can be used only once for for loops.

Signed-off-by: IWAMOTO Toshihiro <[email protected]>
---
 ryu/base/app_manager.py                           |  3 +--
 ryu/lib/of_config/base.py                         |  4 ++--
 ryu/lib/packet/bgp.py                             |  4 ++--
 ryu/lib/packet/vrrp.py                            | 10 ++++------
 ryu/lib/stringify.py                              |  4 ++--
 ryu/ofproto/ofproto_v1_0_parser.py                |  2 +-
 ryu/ofproto/ofproto_v1_2_parser.py                |  2 +-
 ryu/ofproto/ofproto_v1_3_parser.py                |  2 +-
 ryu/ofproto/ofproto_v1_4_parser.py                |  2 +-
 ryu/ofproto/ofproto_v1_5_parser.py                |  2 +-
 ryu/services/protocols/bgp/operator/views/base.py |  4 ++--
 ryu/services/protocols/bgp/utils/validation.py    |  2 +-
 ryu/services/protocols/vrrp/event.py              |  2 +-
 ryu/tests/unit/ofproto/test_parser.py             |  2 +-
 ryu/tests/unit/ofproto/test_parser_ofpmatch.py    |  2 +-
 ryu/tests/unit/ofproto/test_parser_ofpstats.py    |  2 +-
 16 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index b81e59c..340d31a 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -380,8 +380,7 @@ class AppManager(object):
         while len(app_lists) > 0:
             app_cls_name = app_lists.pop(0)
 
-            context_modules = map(lambda x: x.__module__,
-                                  self.contexts_cls.values())
+            context_modules = [x.__module__ for x in 
self.contexts_cls.values()]
             if app_cls_name in context_modules:
                 continue
 
diff --git a/ryu/lib/of_config/base.py b/ryu/lib/of_config/base.py
index c657b10..e2e4eb5 100644
--- a/ryu/lib/of_config/base.py
+++ b/ryu/lib/of_config/base.py
@@ -92,7 +92,7 @@ class _Base(stringify.StringifyMixin):
                 continue
             if isinstance(v, list):
                 assert e.is_list
-                ele = map(convert, v)
+                ele = list(map(convert, v))
             else:
                 assert not e.is_list
                 ele = [convert(v)]
@@ -128,7 +128,7 @@ class _Base(stringify.StringifyMixin):
                     v = [v]
             else:
                 assert e.is_list
-                v = map(convert, v)
+                v = list(map(convert, v))
             k = _pythonify(e.name)
             assert k not in kwargs
             kwargs[k] = v
diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py
index 575da9d..cd324c7 100644
--- a/ryu/lib/packet/bgp.py
+++ b/ryu/lib/packet/bgp.py
@@ -808,10 +808,10 @@ class _LabelledAddrPrefix(_AddrPrefix):
     def _to_bin(cls, addr):
         labels = addr[0]
         rest = addr[1:]
-        labels = map(lambda x: x << 4, labels)
+        labels = [x << 4 for x in labels]
         if labels:
             labels[-1] |= 1  # bottom of stack
-        bin_labels = map(cls._label_to_bin, labels)
+        bin_labels = list(map(cls._label_to_bin, labels))
         return bytes(reduce(lambda x, y: x + y, bin_labels,
                             bytearray()) + cls._prefix_to_bin(rest))
 
diff --git a/ryu/lib/packet/vrrp.py b/ryu/lib/packet/vrrp.py
index b840cd6..cc58ebb 100644
--- a/ryu/lib/packet/vrrp.py
+++ b/ryu/lib/packet/vrrp.py
@@ -463,8 +463,7 @@ class vrrpv2(vrrp):
         ip_addresses_pack_str = cls._ip_addresses_pack_str(count_ip)
         ip_addresses_bin = struct.unpack_from(ip_addresses_pack_str, buf,
                                               offset)
-        ip_addresses = map(lambda x: addrconv.ipv4.bin_to_text(x),
-                           ip_addresses_bin)
+        ip_addresses = [addrconv.ipv4.bin_to_text(x) for x in ip_addresses_bin]
 
         offset += struct.calcsize(ip_addresses_pack_str)
         auth_data = struct.unpack_from(cls._AUTH_DATA_PACK_STR, buf, offset)
@@ -499,8 +498,7 @@ class vrrpv2(vrrp):
                          vrrp_.checksum)
         offset += vrrpv2._MIN_LEN
         struct.pack_into(ip_addresses_pack_str, buf, offset,
-                         *map(lambda x: addrconv.ipv4.text_to_bin(x),
-                              vrrp_.ip_addresses))
+                         *[addrconv.ipv4.text_to_bin(x) for x in 
vrrp_.ip_addresses])
         offset += ip_addresses_len
         struct.pack_into(vrrpv2._AUTH_DATA_PACK_STR, buf, offset,
                          *vrrp_.auth_data)
@@ -590,7 +588,7 @@ class vrrpv3(vrrp):
                     address_len, count_ip))
 
         ip_addresses_bin = struct.unpack_from(pack_str, buf, offset)
-        ip_addresses = map(lambda x: conv(x), ip_addresses_bin)
+        ip_addresses = [conv(x) for x in ip_addresses_bin]
         msg = cls(version, type_, vrid, priority,
                   count_ip, max_adver_int, checksum, ip_addresses)
         return msg, None, buf[len(msg):]
@@ -624,7 +622,7 @@ class vrrpv3(vrrp):
                          vrrp_.vrid, vrrp_.priority,
                          vrrp_.count_ip, vrrp_.max_adver_int, vrrp_.checksum)
         struct.pack_into(ip_addresses_pack_str, buf, vrrpv3._MIN_LEN,
-                         *map(lambda x: conv(x), vrrp_.ip_addresses))
+                         *[conv(x) for x in vrrp_.ip_addresses])
 
         if checksum:
             vrrp_.checksum = packet_utils.checksum_ip(prev, len(buf), buf)
diff --git a/ryu/lib/stringify.py b/ryu/lib/stringify.py
index 3c5bf5e..ca76241 100644
--- a/ryu/lib/stringify.py
+++ b/ryu/lib/stringify.py
@@ -190,7 +190,7 @@ class StringifyMixin(object):
             if isinstance(v, (bytes, six.text_type)):
                 json_value = encode_string(v)
             elif isinstance(v, list):
-                json_value = map(_encode, v)
+                json_value = list(map(_encode, v))
             elif isinstance(v, dict):
                 json_value = _mapdict(_encode, v)
                 # while a python dict key can be any hashable object,
@@ -272,7 +272,7 @@ class StringifyMixin(object):
             if isinstance(json_value, (bytes, six.text_type)):
                 v = decode_string(json_value)
             elif isinstance(json_value, list):
-                v = map(_decode, json_value)
+                v = list(map(_decode, json_value))
             elif isinstance(json_value, dict):
                 if cls._is_class(json_value):
                     v = cls.obj_from_jsondict(json_value, **additional_args)
diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index 8adeea7..f4648f7 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -1016,7 +1016,7 @@ class 
OFPDescStats(ofproto_parser.namedtuple('OFPDescStats', (
         desc = struct.unpack_from(ofproto.OFP_DESC_STATS_PACK_STR,
                                   buf, offset)
         desc = list(desc)
-        desc = map(lambda x: x.rstrip('\0'), desc)
+        desc = [x.rstrip('\0') for x in desc]
         stats = cls(*desc)
         stats.length = ofproto.OFP_DESC_STATS_SIZE
         return stats
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
b/ryu/ofproto/ofproto_v1_2_parser.py
index fa5d36c..7ecce12 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -1985,7 +1985,7 @@ class 
OFPDescStats(ofproto_parser.namedtuple('OFPDescStats', (
         desc = struct.unpack_from(ofproto.OFP_DESC_STATS_PACK_STR,
                                   buf, offset)
         desc = list(desc)
-        desc = map(lambda x: x.rstrip('\0'), desc)
+        desc = [x.rstrip('\0') for x in desc]
         stats = cls(*desc)
         stats.length = ofproto.OFP_DESC_STATS_SIZE
         return stats
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py 
b/ryu/ofproto/ofproto_v1_3_parser.py
index 930e8b5..7724e97 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -3655,7 +3655,7 @@ class 
OFPDescStats(ofproto_parser.namedtuple('OFPDescStats', (
         desc = struct.unpack_from(ofproto.OFP_DESC_PACK_STR,
                                   buf, offset)
         desc = list(desc)
-        desc = map(lambda x: x.rstrip('\0'), desc)
+        desc = [x.rstrip('\0') for x in desc]
         stats = cls(*desc)
         stats.length = ofproto.OFP_DESC_SIZE
         return stats
diff --git a/ryu/ofproto/ofproto_v1_4_parser.py 
b/ryu/ofproto/ofproto_v1_4_parser.py
index 0c391ce..1a6e0e7 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -2101,7 +2101,7 @@ class 
OFPDescStats(ofproto_parser.namedtuple('OFPDescStats', (
         desc = struct.unpack_from(ofproto.OFP_DESC_PACK_STR,
                                   buf, offset)
         desc = list(desc)
-        desc = map(lambda x: x.rstrip('\0'), desc)
+        desc = [x.rstrip('\0') for x in desc]
         stats = cls(*desc)
         stats.length = ofproto.OFP_DESC_SIZE
         return stats
diff --git a/ryu/ofproto/ofproto_v1_5_parser.py 
b/ryu/ofproto/ofproto_v1_5_parser.py
index b7152a8..bf4a78d 100644
--- a/ryu/ofproto/ofproto_v1_5_parser.py
+++ b/ryu/ofproto/ofproto_v1_5_parser.py
@@ -2242,7 +2242,7 @@ class 
OFPDescStats(ofproto_parser.namedtuple('OFPDescStats', (
         desc = struct.unpack_from(ofproto.OFP_DESC_PACK_STR,
                                   buf, offset)
         desc = list(desc)
-        desc = map(lambda x: x.rstrip('\0'), desc)
+        desc = [x.rstrip('\0') for x in desc]
         stats = cls(*desc)
         stats.length = ofproto.OFP_DESC_SIZE
         return stats
diff --git a/ryu/services/protocols/bgp/operator/views/base.py 
b/ryu/services/protocols/bgp/operator/views/base.py
index c25ddfd..a528f0f 100644
--- a/ryu/services/protocols/bgp/operator/views/base.py
+++ b/ryu/services/protocols/bgp/operator/views/base.py
@@ -143,7 +143,7 @@ class OperatorListView(OperatorAbstractView):
     def combine_related(self, field_name):
         f = self._fields[field_name]
         return CombinedViewsWrapper(RdyToFlattenList(
-            map(lambda obj: f.retrieve_and_wrap(obj), self.model)
+            [f.retrieve_and_wrap(obj) for obj in self.model]
         ))
 
     def get_field(self, field_name):
@@ -175,7 +175,7 @@ class OperatorDictView(OperatorAbstractView):
     def combine_related(self, field_name):
         f = self._fields[field_name]
         return CombinedViewsWrapper(RdyToFlattenList(
-            map(lambda obj: f.retrieve_and_wrap(obj), self.model.values()))
+            [f.retrieve_and_wrap(obj) for obj in self.model.values()])
         )
 
     def get_field(self, field_name):
diff --git a/ryu/services/protocols/bgp/utils/validation.py 
b/ryu/services/protocols/bgp/utils/validation.py
index 9851998..659ea24 100644
--- a/ryu/services/protocols/bgp/utils/validation.py
+++ b/ryu/services/protocols/bgp/utils/validation.py
@@ -31,7 +31,7 @@ def is_valid_ipv4(ipv4):
         valid = False
     else:
         try:
-            a, b, c, d = map(lambda x: int(x), ipv4.split('.'))
+            a, b, c, d = [int(x) for x in ipv4.split('.')]
             if (a < 0 or a > 255 or b < 0 or b > 255 or c < 0 or c > 255 or
                     d < 0 or d > 255):
                 valid = False
diff --git a/ryu/services/protocols/vrrp/event.py 
b/ryu/services/protocols/vrrp/event.py
index 79cacaf..dbf8e27 100644
--- a/ryu/services/protocols/vrrp/event.py
+++ b/ryu/services/protocols/vrrp/event.py
@@ -156,7 +156,7 @@ class VRRPConfig(object):
 
     def __hash__(self):
         hash((self.version, self.vrid, self.priority,
-              map(vrrp.ip_text_to_bin, self.ip_addresses),
+              list(map(vrrp.ip_text_to_bin, self.ip_addresses)),
               self.advertisement_interval, self.preempt_mode,
               self.preempt_delay, self.accept_mode, self.is_ipv6))
 
diff --git a/ryu/tests/unit/ofproto/test_parser.py 
b/ryu/tests/unit/ofproto/test_parser.py
index fe68386..0fb7448 100644
--- a/ryu/tests/unit/ofproto/test_parser.py
+++ b/ryu/tests/unit/ofproto/test_parser.py
@@ -204,7 +204,7 @@ class Test_Parser(unittest.TestCase):
             def _remove(d, names):
                 f = lambda x: _remove(x, names)
                 if isinstance(d, list):
-                    return map(f, d)
+                    return list(map(f, d))
                 if isinstance(d, dict):
                     d2 = {}
                     for k, v in d.items():
diff --git a/ryu/tests/unit/ofproto/test_parser_ofpmatch.py 
b/ryu/tests/unit/ofproto/test_parser_ofpmatch.py
index 5f86b15..8775719 100644
--- a/ryu/tests/unit/ofproto/test_parser_ofpmatch.py
+++ b/ryu/tests/unit/ofproto/test_parser_ofpmatch.py
@@ -211,7 +211,7 @@ def _add_tests():
                     l = itertools.product(l, cls.generate())
                     keys.append(k)
                     clss.append(cls)
-                l = map(lambda x: flatten(x)[1:], l)
+                l = [flatten(x)[1:] for x in l]
                 for domask in [True, False]:
                     for values in l:
                         if domask:
diff --git a/ryu/tests/unit/ofproto/test_parser_ofpstats.py 
b/ryu/tests/unit/ofproto/test_parser_ofpstats.py
index 74d7a49..0ce428a 100644
--- a/ryu/tests/unit/ofproto/test_parser_ofpstats.py
+++ b/ryu/tests/unit/ofproto/test_parser_ofpstats.py
@@ -169,7 +169,7 @@ def _add_tests():
                     l = itertools.product(l, cls.generate())
                     keys.append(k)
                     clss.append(cls)
-                l = map(lambda x: flatten(x)[1:], l)
+                l = [flatten(x)[1:] for x in l]
                 for values in l:
                     d = dict(zip(keys, values))
                     for n, uv in d.items():
-- 
2.1.4


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to