Skip to content

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

Description

@dropps07

Path.copy() on Linux tries FICLONE first. On filesystems where that ioctl is blocked it returns EPERM (e.g. overlayfs in containers; SELinux-blocked ioctl is a known precedent). pathlib/_os.py copyfileobj only falls back on EBADF, EOPNOTSUPP, ETXTBSY, EXDEV, so the copy fails with PermissionError even though a regular copy works — shutil.copy() succeeds on the same files.

Reproducer: build main, then Path('a.txt').copy('c.txt') on such a filesystem (also reproducible by making _ficlone raise EPERM).

Proposed fix: add EPERM to the _ficlone fallback list.

Linked PRs

Activity

  1. added 5 commits that reference this issue on Nov 3, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 3, 2026
  3. added a commit that references this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions