-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-38688: Consume iterator and create list of entries to prevent infinite loop #17098
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
CLA signed, though not sure how long it may take for the bot to kick in again 👍 |
Please also do: - ignored_names = ignore(src, set(os.listdir(src)))
+ ignored_names = ignore(src, set([x.name for x in entries])) |
Ah, good spot! Done 👍 |
Add a Misc/NEWS entry and we're good to go (check out "python devguide" on how to do it). |
@giampaolo I've pushed a new commit with the news entry (used the I've rebased again, and push-force with a change to the previous commit, but only to the test. There was a failure on Travis/Azure but on another test that I think shouldn't be related to this change. But there is also a warning that the test I've added alters the environment. I had copied another test to use as reference, so I changed a bit the test clean up to see if this message will go away 🤞 And huge thanks for the help and patience so far! |
Well, test warning for altering execution environment is still there, but not sure if introduced in this change. |
Misc/NEWS.d/next/Library/2019-11-22-10-45-03.bpo-38668.iKx23z.rst
Outdated
Show resolved
Hide resolved
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 |
7d64d70
to
56615e0
Compare
I have made the requested changes; please review again. |
Thanks for making the requested changes! @giampaolo: please review the changes made to this pull request. |
Lib/test/test_shutil.py
Outdated
base_dir = self.mkdtemp() | ||
self.addCleanup(shutil.rmtree, base_dir, ignore_errors=True) | ||
src_dir = os.path.join(base_dir, "t/pg/") | ||
dst_dir = os.path.join(src_dir, "somevendor/1.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src_dir = os.path.join(base_dir, "t", "pg")
dst_dir = os.path.join(src_dir, "somevendor", "1.0")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! So close! Fixed. Thanks!
Thanks @kinow for the PR, and @giampaolo for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, @kinow and @giampaolo, I could not cleanly backport this to |
@kinow please also create a backport for 3.8. |
On it @giampaolo, if nothing goes wrong hoping to have a PR in a couple hours or more (just need to learn how to use the |
No rush. Thanks. |
… entries to prevent infinite recursion (pythonGH-17098). (cherry picked from commit 9bbcbc9) Co-authored-by: Bruno P. Kinoshita <kinow@users.noreply.github.com>
GH-17397 is a backport of this pull request to the 3.8 branch. |
…es to prevent infinite recursion (pythonGH-17098)
…es to prevent infinite recursion (pythonGH-17098)
Hi,
Reverted part of
33695
due to the regression reported in38688
. Text below is a copy-paste from my comment in the bugs.python.org issue.It looks to me that the iterator returned by with
os.scandir(...)
is including the newly createddst
directory. See the call foros.makedirs(dst, exist_ok=dirs_exist_ok)
, just before the iterator is open:cpython/Lib/shutil.py
Lines 449 to 453 in e27449d
This results in the function finding an extra directory, and repeating the steps for this folder and its subfolder recursively. This only happens because in the example reported in the issue,
dst
is a subdirectory ofsrc
.The bpo-33695 commit had more changes, so I've reverted just this block of the
copytree
as a tentative fix, and added a unit test.--
Here's a simplified version of what's going on:
My first PR here. Let me know if I forgot anything. Happy to update the PR as necessary 👍
Bruno
https://bugs.python.org/issue38688