MCPcopy Create free account
hub / github.com/rthalley/dnspython / restrict_to

Method restrict_to

dns/wire.py:77–91  ·  view source on GitHub ↗
(self, size: int)

Source from the content-addressed store, hash-verified

75
76 @contextlib.contextmanager
77 def restrict_to(self, size: int) -> Iterator:
78 assert size >= 0
79 if size > self.remaining():
80 raise dns.exception.FormError
81 saved_end = self.end
82 try:
83 self.end = self.current + size
84 yield
85 # We make this check here and not in the finally as we
86 # don't want to raise if we're already raising for some
87 # other reason.
88 if self.current != self.end:
89 raise dns.exception.FormError
90 finally:
91 self.end = saved_end
92
93 @contextlib.contextmanager
94 def restore_furthest(self) -> Iterator:

Callers 8

from_wireFunction · 0.95
option_from_wireFunction · 0.95
test_basicMethod · 0.95
_get_sectionMethod · 0.80
from_wire_parserMethod · 0.80
from_wire_parserMethod · 0.80

Calls 1

remainingMethod · 0.95