Repository navigation
fix(foundation): treat only a regular file's seekable() as trustworthy (#2097) - #2104
Merged
Merged
Conversation
#2097) On Windows before CPython 3.16 a pipe reports seekable() and its seek does nothing (CPython gh-86768), so Extractor skipped SeekableReader and lost the octets its magic-number peek read. A stream whose descriptor is not a regular file is now wrapped; one without a descriptor is taken at its word.
Owner
Author
|
GOOD TO GO at
|
This was referenced Oct 23, 2026
Closed
Contributor
|
Coverage: 91.54% (unit tier, Python 3.15,
Per-file detail: the |
Owner
Author
|
Ready to merge at
This closes #2097. #2108 (the record-skip helper) follows once it merges. |
This was referenced Oct 23, 2026
fix(protocols): convert capture timestamps without the platform's fromtimestamp limits (#2099)
#2111
Merged
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)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix— bug fixesDescription of your pull request and other information
Closes #2097. On Windows a pipe's file object reports
seekable()as True whileseekdoes nothing (the agent cites CPython gh-86768 / bpo-42602; not re-verified here).Extractor.__init__therefore wrapped the raw pipe inPeekableStream, whose peek-then-seek-back lost the 4 magic octets. A buffered stdin got no wrapper at all, so itsseek(0, SEEK_END)answers were wrong. That is why 25 pipe cases,pcapkit -included, failed on the Windows leg (job 120605026883)._can_seek()inpcapkit/foundation/extraction.pytrustsseekable()only whenos.fstat(fileno)reports a regular file. A stream without a descriptor (e.g.BytesIO) is taken at its word as before. Anything else is wrapped inSeekableReader.test_extraction_windows_pipe_seekable_2097_unituses a realos.pipethat claims to be seekable and has a no-opseek. Without the fix the raw case raisesProtocolError: invalid magic number, as in the CI log, and the buffered case returns 0 frames instead of 50. The non-seekable stream tests pass.