* ofproto_parser.MsgBase.__str__(): avoid "TypeError: %x format: a number is 
required, not NoneType"
 * bgp.BadMsg.__str__(): avoid "AttributeError: 'BadMsg' object has no 
attribute 'msg'"

Signed-off-by: Akihiro Suda <suda.akih...@lab.ntt.co.jp>
---
 ryu/lib/packet/bgp.py         | 2 +-
 ryu/ofproto/ofproto_parser.py | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/ryu/lib/packet/bgp.py b/ryu/lib/packet/bgp.py
index 2f507f0..81feef3 100644
--- a/ryu/lib/packet/bgp.py
+++ b/ryu/lib/packet/bgp.py
@@ -276,7 +276,7 @@ class BadMsg(BgpExc):
         self.data = struct.pack('B', msg_type)
 
     def __str__(self):
-        return '<BadMsg %d>' % (self.msg,)
+        return '<BadMsg %d>' % (self.msg_type,)
 
 # ============================================================================
 # OPEN Message Errors
diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py
index 9625cd8..86b8439 100644
--- a/ryu/ofproto/ofproto_parser.py
+++ b/ryu/ofproto/ofproto_parser.py
@@ -163,9 +163,11 @@ class MsgBase(StringifyMixin):
         self.buf = buffer(buf)
 
     def __str__(self):
-        buf = 'version: 0x%x msg_type 0x%x xid 0x%x ' % (self.version,
-                                                         self.msg_type,
-                                                         self.xid)
+        def hexify(x):
+            return str(None) if x is None else '0x%x' % x
+        buf = 'version: %s msg_type %s xid %s ' % (hexify(self.version),
+                                                   hexify(self.msg_type),
+                                                   hexify(self.xid))
         return buf + StringifyMixin.__str__(self)
 
     @classmethod
-- 
2.1.0



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to