FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

chore: fresh docstrings, restore exception import, compute rdata leng… · python-zeroconf/python-zeroconf@153d6ee · GitHub

Repository navigation

Commit 153d6ee

Browse files
committed
chore: fresh docstrings, restore exception import, compute rdata length from size counter
1 parent 5a91843 commit 153d6ee

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎src/zeroconf/_dns.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import socket
2727
from typing import TYPE_CHECKING, Any, cast
2828

29+
from ._exceptions import AbstractMethodException
2930
from ._utils.net import _is_v6_address
3031
from ._utils.time import current_time_millis
3132
from .const import _CLASS_MASK, _CLASS_UNIQUE, _CLASSES, _TYPE_ANY, _TYPES
@@ -156,7 +157,7 @@ def __repr__(self) -> str:
156157
)
157158

158159

159-
class DNSRecord(DNSEntry):
160+
class DNSRecord(DNSEntry): # noqa: PLW1641
160161
"""A DNS record - like a DNS entry, but has a TTL"""
161162

162163
__slots__ = ("created", "ttl")

‎src/zeroconf/_protocol/incoming.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def _read_string(self, length: _int) -> bytes:
311311
return info
312312

313313
def _read_others(self) -> None:
314+
"""Read the answer, authority and additional sections."""
314315
self._did_read_others = True
315316
buf = self._buf
316317
answers = self._answers

‎src/zeroconf/_protocol/outgoing.pxd‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@ cdef class DNSOutgoing:
6565
cdef cython.bint _write_question(self, DNSQuestion question)
6666

6767
@cython.locals(
68-
chunk=cython.bytes,
6968
data_length_before=cython.uint,
7069
size_before=cython.uint,
7170
length_index=cython.uint,
72-
rdata_length=cython.uint,
71+
rdata_size_start=cython.uint,
7372
)
7473
cdef cython.bint _write_record(self, DNSRecord record, double now)
7574

‎src/zeroconf/_protocol/outgoing.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,9 @@ def _write_record(self, record: DNSRecord_, now: float_) -> bool:
335335
self._write_ttl(record, now)
336336
length_index = len(self.data)
337337
self.write_short(0) # placeholder for the rdata length
338+
rdata_size_start = self.size
338339
record.write(self)
339-
rdata_length = 0
340-
for chunk in self.data[length_index + 1 :]:
341-
rdata_length += len(chunk)
342-
self._replace_short(length_index, rdata_length)
340+
self._replace_short(length_index, self.size - rdata_size_start)
343341
return self._check_data_limit_or_rollback(data_length_before, size_before)
344342

345343
def _check_data_limit_or_rollback(self, start_data_length: int_, start_size: int_) -> bool:

‎tests/test_protocol.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def test_questions_do_not_end_up_every_packet(self):
457457

458458
class PacketForm(unittest.TestCase):
459459
def test_transaction_id(self):
460+
"""Multicast DNS messages carry transaction id 0 (RFC 6762 section 18.1)."""
460461
generated = r.DNSOutgoing(const._FLAGS_QR_QUERY)
461462
bytes = generated.packets()[0]
462463
id = bytes[0] << 8 | bytes[1]

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL