Repository navigation
fix(const): keep AppType/OptionType.register loud inside a quiet block (#1916) - #1927
Conversation
|
GOOD TO GO at |
|
Coverage: 90.07% (unit tier, Python 3.15,
Per-file detail: the |
|
Wondering if we can actually rename |
|
Yes. |
|
ready to go or pending changes? |
|
Pending changes. The |
#1916) - AppType.register and OptionType.register called _validate_value bare, so a rejection raised inside an enclosing quiet get block logged nothing. Run it inside `with _CaughtByCaller():`, as EnumRegistry.register does (#1845), in the vendor templates, and import _CaughtByCaller there. - Regenerate pcapkit/const/reg/apptype/apptype.py and pcapkit/const/pcapng/option_type.py from the edited templates, reusing the committed crawled data rather than re-crawling. - Add a unit test that TCP.register(70000, 'x') and OptionType.register(-1, 'x') still leave their record on the pcapkit logger inside `_CaughtByCaller(ValueError)`. Closes #1916
- The block is used across pcapkit as a library-wide context manager, so drop the leading underscore. It is new in this beta, so no old-name re-export is kept. - Rename every use: exceptions.py, corekit/enum.py, the AppType and OptionType vendor templates, the exceptions docs page, and the tests that open the block. The two const modules are regenerated from the templates. - Export it from pcapkit.utilities.exceptions.__all__ and word its docstring as a contract, with a versionadded directive. Refs #1916
2d50c6b to
985da2d
Compare
|
GOOD TO GO at |
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 — N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657
fix— corrects a defectAppType.registerandOptionType.registernow run_validate_valueinsidewith _CaughtByCaller():, asEnumRegistry.registerdoes (#1845), so a rejection stays loud inside a quietgetblock. The vendor templates are edited, and both const modules are regenerated from the crawled data already committed, without a re-crawl.The new test checks that
TCP.register(70000, 'x')andOptionType.register(-1, 'x')raise and log on thepcapkitlogger inside_CaughtByCaller(ValueError). Both cases fail without the fix.Closes #1916