File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,19 @@ def bytes_to_string(buf):
60
60
return '/' .join (st )
61
61
62
62
63
+ int_to_hex = None
64
+ encode_big_endian_16 = None
65
+
66
+
63
67
def address_string_to_bytes (proto , addr_string ):
64
- from .util import int_to_hex
65
- from .util import encode_big_endian_16
68
+ global int_to_hex
69
+ if int_to_hex is None :
70
+ from .util import int_to_hex
71
+
72
+ global encode_big_endian_16
73
+ if encode_big_endian_16 is None :
74
+ from .util import encode_big_endian_16
75
+
66
76
if proto .code == P_IP4 : # ipv4
67
77
try :
68
78
ip = IPAddress (addr_string )
@@ -143,8 +153,13 @@ def address_string_to_bytes(proto, addr_string):
143
153
raise ValueError ("failed to parse %s addr: unknown" % proto .name )
144
154
145
155
156
+ decode_big_endian_16 = None
157
+
158
+
146
159
def address_bytes_to_string (proto , buf ):
147
- from .util import decode_big_endian_16
160
+ global decode_big_endian_16
161
+ if decode_big_endian_16 is None :
162
+ from .util import decode_big_endian_16
148
163
if proto .code == P_IP4 :
149
164
return str (IPAddress (int (buf , 16 ), 4 ).ipv4 ())
150
165
elif proto .code == P_IP6 :
You can’t perform that action at this time.
0 commit comments