Repository navigation
fix(registry): foundation registrars restore the built-in a name shipped with (#1363) - #1376
Merged
Merged
Conversation
…ped with (#1363) - Extractor.register_engine/_reassembly/_traceflow accept the built-in a name shipped with, as its descriptor or as the class it names, and restore the shipped entry; every other built-in is still refused (#1016). - Extractor.register_dumper and TraceFlow.register_dumper restore the shipped (descriptor, ext) pair instead of replacing it with the class, the dumper half of #1364. - Re-registering the shipped original over itself is a silent no-op. - The shipped entry is matched via sys.modules, never by importing it. New tests/foundation/registry/test_restore_builtin_unit.py: 8 tests, 7 fail on origin/main.
Owner
Author
|
Cross-review verdict on
Edge cases, not blocking:
|
Contributor
|
Coverage: 88.98% (unit tier, Python 3.14,
Per-file detail: the |
This was referenced Oct 8, 2026
JarryShaw
added a commit
that referenced
this pull request
Oct 8, 2026
- ProtocolBase.register and the Internet, Link, Transport, SCTP, Frame and PCAPNG overrides resolved a ModuleDescriptor argument to its class before comparing it with the stored entry, so handing back the stored descriptor warned and replaced the deferred entry with the class. They now compare first: the stored entry, or a descriptor equal to it, is a silent no-op that keeps the stored object. A different entry still warns, and invalid input still raises RegistryError. - Extractor.register_dumper already keeps its shipped descriptors since #1376; it is pinned in the new test. New tests/protocols/test_registry_stored_descriptor_unit.py: 6 tests; 8 fail on origin/main (7 subtests and the ProtocolBase case).
JarryShaw
added a commit
that referenced
this pull request
Oct 8, 2026
…) (#1415) - ProtocolBase.register and the Internet, Link, Transport, SCTP, Frame and PCAPNG overrides resolved a ModuleDescriptor argument to its class before comparing it with the stored entry, so handing back the stored descriptor warned and replaced the deferred entry with the class. They now compare first: the stored entry, or a descriptor equal to it, is a silent no-op that keeps the stored object. A different entry still warns, and invalid input still raises RegistryError. - Extractor.register_dumper already keeps its shipped descriptors since #1376; it is pinned in the new test. New tests/protocols/test_registry_stored_descriptor_unit.py: 6 tests; 8 fail on origin/main (7 subtests and the ProtocolBase case).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isort -l100 -ppcapkit(clean), andpylint/mypyon the three files: no new messages againstorigin/main.maketargets not run.make testpasses, and a test case covers the change — the modules listed below only, not the whole suiteWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Refs #1363 (option 1; the protocol and option registrars follow under #1362). Refs #1364 (dumper half only).
The engine, reassembly and traceflow registrars accept the built-in a name shipped with, as a descriptor or as the class it names, and restore the shipped entry. Both dumper registrars do the same for the shipped
(descriptor, ext)pair. Every other built-in is still refused (#1016). The registries are snapshotted at class definition. The shipped entry is matched throughsys.modules, so an optional engine is never imported to recognise it. Re-registering the original over itself is a silent no-op. Restoring over an override warns, as any overwrite does.Probe (
check_10): onorigin/main,register_extractor_engine('dpkt', MyEngine)then('dpkt', DPKT)raisesRegistryError: engine must be an Engine subclass. With the fix the restore succeeds andExtractor.__engine__is identical to the snapshot (isfor each entry). The same holds for reassemblyipv4/ipv6/tcp, traceflowtcpand dumperjson.Tests: the new
tests/foundation/registry/test_restore_builtin_unit.pypasses 8 tests. Withgit show origin/main:<src>written over the sources, 7 fail (5 failed, plus subtest failures foripv4/ipv6/tcp/json). Only the guard testtest_other_builtins_still_refusedpasses both ways.util/run_unittest_leg.py foundation(underulimit -f): 491 tests with the fix, 483 onorigin/main, and the same 2 failures + 2 errors on both. They are fix(dumpkit): JSON output of DPKT/Scapy frames grows without bound and fills the disk #1372'stest_pcap_output_opens_with_the_global_header(DPKT, Scapy) andtest_pcap_run_writes_global_header_for_file_and_stream_modes, which fail before this change.pytest tests/project: 389 passed, 1 skipped. Also passing:test_foundation.py,test_foundation_keyword_names.py,test_docstring_contract.py,test_extraction.py, the traceflow/engine/reassembly base tests,test_common_unit.pyandtest_base_class_contract.py.