Skip to content

Make it configurable whether shutil.copytree copies stat() information #138570

@pcc

Description

@pcc

Feature or enhancement

Proposal:

When copying a tree of files, it is sometimes useful for them to have default stat() information (file permissions, mtime and so on), instead of it being copied from the source files, for example when copying files from a read-only location to a temporary location where they may be modified or deleted later, but shutil.copytree unconditionally copies stat() information.

In a script that I wrote, I worked around the lack of this feature by monkey-patching the shutil.copystat function to do nothing, but this is clearly not a robust approach.

Ideally I would like to be able to turn off the stat() copying behavior by passing a named argument to copytree, such as:

shutil.copytree(src, dst, copystat=False)

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions