Skip to content

Keep recursive globs within the selected directory - #614

Open
Boulea7 wants to merge 1 commit into
PyFilesystem:masterfrom
Boulea7:fix/recursive-glob-directory-boundary
Open

Boulea7 wants to merge 1 commit into
PyFilesystem:masterfrom
Boulea7:fix/recursive-glob-directory-boundary

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 2, 2026

Copy link
Copy Markdown

Type of change

Bug fix.

Description

In 2.4.16 and current master, fs.glob("my_folder/**/*") includes files directly in my_folder and in its subdirectories. It also includes files under a sibling named my_folder_extra. A standalone ** can consume text without a separator, so the match can continue inside the preceding directory name.

Require the separator whenever a standalone ** consumes path text. The regression checks direct files, nested files, and a sibling with the same prefix through the public glob API.

Refs #574.

Validation

  • Reproduced the extra match with MemoryFS and OSFS in both 2.4.16 and the parent commit. Both backends returned the expected paths after the fix.
  • Passed 108 glob, walk, wildcard, and path tests on each of Python 3.12 and 3.13. Changed-line coverage was 100%.
  • An independent comparison covered 102,942 combinations of patterns and synthetic absolute paths. The parent and 2.4.16 each returned 325 unexpected matches. The patched tree had zero mismatches on both Python versions.
  • The broader Python 3.12 filesystem run had the same six existing assertRaisesRegexp compatibility errors and six skips on both revisions. Black reported the same pre-existing formatting differences on both revisions.

Codex assisted with the reproduction, implementation, and tests.

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