Repository navigation
fix(protocols): restoring a registration puts back the shipped ModuleDescriptor (#1504) - #1533
Merged
Merged
Conversation
…Descriptor (#1504) - ProtocolBase: snapshot each class's own __proto__ at class creation as _shipped_proto, and add _next_layer_entry, which decides what a register stores: None for the stored entry (#1364), the shipped descriptor object itself, unresolved, for a descriptor equal to the one the code shipped with, else the resolved and checked class. - ProtocolBase, Link, Internet, Transport, SCTP and Frame register use it and keep their own warning, so undoing an override leaves the entry a descriptor and imports nothing. - PCAPNG.register (misc/pcapng.py) is not changed here; the Gap(1504) row narrows to register_linktype and register_pcapng. - New per-site tests for the round trip, the restore importing nothing, and dispatch resolving the restored entry when it runs. Part of #1504
Owner
Author
|
Verdict: GOOD TO GO at
Non-blocking:
|
Contributor
|
Coverage: 90.08% (unit tier, Python 3.14,
Per-file detail: the |
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.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeAdded a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription of your pull request and other information
Every next-layer
registerresolved aModuleDescriptorto its class before storing it. The #1364 guard only compares with the incumbent, so after an override, handing back the shipped descriptor stored the class.ProtocolBase.__init_subclass__snapshots a class's own__proto__as_shipped_proto. The new_next_layer_entryreturns the shipped object, unresolved, for a descriptor equal to the one that code shipped with. Any other descriptor still resolves to its class, as fix(registry): re-registering a stored ModuleDescriptor warns and replaces it with the class #1364's pins expect.ProtocolBase,Link,Internet,Transport(TCP/UDP),SCTPandFrame.registeruse it. Each keeps its ownwarn, because tests patch the module-level name.PCAPNG.register(misc/pcapng.py:1021-1035), which this change leaves alone.Gap(1504)narrows toregister_linktype/register_pcapng, so this is notCloses.tests/protocols/test_register_restores_shipped_descriptor_1504_unit.py, covering 7 site families. It checks the round trip, that the restore imports nothing (a blocked import), and that dispatch resolves the entry when it runs. Onmain, 28 of 42 subtests fail; here all pass.Ran (sequentially), all green:
tests/foundation/registry, the dispatch and registry modules intests/protocols,tests/protocols/{link,internet,transport,misc,application},tests/project,tests/test_docstring_contract.pyandtests/test_tier_guard.py.Part of #1504