bpo-39390: fix argument types for ignore callback of shutil.copytree#18122
bpo-39390: fix argument types for ignore callback of shutil.copytree#18122giampaolo merged 1 commit intopython:masterfrom
Conversation
Lib/shutil.py
Outdated
There was a problem hiding this comment.
This removes the speedup originally introduced. I think you can just do this:
ignored_names = ignore(os.fspath(src), [x.path for x in entries])
There should be a unit test which makes sure the callback function receives a string regardless of the type passed as input (str, pathlib.Path, os.DirEntry).
There was a problem hiding this comment.
I have made the requested changes; please review again.
There was a problem hiding this comment.
Sorry, I missed something for the test.
There was a problem hiding this comment.
Ok, I think it should be good now.
|
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 |
f18cf4f to
95953fd
Compare
Lib/test/test_shutil.py
Outdated
There was a problem hiding this comment.
You can use self.addCleanup(shutil.rmtree, path) and avoid the try/finally blocks.
There was a problem hiding this comment.
Hmm, actually from the looks of it, that's already part of self.mkdtemp.
There was a problem hiding this comment.
I think the test should be ok now.
95953fd to
b0c0108
Compare
giampaolo
left a comment
There was a problem hiding this comment.
I added one last nitpick. Also, please add a NEWS entry with blurb.
Lib/test/test_shutil.py
Outdated
There was a problem hiding this comment.
I'd add a check to make sure this function is called 3 times. Something like:
def test_copytree_arg_types_of_ignore(self):
def _ignore(src, names):
...
flags.append(None)
flags = []
... # body
self.assertEqual(len(flags), 3) # last lineThere was a problem hiding this comment.
Since it's called recursively, it's actually called a total of 9 times, but in any case it works.
b0c0108 to
eebcd7a
Compare
|
Thanks @mbarkhau for the PR, and @giampaolo for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
|
I'm having trouble backporting to |
|
Could you backport this to 3.8? |
|
I'll have a look. |
|
GH-18168 is a backport of this pull request to the 3.8 branch. |
…nGH-18122). (cherry picked from commit 8870433) Co-authored-by: mbarkhau <mbarkhau@gmail.com>
The directory being copied.
An ignore function for debugging.
Python 3.7
Python 3.8
https://bugs.python.org/issue39390