-
Couldn't load subscription status.
- Fork 3.2k
Added the possibility to follow symlinks on copytree also for py3 #3707
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
Conversation
|
Seems has been fixed since Python 3.5 travis build and py3.5 source. |
|
You said this has been fixed- Does that mean this PR is no longer needed? Or that it's needed for Python's older then 3.5? |
|
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
|
Hi! @alquerci Could you by any chance fix the conflicts in this PR? Sidenote: The tests seem to be failing on AppVeyor. |
|
Hello @pradyunsg I will start to do it by tomorrow. |
|
@pradyunsg All type of fixes are done (conflicts, lints, news). |
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.
Mostly just minor nits and a few misc questions.
I've not checked the functionality of the PR since I haven't read the previous discussions on this PR yet. :)
| @@ -0,0 +1,3 @@ | |||
| 1. Revert previous fix that disable symlinks dereference. | |||
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.
Please don't have a numbered list here. The news fragments get aggregated into a list. This would result in a list containing a list - nobody wants that in NEWS. :P
Having a commit message style summary line followed by a small passage describing the change would probably be a better format. :)
This suggests to me that this PR is doing multiple things at the same time; if so, is it possible to split them?
| os.symlink(linkto, dst) | ||
| return dst | ||
| except OSError: | ||
| # catch the OSError when the os.symlink function is called |
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.
nit: Catch
| 'Circular reference detected in "%s" ("%s" > "%s").' | ||
| '' % (resources[0], '" > "'.join(resources), resources[0]), | ||
| ) | ||
| PipError.__init__(self, message) |
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.
nit: Use super(CircularSymlinkException, self).__init__(message)
| def validate_path(path): | ||
| """Detect circular symbolic link | ||
| @raise CircularSymlinkException: When a symlink loop was found |
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.
nit: Use plain English; don't tag with @raise since that isn't something consistent with the rest of the codebase.
| def copytree_ignore_callback(src, names): | ||
| """Ignore circular symbolic links | ||
| @return: set of ignores names |
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.
nit: Use plain English; as above.
|
|
||
|
|
||
| def copytree(source, location, symlinks=False): | ||
| return compat.copytree( |
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.
I think it makes sense to have a docstring here describing why we don't simply reuse shutil.copytree.
| ) | ||
|
|
||
|
|
||
| def copytree_ignore_callback(src, names): |
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.
Maybe make this _copytree_ignore_callback?
| finally: | ||
| os.unlink(symbar_link) | ||
|
|
||
| @pytest.mark.skipif( |
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.
nit: You're using the same decorator in multiple places; you can simply make it into a module level underscored variable and decorate functions with it.
needs_os_symlink = pytest.mark.skipif(not hasattr(os, "symlink"), reason="requires os.symlink")| import tarfile | ||
| import zipfile | ||
|
|
||
| # For copytree as when using from an import exception is thrown. |
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.
I'm curious, what are you seeing?
| os.symlink(foo_file, symfoo_link) | ||
| validate_path(symfoo_link) | ||
| except OSError: | ||
| return |
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.
Skip the test or make it fail if you come inside the except; maybe don't actually catch it?
Same for later cases as well.
|
Thanks for updating this @alquerci! ^.^ |
|
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
|
@alquerci Could you fix the conflicts in this PR; again? |
|
Closing due to lack of a response. |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hello,
Reply to #1311
It's an answer of https://github.com/pypa/pip/pull/1311/files#r7640350
If a project contains true NTFS symlinks it require elevated privileges indeed (source: @docs.python: os.symlink and @Wikipedia: NTFS_symbolic_link)
Fix shutil.copytree for py3 when a symlink points to a directory
Prevent circular symbolic links
Add test with circular symbolic links
revert f579c17
It should be also update tests.lib.path.Path.copytree method (e.g. git revert 99a4f6f) but it will add a dependency to pip.util module.
All comments are welcome
This was migrated from #1329 to reparent it to the
masterbranch. Please see original pull request for any previous discussion.This change is