Skip to content

shutil.copytree: Give the option to disable copystat #89721

Open

Description

@doronbehar
BPO 45558
Nosy @jaraco, @doronbehar
PRs
  • gh-89721: shutil.copytree: Allow disabling copystat #29130
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-10-21.20:20:18.081>
    labels = ['type-feature', 'library', '3.11']
    title = 'shutil.copytree: Give the option to disable copystat'
    updated_at = <Date 2021-11-27.23:01:38.428>
    user = 'https://github.com/doronbehar'

    bugs.python.org fields:

    activity = <Date 2021-11-27.23:01:38.428>
    actor = 'doronbehar'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-10-21.20:20:18.081>
    creator = 'doronbehar'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45558
    keywords = ['patch']
    message_count = 2.0
    messages = ['407053', '407175']
    nosy_count = 2.0
    nosy_names = ['jaraco', 'doronbehar']
    pr_nums = ['29130']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue45558'
    versions = ['Python 3.11']

    Linked PRs

    Activity

    1. added
      3.11only security fixes
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on Oct 21, 2021
    2. jaraco commented on Nov 26, 2021

      @jaraco
      Member

      Can you provide a description of what motivated you to change the behavior or what benefits this change would have for you or others? Do you know why others haven’t reported this need previously?

    3. doronbehar commented on Nov 27, 2021

      doronbeharmannequin
      MannequinAuthor

      Can you provide a description of what motivated you to change the behavior or what benefits this change would have for you or others?

      Sometimes, you wish to copy a whole directory from a read-only file system and you don't want it to be read-only in the destination.

      Do you know why others haven’t reported this need previously?

      On NixOS all of the files that belong to packages are read-only. I encountered the need for this feature in GNURadio, at:

      gnuradio/gnuradio#5227

      The following Stack overflow question also suggests the need for this functionality is a bit common:

      https://stackoverflow.com/a/17022146/4935114

    4. transferred this issue fromon Apr 10, 2022
    5. max-privatevoid commented on Mar 3, 2023

      @max-privatevoid

      Facing this issue as well. Various Python software uses shutil.copytree to initialize state directories from a skeleton directory shipped with the software. With mutable package managers, all the files in package directories are read-write, so the problem doesn't become apparent. In the case of Nix and other package managers that install packages into immutable locations, this causes a surprising breakage. shutil.copytree already provide an argument copy_function, which allows disabling this behavior for files, but directories always get their permissions copied.

    6. added 2 commits that reference this issue on Oct 21, 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/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions