To support Python3, buffer() type need to be replaced with six.binary_type().
Note: ofproto_v1_[0234]_parser was done in previous commits. Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com> --- ryu/ofproto/ofproto_v1_5_parser.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ryu/ofproto/ofproto_v1_5_parser.py b/ryu/ofproto/ofproto_v1_5_parser.py index 9cfac4b..4b6b235 100644 --- a/ryu/ofproto/ofproto_v1_5_parser.py +++ b/ryu/ofproto/ofproto_v1_5_parser.py @@ -250,7 +250,7 @@ class OFPErrorMsg(MsgBase): @classmethod def parser(cls, datapath, version, msg_type, msg_len, xid, buf): - type_, = struct.unpack_from('!H', buffer(buf), + type_, = struct.unpack_from('!H', six.binary_type(buf), ofproto.OFP_HEADER_SIZE) if type_ == ofproto.OFPET_EXPERIMENTER: return OFPErrorExperimenterMsg.parser(datapath, version, msg_type, @@ -1147,7 +1147,8 @@ class OFPPortDescPropRecirculate(OFPPortDescProp): rest = cls.get_rest(buf) nos = [] while rest: - (n,) = struct.unpack_from(cls._PORT_NO_PACK_STR, buffer(rest), 0) + (n,) = struct.unpack_from(cls._PORT_NO_PACK_STR, + six.binary_type(rest), 0) rest = rest[struct.calcsize(cls._PORT_NO_PACK_STR):] nos.append(n) return cls(port_nos=nos) @@ -2278,7 +2279,7 @@ class OFPMultipartReply(MsgBase): @classmethod def parser(cls, datapath, version, msg_type, msg_len, xid, buf): type_, flags = struct.unpack_from( - ofproto.OFP_MULTIPART_REPLY_PACK_STR, buffer(buf), + ofproto.OFP_MULTIPART_REPLY_PACK_STR, six.binary_type(buf), ofproto.OFP_HEADER_SIZE) stats_type_cls = cls._STATS_MSG_TYPES.get(type_) msg = super(OFPMultipartReply, stats_type_cls).parser( @@ -2455,7 +2456,7 @@ class OFPInstructionId(StringifyMixin): @classmethod def parse(cls, buf): - (type_, len_,) = struct.unpack_from(cls._PACK_STR, buffer(buf), 0) + (type_, len_,) = struct.unpack_from(cls._PACK_STR, six.binary_type(buf), 0) rest = buf[len_:] return cls(type_=type_, len_=len_), rest @@ -2505,7 +2506,7 @@ class OFPActionId(StringifyMixin): @classmethod def parse(cls, buf): - (type_, len_,) = struct.unpack_from(cls._PACK_STR, buffer(buf), 0) + (type_, len_,) = struct.unpack_from(cls._PACK_STR, six.binary_type(buf), 0) rest = buf[len_:] return cls(type_=type_, len_=len_), rest @@ -2558,7 +2559,7 @@ class OFPTableFeaturePropNextTables(OFPTableFeatureProp): rest = cls.get_rest(buf) ids = [] while rest: - (i,) = struct.unpack_from(cls._TABLE_ID_PACK_STR, buffer(rest), 0) + (i,) = struct.unpack_from(cls._TABLE_ID_PACK_STR, six.binary_type(rest), 0) rest = rest[struct.calcsize(cls._TABLE_ID_PACK_STR):] ids.append(i) return cls(table_ids=ids) @@ -2609,7 +2610,7 @@ class OFPOxmId(StringifyMixin): @classmethod def parse(cls, buf): - (oxm,) = struct.unpack_from(cls._PACK_STR, buffer(buf), 0) + (oxm,) = struct.unpack_from(cls._PACK_STR, six.binary_type(buf), 0) # oxm (32 bit) == class (16) | field (7) | hasmask (1) | length (8) # in case of experimenter OXMs, another 32 bit value # (experimenter id) follows. @@ -2620,7 +2621,7 @@ class OFPOxmId(StringifyMixin): class_ = oxm >> (7 + 1 + 8) if class_ == ofproto.OFPXMC_EXPERIMENTER: (exp_id,) = struct.unpack_from(cls._EXPERIMENTER_ID_PACK_STR, - buffer(rest), 0) + six.binary_type(rest), 0) rest = rest[struct.calcsize(cls._EXPERIMENTER_ID_PACK_STR):] subcls = OFPExperimenterOxmId return subcls(type_=type_, exp_id=exp_id, hasmask=hasmask, -- 1.9.1 ------------------------------------------------------------------------------ _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel