Extractor's three registrar methods check against the *Base classes but name the public class in their error message, so a caller who trips the guard is told the wrong type is required.
In pcapkit/foundation/extraction.py:
| check |
message |
:452 issubclass(engine, EngineBase) |
:453 "engine must be an Engine subclass" |
:491 issubclass(reassembly, ReassemblyBase) |
:492 "reassembly must be a Reassembly subclass" |
:530 issubclass(traceflow, TraceFlowBase) |
:531 "traceflow must be a TraceFlow subclass" |
The accepted type is wider than the message says: Engine, Reassembly and TraceFlow are each a strict subclass of their base, and the shipped classes derive from the base directly. So a class that subclasses EngineBase is accepted while the message implies it should not be, and a reader who hits the error is sent to fix something that was never wrong.
Two related narrowings in the same area:
register_extractor_engine and its siblings are annotated Type[Engine], narrower than the runtime check, so a legitimate EngineBase subclass is a type error at a call site that works at runtime.
register_protocol checks issubclass(protocol, ProtocolBase); its message and annotation should be checked for the same mismatch.
Found while sweeping docstrings for #719. The prose side is corrected in #1015, which deliberately left these alone because the messages and annotations are code, not documentation. #513 and #514 are the same conflation approached from the caller's side.
The fix is a judgement call rather than mechanical: either widen the messages and annotations to the *Base classes, matching the guard, or narrow the guards to the public classes, which would be a behaviour change and needs a ruling.
Extractor's three registrar methods check against the*Baseclasses but name the public class in their error message, so a caller who trips the guard is told the wrong type is required.In
pcapkit/foundation/extraction.py::452issubclass(engine, EngineBase):453"engine must be an Engine subclass":491issubclass(reassembly, ReassemblyBase):492"reassembly must be a Reassembly subclass":530issubclass(traceflow, TraceFlowBase):531"traceflow must be a TraceFlow subclass"The accepted type is wider than the message says:
Engine,ReassemblyandTraceFloware each a strict subclass of their base, and the shipped classes derive from the base directly. So a class that subclassesEngineBaseis accepted while the message implies it should not be, and a reader who hits the error is sent to fix something that was never wrong.Two related narrowings in the same area:
register_extractor_engineand its siblings are annotatedType[Engine], narrower than the runtime check, so a legitimateEngineBasesubclass is a type error at a call site that works at runtime.register_protocolchecksissubclass(protocol, ProtocolBase); its message and annotation should be checked for the same mismatch.Found while sweeping docstrings for #719. The prose side is corrected in #1015, which deliberately left these alone because the messages and annotations are code, not documentation. #513 and #514 are the same conflation approached from the caller's side.
The fix is a judgement call rather than mechanical: either widen the messages and annotations to the
*Baseclasses, matching the guard, or narrow the guards to the public classes, which would be a behaviour change and needs a ruling.