Skip to content

Avoid following symlink targets when link traversal is disabled - #156

Open
sricharanreddycheruku wants to merge 1 commit into
cpburnz:masterfrom
sricharanreddycheruku:batch7-no-follow-symlink-loops
Open

sricharanreddycheruku wants to merge 1 commit into
cpburnz:masterfrom
sricharanreddycheruku:batch7-no-follow-symlink-loops

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown

iter_tree_files(..., follow_links=False) still follows symbolic link targets
when it calls DirEntry.is_file() with the default follow_symlinks=True.
A self-referential link or a two-link cycle consequently raises ELOOP and
aborts traversal, although link following was disabled.

Pass the existing follow_links option to the file-type check, matching the
preceding directory-type check. Unfollowed links can then reach the existing
symlink-yield branch without inspecting their targets. The default following
behavior is unchanged.

Add real-filesystem regressions for both link cycles, checking that the links,
ordinary files, and nested files are all returned without an error callback.
Update the changelog source and its rendered copies.

Validation on Linux:

  • Original code: both new subtests error with ELOOP.
  • Fixed code: all 24 tree traversal tests run successfully (1 existing skip).
  • Python 3.14.7 full unittest suite: 234 tests run, OK (1 existing skip),
    with the optional native backends installed.
  • Python 3.9.25 full unittest suite: 234 tests run, OK; unavailable optional
    backend cases are skipped (391 skips including subtest skips).
  • Warning-as-error Sphinx documentation build and git diff --check pass.

No linked issue. This is independent of the pending gitignore matching changes.
Windows and macOS were not run locally.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant