@@ -31,11 +31,9 @@ def _protect_global_exception_state(self) -> None:
3131 ``StructError('unexpected eof', eof=True)`` does not pass ``quiet=True``,
3232 for one -- and a loud error outside development mode installs
3333 :mod:`pcapkit.utilities.exceptions`'s own exception hook on first use
34- (GitHub issue #719). This file had no ``tearDown`` before that issue and
35- never needed one: the equivalent side effect at the time,
36- ``sys.tracebacklimit = 0``, was already left unrestored, corrupting
37- every test that ran afterwards in the same process -- the #981 shape,
38- just not previously visible as a failure here. Addressed the way
34+ (GitHub issue #719). Left unrestored, that process-global corrupts every
35+ test that runs afterwards in the same process -- the #981 shape, whether
36+ or not it shows as a failure here. It is restored the way
3937 ``isolate_modules`` addresses its own restore: via ``addCleanup``, so it
4038 still runs if the rest of ``setUp`` raises partway through.
4139
@@ -131,9 +129,9 @@ def _demo_schema_for_call_shapes(self):
131129
132130 Shared by the five call-shape tests below, one per row of `#444
133131 <https://github.com/JarryShaw/PyPCAPKit/issues/444>`__'s reproduction
134- table: ``prepare`` used to subscript ``args[2]``/``args[3]``
135- unconditionally, so only the three-positional shape worked and every
136- shorter or keyword call raised ``IndexError`` instead of falling back
132+ table: without the fix, ``prepare`` subscripts ``args[2]``/``args[3]``
133+ unconditionally, so only the three-positional shape works and every
134+ shorter or keyword call raises ``IndexError`` instead of falling back
137135 to the documented ``length=None, packet=None`` defaults.
138136
139137 """
@@ -187,20 +185,20 @@ def test_prepare_accepts_keyword_length_and_packet(self) -> None:
187185 self ._assert_call_shape_result (DemoSchema .unpack (b'payload' , length = 7 , packet = {}))
188186
189187 def test_prepare_raises_typeerror_for_extra_positional_and_keyword_arguments (self ) -> None :
190- """Extras used to vanish silently instead of being forwarded ; see #454.
188+ """Extras raise :exc:`TypeError` rather than vanishing silently ; see #454.
191189
192- ``prepare``'s own docstring promised the decorated function receives
193- ``*args, **kwargs``, but the wrapper never populated either --
194- reproduced from the issue::
190+ Without the fix, ``prepare``'s own docstring promises the decorated
191+ function receives ``*args, **kwargs``, but the wrapper populates neither
192+ -- reproduced from the issue::
195193
196194 Probe.unpack(b'\\ x07\\ x08', 2, {}, 'EXTRA_POSITIONAL', extra_kw='EXTRA_KW')
197195 -> a=7 b=8 # both extras silently gone, no error
198196
199- The chosen fix removes the promise (nothing in the tree ever passed
200- extras, and ``@prepare`` decorates exactly one function, whose real
201- signature never had room for them) and rejects extras instead of
202- forwarding them, so a misspelled or unsupported argument is a
203- ``TypeError`` rather than a parse that silently ignored it.
197+ ``prepare`` makes no such promise (nothing in the tree passes extras, and
198+ the real signature of the function ``@prepare`` decorates has no room for
199+ them) and rejects extras instead of forwarding them, so a misspelled or
200+ unsupported argument is a ``TypeError`` rather than a parse that silently
201+ ignores it.
204202
205203 """
206204 DemoSchema = self ._demo_schema_for_call_shapes ()
@@ -211,11 +209,11 @@ def test_prepare_raises_typeerror_for_extra_positional_and_keyword_arguments(sel
211209 def test_prepare_raises_typeerror_for_length_given_both_positionally_and_by_keyword (self ) -> None :
212210 """The narrower case #454 calls out.
213211
214- Passing ``length`` both positionally and by keyword used to silently
215- keep the positional value and drop the keyword one -- the keyword
216- never reached ``kwargs.pop``, since that branch only runs when the
217- positional slot was *not* supplied. It is now a caller error like any
218- other unconsumed argument .
212+ Passing ``length`` both positionally and by keyword is a caller error
213+ like any other unconsumed argument. Without the fix, the positional
214+ value is silently kept and the keyword one dropped -- the keyword never
215+ reaches ``kwargs.pop``, since that branch only runs when the positional
216+ slot is *not* supplied .
219217
220218 """
221219 DemoSchema = self ._demo_schema_for_call_shapes ()
@@ -241,13 +239,13 @@ def unpack(cls, data, length=None, packet=None):
241239 DemoSchema .unpack (b'' , None , None )
242240
243241 def test_prepare_raises_stream_eof_error_not_a_bare_eof_error (self ) -> None :
244- """The genuinely-exhausted case now raises an in-library exception.
242+ """The genuinely-exhausted case raises an in-library exception.
245243
246- A caller could not previously tell a truncated capture apart from any
247- other ``EOFError``. ``StreamEOFError`` still *is* an ``EOFError`` --
248- so ``pcapkit.foundation.extraction.Extractor``'s existing ``except
249- (EOFError, StopIteration)`` keeps working unchanged -- but it can now
250- be caught specifically via
244+ That lets a caller tell a truncated capture apart from any other
245+ ``EOFError``. ``StreamEOFError`` *is* an ``EOFError`` -- so
246+ ``pcapkit.foundation.extraction.Extractor``'s ``except
247+ (EOFError, StopIteration)`` catches it -- but it can also be caught
248+ specifically via
251249 :class:`pcapkit.utilities.exceptions.StreamEOFError`.
252250
253251 """
@@ -299,7 +297,7 @@ def test_prepare_accepts_a_declared_zero_length_schema(self) -> None:
299297 class Empty(Schema):
300298 pass
301299 Empty.unpack(b'', 0, {})
302- -> EOFError: EOFError() # before the fix
300+ -> EOFError: EOFError() # without the fix
303301
304302 Distinguishing this from the truncated-stream case above is what
305303 ``length is not None`` (a *declared* length, even zero) checks for.
@@ -333,12 +331,12 @@ def test_prepare_leaves_the_schema_clean_after_post_process(self) -> None:
333331
334332 ``Schema.unpack`` clears ``__updated__`` before returning, but
335333 ``post_process`` runs after it and every field it assigns sets the flag
336- again. The schema was therefore left dirty, and the next
337- ``bytes(schema)`` re-packed it -- which calls ``post_process`` a second
334+ again. Without the fix the schema is therefore left dirty, and the next
335+ ``bytes(schema)`` re-packs it -- which calls ``post_process`` a second
338336 time with a packet context rebuilt from the schema's own fields, so any
339- value ``post_process`` had derived from the *enclosing* layer's context
340- was overwritten with the fallback. ``Schema.pack`` clears the flag after
341- ``post_process``, and this asserts the unpacking path now matches it.
337+ value ``post_process`` derived from the *enclosing* layer's context is
338+ overwritten with the fallback. ``Schema.pack`` clears the flag after
339+ ``post_process``, and this asserts the unpacking path matches it.
342340
343341 """
344342 class DemoSchema :
@@ -496,8 +494,8 @@ def test_beholder_uses_the_protocol_payload_accessor_not_the_schema(self) -> Non
496494 so neither header schema has a ``payload`` field: reaching for the schema
497495 raises ``ProtocolUnbound('unknown field: payload')`` *from the recovery
498496 path*, turning a next-layer failure that should have degraded to
499- :class:`Raw` into a crash. It was unreachable until something was
500- registered on an SCTP payload protocol identifier, which NGAP now is.
497+ :class:`Raw` into a crash. It is reachable once something is registered
498+ on an SCTP payload protocol identifier, as NGAP is.
501499
502500 """
503501 exceptions = self .exceptions
0 commit comments