_IPAddrPrefix can be inherited by labeled addr prefix.
In that case, variable 'addr' is tuple and not string. so declare to
parse 'addr' in 'ascii' format in _IPAddrPrefix cause following error.
this patch fix this bug.
p = LabelledIPAddrPrefix(28, ([1], '192.168.0.0'))
p.to_jsondict()
Traceback (most recent call last):
File "./parse_labeled_addr_prefix.py", line 11, in <module>
p.to_jsondict()
File "/home/wataru/ryu/ryu/lib/stringify.py", line 210, in to_jsondict
dict_[k] = encode(k, v)
File "/home/wataru/ryu/ryu/lib/stringify.py", line 208, in <lambda>
encode = lambda k, x: self._encode_value(k, x, encode_string)
File "/home/wataru/ryu/ryu/lib/stringify.py", line 155, in
_encode_value
return cls._get_encoder(k, encode_string)(v)
File "/home/wataru/ryu/ryu/lib/stringify.py", line 56, in encode
return unicode(v, 'ascii')
TypeError: coercing to Unicode: need string or buffer, tuple found
Signed-off-by: ISHIDA Wataru <[email protected]>
---
ryu/lib/packet/bgp.py | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py
index 698d0fd..0a96b42 100644
--- a/ryu/lib/packet/bgp.py
+++ b/ryu/lib/packet/bgp.py
@@ -852,12 +852,6 @@ class _UnlabelledAddrPrefix(_AddrPrefix):
class _IPAddrPrefix(_AddrPrefix):
- _TYPE = {
- 'ascii': [
- 'addr'
- ]
- }
-
@staticmethod
def _prefix_to_bin(addr):
(addr,) = addr
@@ -869,12 +863,6 @@ class _IPAddrPrefix(_AddrPrefix):
class _IP6AddrPrefix(_AddrPrefix):
- _TYPE = {
- 'ascii': [
- 'addr'
- ]
- }
-
@staticmethod
def _prefix_to_bin(addr):
(addr,) = addr
@@ -923,6 +911,11 @@ class _VPNAddrPrefix(_AddrPrefix):
class IPAddrPrefix(_UnlabelledAddrPrefix, _IPAddrPrefix):
ROUTE_FAMILY = RF_IPv4_UC
+ _TYPE = {
+ 'ascii': [
+ 'addr'
+ ]
+ }
@property
def prefix(self):
@@ -935,6 +928,11 @@ class IPAddrPrefix(_UnlabelledAddrPrefix, _IPAddrPrefix):
class IP6AddrPrefix(_UnlabelledAddrPrefix, _IP6AddrPrefix):
ROUTE_FAMILY = RF_IPv6_UC
+ _TYPE = {
+ 'ascii': [
+ 'addr'
+ ]
+ }
@property
def prefix(self):
--
1.7.10.4
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel