Repository navigation
Conversation
This branch has not been deployed
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.
Summary
iter_tree_entries()anditer_tree_files()handle errors opening a directory and inspecting its entries, but anOSErrorraised while advancing an already-openos.scandir()iterator escapes without reachingon_error.Handle scan-advancement errors using the existing contract: ignore the error when no handler is supplied, otherwise call the handler once with the original exception. Preserve entries already yielded and continue walking healthy sibling directories. Exceptions raised by the handler still propagate, and the scan context is closed.
The shared helper guards only
next(entries), not entry processing or callback execution. The change history is updated in both its source and generated file.Regression coverage
This is a synthetic directory-read-error reproduction, not a claim of a production incident. The tests inject an iterator that yields an entry and then raises
OSError(EIO), plus a failing child scan alongside a healthy sibling.Two new test methods cover both tree walkers, ignore/record/raise modes, original exception identity, once-only callbacks, context cleanup, partial results, and sibling traversal. Their eight subcases produce six errors and two failures against the unchanged base; all pass with the patch.
Validation
python -m unittest discover -t . -s tests/: OK on Python 3.12.14 and 3.13.5, each reporting 292 tests and 786 skipped cases/subcases. Optional RE2/Hyperscan backends were not installed.git diff --check: passed.Windows, other Python runtimes, optional native backends, type checking, and documentation builds were not run.
Prepared and reviewed with AI assistance; no human code review is claimed.