Repository navigation
docs(const): state what _missing_ actually does instead of claiming it mints - #1018
Conversation
…t mints `docs/source/pcapkit/const/index.rst` told the reader that an unregistered value inside a registry's valid range is minted into a permanent member via ``aenum.extend_enum``, and that a minted member's identity is stable for the life of the process. Measured, there are **four** behaviours across the 127 `EnumRegistry` subclasses, not one: - **1 installs a permanent member** -- `CGAType`, so `__members__` and iteration grow. - **5 cache a composed object in the value table only** -- `tcp.flags.Flags` and the four Mobility Header flag registries. They are `aenum.IntFlag` subclasses, so `super()._missing_` reaches `aenum.Flag._create_pseudo_member_`, which ends in `cls._value2member_map_.setdefault(value, pseudo_member)`. A second lookup therefore returns the **same** object, while `__members__` and iteration do not change. - **117 return an uninstalled object** -- nothing grows, and a second lookup gives an equal but distinct object. This is the common case the page now describes. - **4 raise for any unknown value** -- `Transport`, `ExtensionHeader`, `TLSKeyLabel`, and the memberless `AppType` base. So the old identity claim was true of six registries rather than one, and false of the other 121. The page now leads with the warning that a lookup does not raise, states the common case, and lists the exceptions, deferring the full split to `mint-criterion` by `:ref:`. "The mechanism is uniform because it is generated" is corrected: only the common form of the override is generated. Closes #1013. `tests/project`: 268 passed, 1 skipped, 864 subtests passed.
a992025 to
f134b2d
Compare
|
NEEDS CHANGES at My replacement prose was false for five registries. It said the resolved object is not installed and that a second lookup returns an equal but distinct object. Measured: The mechanism, established rather than guessed. They are A correction I owe the reviewer. I pushed back on its The full partition is four behaviours over 127 registries, and it also corrects the issue's own framing: 1 installs a permanent member ( The page now leads with the warning that a lookup does not raise, states the common case, lists the three exceptions, and defers the full split to This means |
|
GOOD TO GO at 1 installs / 5 cache / 117 uninstalled / 4 raise = 127. The 117 arrives as 114 − 1 + 4, and the −1 is the part worth recording: It withdrew its own earlier bucketing — its first pass had measured One precision note it raised and I agree is not a defect. Thirteen further registries never reach All five rewrite checks confirmed, and the warning test came out better than before rather than merely no worse — the opening paragraph is now 6 lines where it was 10, with the mechanism moved into a scannable list, and "nearly every" is well-earned at 123/127. The Residual, non-blocking: nothing automated gates this page — |
|
Correcting my own number above, and the verdict is unchanged — still GOOD TO GO at I wrote "thirteen further registries" never reach The cause is worth recording, because it will catch the next person probing these registries. That is the third probe artifact in this one area, and they share a shape: assuming the value space is small, contiguous and integer-keyed. The earlier two were None of this touches the partition. 1 / 5 / 117 / 4 = 127 rests on source inspection — 114 registries owning a One item stays UNVERIFIED and changes nothing downstream: of the twelve, the range guard was read directly on five; the other seven were inferred from member counts matching fully-assigned 1-, 2- and 3-bit fields. |
make pylint,make mypy,make isort) — N/A, no code changedmake testpasses, and a test case covers the change — I rantests/projectonly (268 passed, 1 skipped, 864 subtests), not the full suitedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, prose onlyWhat is the purpose of your pull request?
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingchore— anything elseDescription of your pull request and other information
Closes #1013. One file, +13/−10.
The
pcapkit.constlanding page is the first thing a reader of those registries meets, and it described the behaviour backwards. It said an unregistered value inside a registry's valid range is minted into a permanent member viaaenum.extend_enum, and that a minted member's identity is stable for the life of the process. Both are true of exactly one registry out of 121.Measured at runtime, in a worktree with
pcapkit.__file__asserted:EnumRegistrysubclasses underpcapkit.const_missing_extend_enum)CGAType_unregistered_member, no install)super()._missing_The identity claim is the inverse of the truth for those 114. Two lookups of the same unassigned value:
EtherType(0x0)twice — compare equal, are not the same object, member count unchanged at 160, and the value is absent from both__members__and iteration.CGAType(5)twice — same object, and__members__grows 7 → 8.So "stable for the life of the process" described
CGATypeand nothing else, while the reader was told it applied to all of them. Out-of-range and wrong-type values (-1,0x10000,'x',None,1.5) all raiseValueError, which the page had right.What changed. The opening passage now says the object is not installed, that a second lookup returns an equal but distinct object, and names
CGATypeas the single exception with a:ref:tomint-criterionfor the split. The closed-set sentence now states the consequence that actually bites — compare such members by value, not identity. And "for every registry" is dropped from the claim about the generated_missing_override, because six registries have none.mint-criterion.rstis not touched: it was already correct, and it belongs to another slice. This page now agrees with it rather than contradicting it.The page carries no issue or PR citations, before or after. No Sphinx build was run, so the new
:ref:and:class:targets are checked by reading the label and by import, not by Sphinx's own resolver.