Skip to content

Commit f78a196

Browse files
authored
fix: ensure IPv6 scoped address construction uses the string cache (#1336)
1 parent 6c2d6e6 commit f78a196

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/zeroconf/_utils/ipaddress.py

Lines changed: 2 additions & 1 deletion
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

0 commit comments

Comments
 (0)