Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

shutil.copyfile() rejects device symlinks with follow_symlinks=False #154726

Copy link
Copy link

Description

@lkk7
Issue body actions

Bug report

Bug description:

I think it's a regression from #142693.

copyfile() rejects a symlink to a device even when follow_symlinks=False.

import os
import shutil
import tempfile

with tempfile.TemporaryDirectory() as directory:
    src = os.path.join(directory, "src")
    dst = os.path.join(directory, "dst")
    os.symlink("/dev/null", src)
    shutil.copyfile(src, dst, follow_symlinks=False)
  • Current behavior: shutil.SpecialFileError: .../src is a character device
  • Expected: dst is created as a symlink to /dev/null

The docs say:

If follow_symlinks is false and src is a symbolic link, a new symbolic link will be created instead of copying the file src points to.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.