Instantiate a new IPv6 address object. Args: address: A string or integer representing the IP Additionally, an integer can be passed, so IPv6Address('2001:db8::') == IPv6Address(42540766411282592856903984951653826560) or
(self, address)
| 1914 | __slots__ = ('_ip', '_scope_id', '__weakref__') |
| 1915 | |
| 1916 | def __init__(self, address): |
| 1917 | """Instantiate a new IPv6 address object. |
| 1918 | |
| 1919 | Args: |
| 1920 | address: A string or integer representing the IP |
| 1921 | |
| 1922 | Additionally, an integer can be passed, so |
| 1923 | IPv6Address('2001:db8::') == |
| 1924 | IPv6Address(42540766411282592856903984951653826560) |
| 1925 | or, more generally |
| 1926 | IPv6Address(int(IPv6Address('2001:db8::'))) == |
| 1927 | IPv6Address('2001:db8::') |
| 1928 | |
| 1929 | Raises: |
| 1930 | AddressValueError: If address isn't a valid IPv6 address. |
| 1931 | |
| 1932 | """ |
| 1933 | # Efficient constructor from integer. |
| 1934 | if isinstance(address, int): |
| 1935 | self._check_int_address(address) |
| 1936 | self._ip = address |
| 1937 | self._scope_id = None |
| 1938 | return |
| 1939 | |
| 1940 | # Constructing from a packed address |
| 1941 | if isinstance(address, bytes): |
| 1942 | self._check_packed_address(address, 16) |
| 1943 | self._ip = int.from_bytes(address, 'big') |
| 1944 | self._scope_id = None |
| 1945 | return |
| 1946 | |
| 1947 | # Assume input argument to be string or any object representation |
| 1948 | # which converts into a formatted IP string. |
| 1949 | addr_str = str(address) |
| 1950 | if '/' in addr_str: |
| 1951 | raise AddressValueError(f"Unexpected '/' in {address!r}") |
| 1952 | addr_str, self._scope_id = self._split_scope_id(addr_str) |
| 1953 | |
| 1954 | self._ip = self._ip_int_from_string(addr_str) |
| 1955 | |
| 1956 | def _explode_shorthand_ip_string(self): |
| 1957 | ipv4_mapped = self.ipv4_mapped |
nothing calls this directly
no test coverage detected