fix: ensure IPv6 scoped address construction uses the string cache (#… · python-zeroconf/python-zeroconf@f78a196

Original file line numberDiff line numberDiff line change

@@ -113,7 +113,8 @@ def ip_bytes_and_scope_to_address(address: bytes_, scope: int_) -> Optional[Unio

113113

"""Convert the bytes and scope to an IP address object."""

114114

base_address = cached_ip_addresses_wrapper(address)

115115

if base_address is not None and base_address.is_link_local:

116-

return cached_ip_addresses_wrapper(f"{base_address}%{scope}")

116+

# Avoid expensive __format__ call by using PyUnicode_Join

117+

return cached_ip_addresses_wrapper("".join((str(base_address), "%", str(scope))))

117118

return base_address

118119
119120