Repository navigation
fix(schema): finalise each non-final Schema subclass on its own state (#1498) - #1499
Merged
Merged
Conversation
…#1498) Schema.__new__ read __finalised__ through inheritance, so once a non-final parent had been built its non-final children read the parent's BASE and were never finalised: they kept the __excluded__ copied at declaration and to_dict() leaked __map__, __map_reverse__, __buffer__ and __updated__. Read the class's own __dict__ instead, as #1496 does for Info. This also closes the documented gap where a bare @Final under a BASE ancestor escaped the guard, so its Warning becomes a Note. The shipped instances are the Quick-Start option schemas of HOPOPT, IPv6-Opts and IPv4.
Owner
Author
|
Verdict: GOOD TO GO at
Non-blocking: the NOTE in |
Contributor
|
Coverage: 89.65% (unit tier, Python 3.14,
Per-file detail: the |
2 of 13 tasks
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
Schema.__new__read the inherited__finalised__, so once a non-final parent had been built its non-final children were never finalised andto_dict()leaked__map__,__map_reverse__,__buffer__and__updated__. The check now readscls.__dict__.get('__finalised__', FinalisedState.NONE), mirroring #1496 forInfo. The docstringWarningdescribing the@final-under-BASEescape becomes aNote, since that gap closes too.Shipped instances: the Quick-Start option schemas of HOPOPT, IPv6-Opts and IPv4 (non-final children of non-final
Option).tests/protocols/schema/test_schema_child_finalisation_1498_unit.pyruns both construction orders in fresh interpreters, for a synthetic pair and the three shipped ones. It also covers a child declared after its parent'sBASE, and a bare@finalunder aBASEparent. Onorigin/main'sschema.py: 6 failed (4 parent-first subtests and the 2 direct tests). The child-first subtests pass there, as expected.Run here with an FSIZE cap: the new test,
tests/test_final_enforcement.py,tests/corekit/test_schema_roundtrip_unit.py,tests/protocols/internet,tests/protocols/transport,tests/protocols/test_capture_roundtrip_runtime.py,tests/projectandtests/test_docstring_contract.py. All pass. Per-file hashes ofrepr(frame.info.to_dict())over the 23examples/capturesfiles are identical on both trees.Closes #1498