Skip to content

Commit

Permalink
fix: ensure IPv6 scoped address construction uses the string cache (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Dec 14, 2023
1 parent 6c2d6e6 commit f78a196
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/zeroconf/_utils/ipaddress.py
Expand Up @@ -113,7 +113,8 @@ def ip_bytes_and_scope_to_address(address: bytes_, scope: int_) -> Optional[Unio
"""Convert the bytes and scope to an IP address object."""
base_address = cached_ip_addresses_wrapper(address)
if base_address is not None and base_address.is_link_local:
return cached_ip_addresses_wrapper(f"{base_address}%{scope}")
# Avoid expensive __format__ call by using PyUnicode_Join
return cached_ip_addresses_wrapper("".join((str(base_address), "%", str(scope))))
return base_address


Expand Down

0 comments on commit f78a196

Please sign in to comment.