From ed5b3edd27243d52b69693768e0865ff694ef836 Mon Sep 17 00:00:00 2001 From: IWAMOTO Toshihiro Date: Fri, 3 Jul 2015 11:27:08 +0900 Subject: [PATCH] python3: Partially revert b'str' conversion This patch partially reverts 75e8c58916524243e6796e73c371981e14fff6ee and 536a42d8c1c0be48e78d5f29b6fd55a38012d953. dhcp.sname is ascii. Signed-off-by: IWAMOTO Toshihiro Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/dhcp.py | 2 +- ryu/tests/unit/packet/test_dhcp.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ryu/lib/packet/dhcp.py b/ryu/lib/packet/dhcp.py index bfc1f78c..eed7a113 100644 --- a/ryu/lib/packet/dhcp.py +++ b/ryu/lib/packet/dhcp.py @@ -149,7 +149,7 @@ class dhcp(packet_base.PacketBase): def __init__(self, op, chaddr, options, htype=_HARDWARE_TYPE_ETHERNET, hlen=0, hops=0, xid=None, secs=0, flags=0, ciaddr='0.0.0.0', yiaddr='0.0.0.0', siaddr='0.0.0.0', - giaddr='0.0.0.0', sname=b'', boot_file=b''): + giaddr='0.0.0.0', sname='', boot_file=b''): super(dhcp, self).__init__() self.op = op self.htype = htype diff --git a/ryu/tests/unit/packet/test_dhcp.py b/ryu/tests/unit/packet/test_dhcp.py index 92116ee8..1c24ef1a 100644 --- a/ryu/tests/unit/packet/test_dhcp.py +++ b/ryu/tests/unit/packet/test_dhcp.py @@ -41,7 +41,7 @@ class Test_dhcp_offer(unittest.TestCase): yiaddr = '192.168.20.20' siaddr = '192.168.30.30' giaddr = '192.168.40.40' - sname = b'abc' + sname = 'abc' boot_file = b'' option_list = [ @@ -124,7 +124,7 @@ class Test_dhcp_offer(unittest.TestCase): eq_(self.giaddr, res.giaddr) eq_(self.chaddr, res.chaddr) # sname is 64 byte length. rest of data is filled by '\x00'. - eq_(self.sname.ljust(64, b'\x00'), res.sname) + eq_(self.sname.ljust(64, '\x00'), res.sname) # boof_file is 128 byte length. rest of data is filled by '\x00'. eq_(self.boot_file.ljust(128, b'\x00'), res.boot_file) eq_(str(self.options), str(res.options)) @@ -153,7 +153,7 @@ class Test_dhcp_offer(unittest.TestCase): eq_(self.giaddr, addrconv.ipv4.bin_to_text(res[10])) eq_(self.chaddr, addrconv.mac.bin_to_text(res[11][:6])) # sname is 64 byte length. rest of data is filled by '\x00'. - eq_(self.sname.ljust(64, b'\x00'), res[12]) + eq_(self.sname.ljust(64, '\x00'), res[12].decode('ascii')) # boof_file is 128 byte length. rest of data is filled by '\x00'. eq_(self.boot_file.ljust(128, b'\x00'), res[13]) options = dhcp.options.parser(