Repository navigation
fix(pcap): Frame.from_data cannot be called — it has no way to pass num and header - #1147
Merged
Merged
Conversation
…um and header ProtocolBase.from_data now takes **kwargs and forwards them to the construction, overriding what _make_data returns, so Frame can be rebuilt with from_data(info, num=..., header=...) and PCAPNG with num/sct/ctx. Caller keywords get the strict construction-keyword check. Drops the stale ts_src/prio examples from the _check_construction_keywords comment (both fixed in #1115), and the _make_data patch in test_make_data_keys_unit. Closes #1126
Owner
Author
|
Cross-review verdict on
Nit: the explicit |
Contributor
|
Coverage: 88.75% (unit tier, Python 3.14,
Per-file detail: the |
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.
make pylint,make mypy,make isort) — run with the Makefile flags on the two changed source files; no new findings vsmainmake testpasses, and a test case covers the change — the modules listed below only, not the full suitedocs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible — N/A, added centrally after the waveWhat is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1126.
ProtocolBase.from_data(data, **kwargs)now forwards extra keywords to the construction, overriding_make_data's. Caller keywords get the strict construction-keyword check, so a typo raisesUnsupportedCall.PCAPNG.from_datahad the same defect (it needsnum/sct/ctx), and this fixes it too.Before:
Frame.from_data(info, num=1, header=hdr)raisedTypeError: from_data() got an unexpected keyword argument 'num'.PCAPNG.from_data(shb.info, num=0, sct=1, ctx=None)failed the same way.After: all 6 frames of
in.pcapround-trip byte for byte, and so does thetest.pcapngSHB (164 B).Also: dropped the stale
ts_src/prioexamples from the_check_construction_keywordscomment (both fixed in #1115). Removed the_make_datapatch fromtest_make_data_keys_unit.Tests: new
tests/protocols/misc/pcap/test_frame_from_data_runtime.py. Without the fix it gives 8 failed, 1 passed; with the fix it gives 3 passed, 6 subtests passed. Passing modules:test_make_data_keys_unit(2),test_construction_keyword_check_unit(22),test_protocol_base_unit(15),pcap/test_header_frame_unit(6),pcap/test_frame_runtime(4),misc/test_pcapng_unit(97), andtests/project(385 passed, 1 skipped).