Skip to content

Escape literal parent directories in glob searches - #274

Open
Apeksha9389 wants to merge 1 commit into
jaraco:mainfrom
Apeksha9389:fix/glob-literal-parent
Open

Apeksha9389 wants to merge 1 commit into
jaraco:mainfrom
Apeksha9389:fix/glob-literal-parent

Conversation

@Apeksha9389

Copy link
Copy Markdown

Path.glob() and Path.iglob() treat wildcard characters in the parent directory as part of the search pattern. A directory named [reports] can consequently return files from a sibling named r instead of its own files.

Escape the parent directory before joining the caller's pattern, leaving wildcard matching in that pattern intact. Parameterized regressions cover both APIs, including a matching sibling directory that must not be searched. Add a Towncrier fragment.

Validation on macOS/Python 3.12: both regression cases fail on unmodified main. tox -e py312 passes (166 passed, 1 skipped), including mypy and documentation checks. Explicit Ruff lint and formatting checks pass. Windows and the other Python versions were not run locally.

AI disclosure: The patch, tests, and description were prepared with OpenAI Codex assistance; the reported checks were executed locally.

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