fix: make _is_write_denied robust to Path objects (#1678)

Cast path to str() before os.path.expanduser() to handle pathlib.Path
inputs safely.

Based on PR #1051 by JackTheGit.

Co-authored-by: JackTheGit <JackTheGit@users.noreply.github.com>
This commit is contained in:
Teknium 2026-03-17 02:57:02 -07:00 committed by GitHub
parent 1d5a39e002
commit d9a7b83ae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -94,7 +94,7 @@ def _get_safe_write_root() -> Optional[str]:
def _is_write_denied(path: str) -> bool:
"""Return True if path is on the write deny list."""
resolved = os.path.realpath(os.path.expanduser(path))
resolved = os.path.realpath(os.path.expanduser(str(path)))
# 1) Static deny list
if resolved in WRITE_DENIED_PATHS: