You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(const): AppType.register and OptionType.register let an enclosing quiet block silence their rejection #1916
EnumRegistry.register runs _validate_value inside with _CaughtByCaller(): (pcapkit/corekit/enum.py:580). That keeps its rejection loud even inside a quiet get block, which is what the #1845 ruling asked for. The generated overrides call cls._validate_value(...) without that block: pcapkit/const/reg/apptype/apptype.py:2831 and pcapkit/const/pcapng/option_type.py:280. Both come from the templates in pcapkit/vendor/reg/apptype/apptype.py and pcapkit/vendor/pcapng/option_type.py:190.
Repro on 95caa8b36, with a handler attached to the pcapkit logger. Inside with _CaughtByCaller(ValueError):, TCP.register(70000, 'x') and OptionType.register(-1, 'x') raise EnumValueError and log nothing. In the same block, an EnumRegistry subclass whose _validate_value rejects does log EnumValueError: .... Outside any block, all three log.
The AppType.register docstring says it validates "as EnumRegistry.register does", which is only partly true. The #1873 review noted this as a non-blocker, since nothing reaches these overrides from a quiet block today.
Fix: wrap both calls in with _CaughtByCaller(): in the vendor templates, regenerate the const modules, and add a loud-inside-quiet test for each override, mirroring #1873's register test.
Activity
fix(const): keep AppType/OptionType.register loud inside a quiet block (
refactor(utilities): rename _CaughtByCaller to CaughtByCaller (#1916)