MCPcopy Index your code
hub / github.com/RustPython/RustPython / v4_int_to_packed

Function v4_int_to_packed

Lib/ipaddress.py:120–137  ·  view source on GitHub ↗

Represent an address as 4 packed bytes in network (big-endian) order. Args: address: An integer representation of an IPv4 IP address. Returns: The integer address packed as 4 bytes in network (big-endian) order. Raises: ValueError: If the integer is negative or

(address)

Source from the content-addressed store, hash-verified

118
119
120def v4_int_to_packed(address):
121 """Represent an address as 4 packed bytes in network (big-endian) order.
122
123 Args:
124 address: An integer representation of an IPv4 IP address.
125
126 Returns:
127 The integer address packed as 4 bytes in network (big-endian) order.
128
129 Raises:
130 ValueError: If the integer is negative or too large to be an
131 IPv4 IP address.
132
133 """
134 try:
135 return address.to_bytes(4) # big endian
136 except OverflowError:
137 raise ValueError("Address negative or too large for IPv4")
138
139
140def v6_int_to_packed(address):

Callers 1

packedMethod · 0.85

Calls 1

to_bytesMethod · 0.80

Tested by

no test coverage detected