aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_serializer.py17
-rw-r--r--test/test_bier.py2
2 files changed, 10 insertions, 9 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py
index 5b45cd8a569..8ae46fee83c 100644
--- a/src/vpp-api/python/vpp_papi/vpp_serializer.py
+++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py
@@ -250,21 +250,22 @@ class VLAList(object):
self.options = args
return self
- def pack(self, list, kwargs=None):
- if not list:
+ def pack(self, lst, kwargs=None):
+ if not lst:
return b""
- if len(list) != kwargs[self.length_field]:
+ if len(lst) != kwargs[self.length_field]:
raise VPPSerializerValueError(
'Variable length error, got: {} expected: {}'
- .format(len(list), kwargs[self.length_field]))
- b = bytes()
+ .format(len(lst), kwargs[self.length_field]))
# u8 array
-
if self.packer.size == 1:
- return bytearray(list)
+ if isinstance(lst, list):
+ return b''.join(lst)
+ return bytes(lst)
- for e in list:
+ b = bytes()
+ for e in lst:
b += self.packer.pack(e)
return b
diff --git a/test/test_bier.py b/test/test_bier.py
index 793c8ca0362..b188c364a7a 100644
--- a/test/test_bier.py
+++ b/test/test_bier.py
@@ -167,7 +167,7 @@ class TestBier(VppTestCase):
byte_val = scapy.compat.chb(1 << (bp - 1) % 8)
byte_pos = n_bytes - (((bp - 1) // 8) + 1)
byte_array[byte_pos] = byte_val
- bitstring = ''.join([scapy.compat.chb(x) for x in byte_array])
+ bitstring = b''.join([scapy.compat.chb(x) for x in byte_array])
self.assertEqual(len(bitstring), len(bier_hdr.BitString))
self.assertEqual(bitstring, bier_hdr.BitString)