VTL: Fix issue with ipaddress library use under python2.
[vpp.git] / test / hook.py
index a8f37c7..64fc076 100644 (file)
@@ -6,6 +6,10 @@ from log import RED, single_line_delim, double_line_delim
 import ipaddress
 from subprocess import check_output, CalledProcessError
 from util import check_core_path, get_core_path
+try:
+    text_type = unicode
+except NameError:
+    text_type = str
 
 
 class Hook(object):
@@ -32,6 +36,7 @@ class Hook(object):
                 return '{!s} ({!s})'.format(val, ':'.join(['{:02x}'.format(
                     ord(x)) for x in val]))
             try:
+                # we don't call test_type(val) because it is a packed value.
                 return '{!s} ({!s})'.format(val, str(
                     ipaddress.ip_address(val)))
             except ipaddress.AddressValueError: