⚡ Sangsakala Proxy 🏠 Home
Skip to content

gh-161241: Fall back when FICLONE fails with EPERM in pathlib copyfileobj - #161244

Open
dropps07 wants to merge 6 commits into
python:mainfrom
dropps07:gh-161241-ficlone-eperm
Open

dropps07 wants to merge 6 commits into
python:mainfrom
dropps07:gh-161241-ficlone-eperm

Conversation

@dropps07

@dropps07 dropps07 commented Nov 3, 2026

Copy link
Copy Markdown

Fixes gh-161241
Path.copy() on Linux tries FICLONE first. On filesystems where that ioctl is blocked it returns EPERM, and pathlib/_os.py copyfileobj only fell back on EBADF, EOPNOTSUPP, ETXTBSY, EXDEV, so the copy failed with PermissionError even though a regular copy works — shutil.copy() succeeds on the same files.
This adds EPERM to the _ficlone fallback list, so a blocked reflink falls through to copy_file_range / sendfile / plain read-write copying.
Tests: added CopyFileobjFallbackTest.test_ficlone_eperm_falls_back in Lib/test/test_pathlib/test_copy.py; it fails without this change and passes with it. test_pathlib.test_copy passes (53 tests).

@dropps07
dropps07 requested a review from barneygale as a code owner November 3, 2026 09:12
@python-cla-bot

python-cla-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@dropps07

dropps07 commented Nov 4, 2026

Copy link
Copy Markdown
Author

@barneygale hey pls check my PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path.copy fails on filesystems where FICLONE returns EPERM instead of falling back

1 participant