Repository navigation
fix(dumpkit): tree output raises on complex and is undocumented as lossy (#1266) - #1366
Merged
Merged
Conversation
…ssy (#1266) - make_dumper() overrides Tree._append_number to write a complex value as "-> (1+2j)", spelling NaN/Infinity as the writer does for a float; upstream math.isnan() raised TypeError on it. JSON and PLIST unchanged. - docs/source/pcapkit/dumpkit/index.rst: state that tree is a lossy, human-readable view and that json and plist are the round-trip formats. - tests/dumpkit/test_tree_lossy_unit.py pins both.
Owner
Author
|
Cross-review verdict on
Nits: |
Contributor
|
Coverage: 85.36% (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.
main)make testpasses, and a test case covers the change (rantests/project,util/run_unittest_leg.py dumpkitand the new module; not the full suite)docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible (N/A, added centrally)What is the purpose of your pull request?
fix— corrects a defectDescription of your pull request and other information
Closes #1266. Option (1), as ruled.
complex:make_dumper()overridesTree._append_number. It writes acomplexvalue as-> (1+2j), spellingNaN/Infinitythe way the writer does for afloat. Before,{'c': 1+2j}raisedTypeError: must be real number, not complex(dictdumper/tree.py:397). The override applies only toTree. JSON and PLIST are byte-identical tomainover all 23 fixture captures (69 json/plist/tree reports, 27.8 MB,diff -rclean).docs/source/pcapkit/dumpkit/index.rstnow says tree is a lossy, human-readable view and namesjson/plistas the round-trip formats. A grep ofdocs/andpcapkit/found no claim that every dumper round-trips, so no other file changed. Since fix(dumpkit)!: output writers drop or corrupt what the packets carried #1305,NO_VALUE/NULLrender as<NO_VALUE>/<NULL>, notNIL, so the note lists only'',b'',Noneand{}.tests/dumpkit/test_tree_lossy_unit.py: 7 passed. Withgit show origin/main:pcapkit/dumpkit/common.pywritten over the fix: 4 failed (the fourcomplextree tests), 3 passed (JSON/PLIST and real-number pins, unchanged by design).tests/project: 389 passed, 1 skipped.run_unittest_leg.py dumpkit: 223 tests, 0 failures.