Fix convertion of ipv4 to string on i386 and arch

On architectures like i386 or arm convertion of IPv4 to string
was failing in some cases.
It was like that because some integer values were converted to
long which is not the case on x86_64.
It was like that for example with value "2871386400" which is
used in ryu.tests.unit.ofproto.test_parser_v10:TestOFPMatch unit
test.
Because of that this test was failing when running on architectures
where integer range was too small to handle this value.

Signed-off-by: Slawek Kaplonski <skaplons@redhat.com>
Reviewed-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Slawek Kaplonski 2018-08-11 18:46:28 +02:00 committed by FUJITA Tomonori
parent 8312ab23b3
commit d7d526ad21

View File

@ -84,7 +84,7 @@ def ipv4_to_str(ip):
:param ip: binary or int type representation of IPv4 address
:return: IPv4 address string
"""
if isinstance(ip, int):
if isinstance(ip, numbers.Integral):
return addrconv.ipv4.bin_to_text(struct.pack("!I", ip))
else:
return addrconv.ipv4.bin_to_text(ip)