Repository navigation
refactor(protocols)!: replace the pcapkit.protocols.__proto__ dict with ProtocolBase.__registry__ (#2763) - #2770
Merged
Conversation
…th ProtocolBase.__registry__ (#2763) - ProtocolBase.__registry__ lists every built-in as a ModuleDescriptor, so the map is whole before any protocol is imported; get_protocol() resolves a name in any case, one thread at a time, as racing first imports can deadlock. - ProtocolMeta.registry is a read-only view of the entries as stored, so AnyProtocol.registry imports nothing. - A concrete Protocol subclass names itself from Protocol.__init_subclass__, after its code= is accepted; an abstract one is skipped, a clash keeps the entry and warns, and a class meeting its own descriptor is silent. - register_protocol() replaces an entry and puts a built-in's shipped descriptor back; the foundation wrapper calls it and the name leases compare through it. - Readers move to the getter; pcapkit.protocols.__proto__ goes, with no alias. - Docs and conventions record the ruling. Tests: guard, registration, getter, view, cold laziness and a thread race, mutation-proven; old readers adapted.
Owner
Author
|
GOOD TO GO at
|
JarryShaw
added a commit
that referenced
this pull request
Nov 4, 2026
- Breaking (#2770), a new entry after the package layout one: pcapkit.protocols.__proto__, a dict keyed by upper-cased name in 1.5.1, is removed with no alias; ProtocolBase.__registry__, get_protocol(), register_protocol() and the read-only registry view replace it, and a concrete Protocol subclass registers itself, measured against v1.5.1. The ruling goes into the conventions entry. - The lazy-import entry no longer describes the removed registry module, which never shipped and stays unnamed. - 1.5.0's __proto__ role points at ProtocolBase.__registry__, its text unchanged, so the nitpicky build does not warn on it. - CHANGELOG.md regenerated; util/changelog_md.py --check passes.
1 of 5 tasks
JarryShaw
added a commit
that referenced
this pull request
Nov 4, 2026
- #2770: 1.5.1's Protocol.__init_subclass__ already registered a subclass as it was defined. The entry names what changed, measured on a v1.5.1 export: an abstract subclass is skipped, where 1.5.x registered it, and a name clash keeps the existing entry and warns, where 1.5.x replaced it and warned that it was overwriting. - #2767: drops "length", since IPv6_Ext's length at cut 1 is still open on #2761. - CHANGELOG.md regenerated; util/changelog_md.py --check passes.
JarryShaw
added a commit
that referenced
this pull request
Nov 4, 2026
- #2777: the cut-header sentence reads the length back too, the rebuild read at the width its parse was given (__short_width__); the ruling into the conventions entry. - #2778: a PCAP-NG block with octets after opt_endofopt rebuilds an info holding its options and padding_opts, where 1.5.1 rebuilt none, into the whole-header rebuild entry; 1.5.0's frozen entry is left as written. - #2779: SCTP's reorder, the source-ordered member lists and the sorted Option.register clash warning ('opt', 'if', 'epb', ... in 1.5.1), into the member-order entry; the layer-grouped registry and the warning name restore ('put back silently' in 1.5.1), into the #2770 entry; the page wording into the conventions entry. - #2781: import_lock serialising first resolutions, into the lazy-import entry; the removed registry lock never shipped and stays unnamed. - CHANGELOG.md regenerated; util/changelog_md.py --check passes.
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.
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
refactor— restructures code without changing behaviourDescription of your pull request and other information
This replaces the module-level dict
pcapkit.protocols.__proto__with a registry on the protocol classes, as ruled on #2763. Breaking: the old name is gone, with no alias.ProtocolBase.__registry__is a class-level map from name to protocol. It holds all 62 built-ins asModuleDescriptorentries, so it is complete from the start and loads each protocol only when looked up.pcapkit/protocols/registry.pyis removed.ProtocolBase.register_protocolandget_protocol(name, default=None)are classmethods. The getter resolves a descriptor to its class. Thefoundation.registrywrapper now callsregister_protocoland is tagged# NOTE: __registry__.AnyProtocol.registryis a read-only view of the whole map, as stored. It is a property onProtocolMeta, so reading it imports nothing.Protocol.__init_subclass__, the public base, for concrete subclasses only. A name clash keeps the existing entry and warns. Built-ins subclassProtocolBaseand are covered by their descriptors.docs/source/pcapkit/protocols/index.rsthas aversionremoved:: 1.6.0note for the old name. Import time is unchanged.Closes #2763