Skip to content

Allow touching existing read-only files - #272

Open
Apeksha9389 wants to merge 1 commit into
jaraco:mainfrom
Apeksha9389:fix/touch-readonly-files
Open

Apeksha9389 wants to merge 1 commit into
jaraco:mainfrom
Apeksha9389:fix/touch-readonly-files

Conversation

@Apeksha9389

Copy link
Copy Markdown

Path.touch() opens an existing file for writing before updating its timestamps. On POSIX, a read-only file owned by the caller therefore raises PermissionError, although the timestamp update itself is permitted.

Delegate to pathlib.Path.touch(), which attempts the timestamp update before creating a missing file, and preserve the chainable return value. The regression test checks timestamp changes, unchanged content, and unchanged permissions. Add a Towncrier fragment.

Validation on macOS/Python 3.12: tox -e py312 passes (165 passed, 1 skipped), including mypy and documentation checks. Explicit Ruff lint and formatting checks pass. The new regression fails on unmodified main. 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