Uh oh!
There was an error while loading. Please reload this page.
bpo-20849: add dirs_exist_ok to shutil.copytree - #8792
Conversation
Hey, could you please fix the news check while waiting for a review? I just hit this same thing myself and was about to file a PR maybe ten minutes after you with basically same contents. I to be honest think there's some merit to the critique on the ticket while this was my first idea as well. If you compare cp to shutil.copytree, cp has a --no-clobber so it creates directories but allows not overwriting existing files. While yours is a very backwards-compatible interpretation, I kinda think cp's way of doing it makes more sense than both the old and new Python idea of copytree |
Uh oh!
There was an error while loading. Please reload this page.
merwok
commented
Aug 16, 2018
Hello! Your branch contains unwanted changes to get-pip and a patch file. If you’re using git on the command line, a nice tip is to use Graphical git clients usually have a diff hunk selection screen that serves the same purpose. |
jab
commented
Aug 16, 2018
@merwok wrote:
Sorry about that! Fixed in the latest revision.
Nice, thanks for the tip! @nanonyme wrote:
Done in the latest revision.
No way! Solidarity, @nanonyme. Extra funny coincidence given how long this issue has been around.
I agree. Will wait for a maintainer to weigh in on how to proceed. |
e783b52 to
24f03eeCompareUh oh!
There was an error while loading. Please reload this page.
1st1
commented
Sep 7, 2018
@giampaolo@vstinner The PR looks OK to my eyes, should we merge it? |
Uh oh!
There was an error while loading. Please reload this page.
jab
commented
Sep 15, 2018
Thanks for reviewing @1st1! Since the others you pinged haven’t been able to respond yet, is there anyone else who should review before this can be merged? The rest of the month will be busy for me so hoping to land while I still have the spare cycles. |
jab
commented
Dec 15, 2018
Any maintainers up for giving this a look some time soon? Cheers 3 months ago @1st1 wrote:
|
As I said on the bug tracker I think the new argument should be called "dirs_exists_ok" (EDIT: "dirs_exist_ok") instead of "exists_ok" so that it's clear that the behavior does not affect files. Other than that the patch is fine with me but it should be updated as it has conflicts with master. |
Thanks for replying @giampaolo! This has been labeled as "awaiting review" since Aug 16 and nobody commented on bpo-20849 since I did on Aug 17, so I didn't realize you were awaiting changes on this before it could be merged.
Rebased on latest master. (Had to resolve conflicts from your bpo-33695 changes, which I hadn't noticed before – nice changes!) All tests are passing on CI (including the
I don't follow – this does affect files. Are you mistakenly thinking that this patch implements option (b) described in Éric Araujo's comment (as he said the original patch did), whereas this patch actually implements option (a) (i.e. it behaves like BSD From the docs I wrote for this: "If exist_ok is true, the destination directory may already exist, and existing files in the destination tree will be overwritten by matching files in the source tree." (emphasis added) Also:
So can this be merged as-is before there are any further conflicts? |
There was a problem hiding this comment.
(I assumed this can't land in a 3.7.x release. Can it?)
Uh oh!
There was an error while loading. Please reload this page.
jab
commented
Dec 20, 2018
(Unfortunately GNU |
You're right that "exist_ok" argument matches |
nanonyme
commented
Dec 20, 2018
Just a bit of an out-of-the-box thought: how about replace_existing/overwrite instead of all these exist_ok and dirs_exist_ok? |
giampaolo
commented
Dec 20, 2018
Same problem (doesn't tell who's the target). |
I think using the word "target" instead of "destination" is muddying the waters in this discussion. If we stick to using the word "destination" instead of "target", which is the term used in the function description itself, then isn't it clear that we're talking about the
I'm having trouble making any sense of this unless you meant "exist_ok=True" here. Did you? If so, then even with "dirs_exist_ok=True", couldn't that still be misinterpreted as "files with the same name might be skipped since this only applies to directories"? |
No, it's not, because "exists_ok" is meant for directories only and what
It cannot be misinterpreted because of the "dirs_" bit. It's clear it's about directories and not about files or both. |
I have renamed the argument I'm still not following your logic but prefer to defer so this can be merged.
To be fair, that was in the context of someone else's patch from 5 years ago, which implemented behavior (b). This patch implements behavior (a).
I just meant that now the argument name says nothing about what happens to files. Before you were imagining a user who didn't read the docs and jumping to the wrong conclusion about what happens to files. I don't think the new name really prevents that. |
There was a problem hiding this comment.
I would simply rephrase it as something along these lines:
*dirs_exist_ok* dictates whether to raise an exception in case *dst* as well as any missing parent directory already exists. I would not talk about the overwriting of files because the argument specifically targets directories and has nothing to do with files. When copying a big directory another process may create files in the dst directory which conflicts with the ones living in src, and they are always overwritten even when dirs_exist_ok=False.
There was a problem hiding this comment.
The behavior of dirs_exist_ok=False (raising an exception) is already documented in the previous paragraph, so your rephrasing of this paragraph seems redundant. The purpose of this paragraph was to document the behavior of dirs_exist_ok=True.
I've just removed the part that talks about files.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
bedevere-bot
commented
Dec 21, 2018
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
jab
commented
Dec 21, 2018
@bedevere-bot I have made the requested changes; please review again |
bedevere-bot
commented
Dec 21, 2018
Thanks for making the requested changes! @giampaolo: please review the changes made to this pull request. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
giampaolo
commented
Dec 28, 2018
Looks good. Merging. |
jab
commented
Dec 28, 2018
Thanks @giampaolo! Can this be considered for backporting to 3.7.x? If so I would be happy to submit another PR for that. |
giampaolo
commented
Dec 28, 2018
;-) |
It looks like the original author of #2977 lost interest, and it would still be really useful to have this, so I thought I'd pick it back up.
https://bugs.python.org/issue20849