Skip to content

fix(mh): decide whether the two kept get overrides should raise quietly like the base #933

Description

@JarryShaw

FastBindingAcknowledgmentStatus.get and IPv6AddressPrefixCode.get (both in pcapkit/protocols/internet/mh.py) raise EnumKeyError on a name miss without quiet=True. The base does the opposite — EnumLookup.get raises with quiet=True at pcapkit/corekit/enum.py:412.

That divergence pre-dates #932 and is untouched by it, but #932 makes it newly reachable: re-parenting those two onto EnumLookup gives them an inherited get_all, which did not exist on them before and which routes a miss through the loud override. Measured on both trees:

post-#932  has get_all=True   raised=EnumKeyError  sys.tracebacklimit '<unset>' -> 0
pre-#932   has get_all=False  raised=-             sys.tracebacklimit '<unset>' -> '<unset>'

A loud BaseError sets sys.tracebacklimit = 0 process-wide — the hazard behind #362 — so this is a public-API path that can now silently truncate every later traceback in the process. No non-test caller exists in pcapkit/ today, which is why #932 is not being held for it.

The decision I do not want to take inside a refactor: should these two overrides adopt the base's quiet=True?

  1. Yes — they are the odd ones out, and the fix(corekit,utilities): raise pcapkit exceptions from EnumLookup.get, following stdlib Enum's shape #923 ruling on failed-lookup shape reads as a house-wide contract rather than a per-class choice.
  2. No — a get_all miss is a genuine failure the caller should see loudly, and quiet=True on the base exists specifically because a name miss there is part of a successful call at Method.get. These overrides have no such caller, so the reasoning does not transfer.

Option 2 has the better argument on the code as it stands, so unless you say otherwise I would keep them loud, pin the behaviour with a test, and document why they differ. #932 already does the pinning and documenting, so this issue only decides whether the raise itself changes.

Surfaced by the Opus cross-review of #932 and verified independently.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    designA design or decision issue: a pattern being decided rather than a defect or a requestquestionIssues asking how something works rather than reporting a defect

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions