fix: the equality checks for DNSPointer and DNSService should be case… · python-zeroconf/python-zeroconf@48ae77f

@@ -314,14 +314,15 @@ class DNSPointer(DNSRecord):

314314315315

"""A DNS pointer record"""

316316317-

__slots__ = ('_hash', 'alias')

317+

__slots__ = ('_hash', 'alias', 'alias_key')

318318319319

def __init__(

320320

self, name: str, type_: int, class_: int, ttl: int, alias: str, created: Optional[float] = None

321321

) -> None:

322322

super().__init__(name, type_, class_, ttl, created)

323323

self.alias = alias

324-

self._hash = hash((self.key, type_, self.class_, alias))

324+

self.alias_key = self.alias.lower()

325+

self._hash = hash((self.key, type_, self.class_, self.alias_key))

325326326327

@property

327328

def max_size_compressed(self) -> int:

@@ -343,7 +344,7 @@ def __eq__(self, other: Any) -> bool:

343344344345

def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

345346

"""Tests equality on alias."""

346-

return self.alias == other.alias and self._dns_entry_matches(other)

347+

return self.alias_key == other.alias_key and self._dns_entry_matches(other)

347348348349

def __hash__(self) -> int:

349350

"""Hash to compare like DNSPointer."""

@@ -415,7 +416,7 @@ def __init__(

415416

self.port = port

416417

self.server = server

417418

self.server_key = server.lower()

418-

self._hash = hash((self.key, type_, self.class_, priority, weight, port, server))

419+

self._hash = hash((self.key, type_, self.class_, priority, weight, port, self.server_key))

419420420421

def write(self, out: 'DNSOutgoing') -> None:

421422

"""Used in constructing an outgoing packet"""

@@ -434,7 +435,7 @@ def _eq(self, other) -> bool: # type: ignore[no-untyped-def]

434435

self.priority == other.priority

435436

and self.weight == other.weight

436437

and self.port == other.port

437-

and self.server == other.server

438+

and self.server_key == other.server_key

438439

and self._dns_entry_matches(other)

439440

)

440441