Skip to content

Unclear documentation for shutil.copytree() #88513

Description

@tilmanvogel
BPO 44347
Nosy @iritkatriel, @jdevries3133
PRs
  • bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok kwarg #26634
  • bpo-44347: [doc] clarify meaning of shutil.copytree's dirs_exist_ok kwarg #26643
  • 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-06-08.09:17:12.166>
    labels = ['3.9', '3.10', '3.11', 'type-feature', 'library', 'docs']
    title = 'Unclear documentation for shutil.copytree()'
    updated_at = <Date 2021-06-10.12:29:33.310>
    user = 'https://bugs.python.org/tilmanvogel'

    bugs.python.org fields:

    activity = <Date 2021-06-10.12:29:33.310>
    actor = 'jack__d'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2021-06-08.09:17:12.166>
    creator = 'tilman.vogel'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44347
    keywords = ['patch']
    message_count = 4.0
    messages = ['395315', '395452', '395489', '395494']
    nosy_count = 4.0
    nosy_names = ['docs@python', 'iritkatriel', 'tilman.vogel', 'jack__d']
    pr_nums = ['26634', '26643']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44347'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. tilmanvogel commented on Jun 8, 2021

      tilmanvogelmannequin
      MannequinAuthor

      I donot understand this sentence:

      "dirs_exist_ok dictates whether to raise an exception in case dst or any
      missing parent directory already exists."

      How can a "missing parent directory already exist"?

      My understanding would be that an existing dst would be OK (and copied into) but missing parent directories are just the ones above dst that also don't exist.

      Until 3.7, missing parent directories were documented to be auto-created (mkdir -p-style) according to the documentation ("The destination directory, named by dst, must not already exist; it will be created as well as missing parent directories."). Was this feature really removed? If not, then this part was accidentally (?) dropped from documentation?

      What am I missing? I think, the documentation should be amended to make that clear.

    2. added
      docsDocumentation in the Doc dir
      type-featureA feature request or enhancement
      on Jun 8, 2021
    3. iritkatriel commented on Jun 9, 2021

      @iritkatriel
      Member

      From the code, this arg is simply passed to os.mkdirs() here:

      os.makedirs(dst, exist_ok=dirs_exist_ok)

      os.mkdir is documented here: https://docs.python.org/3/library/os.html#os.makedirs

      and says just "If exist_ok is False (the default), an FileExistsError is raised if the target directory already exists."

      So I agree that the sentence you highlighted can be improved.

      Would you like to submit a patch?

    4. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Jun 9, 2021
    5. 2 remaining items

    6. added
      stdlibStandard Library Python modules in the Lib/ directory
      3.11only security fixes
      and removed on Jun 9, 2021
    7. jdevries3133 commented on Jun 9, 2021

      jdevries3133mannequin
      Mannequin

      I would like to submit a patch for this. This would be my first contribution :)

      I am starting on a patch now.

    8. jdevries3133 commented on Jun 9, 2021

      jdevries3133mannequin
      Mannequin

      I've created a PR: #26634

      I forgot to put a news entry, but hopefully that's ok since this is a very small change.

    9. transferred this issue fromon Apr 10, 2022
    10. added a commit that references this issue on Apr 12, 2022
    11. added a commit that references this issue on Apr 12, 2022
    12. JelleZijlstra commented on Apr 12, 2022

      @JelleZijlstra
      Member

      #91434 was merged to address this. Thanks for your contribution @jdevries3133! I'll close this issue once the backports (#91464, #91465) are merged.

    13. added a commit that references this issue on Apr 13, 2022
    14. added a commit that references this issue on Apr 15, 2022
    15. added a commit that references this issue on Jun 2, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifedocsDocumentation in the Doc dirstdlibStandard 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