-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
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-38811: Check for presence of os.link method in pathlib #17170
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! |
I assume Red Hat already signed the CLA. How do I go about having that registered in the system? |
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.
Looks good to me.
Is there a way to add testing for this code? |
Out of curiosity, which system did you try it on that didn't have |
Ram Rachum <[email protected]> writes:
Is there a way to add testing for this code?
Dunno? Looking at the other methods that are conditional in pathlib, I'm
not so sure: symlink just has a "skip_unless_symlink" decorator, and
lchmod() has no test at all.
|
I understand, so there's some precedent for leaving it untested, though it wouldn't be a bad idea to add testing both for this feature and the other methods, both in cases where they're supported and not. |
Ram Rachum <[email protected]> writes:
Out of curiosity, which system did you try it on that didn't have
`link`?
Whatever Travis CI is using: https://travis-ci.org/tohojo/flent/jobs/611950249
|
Ram Rachum <[email protected]> writes:
> Dunno? Looking at the other methods that are conditional in pathlib, I'm
> not so sure: symlink just has a "skip_unless_symlink" decorator, and
> lchmod() has no test at all.
I understand, so there's some precedent for leaving it untested,
though it wouldn't be a bad idea to add testing both for this feature
and the other methods, both in cases where they're supported and not.
Sure, more tests are always better :)
But how? The pathlib definition is done at import, so it's not quite as
simple as simply mock()'ing out the link method in os, is it? It would
take quite some refactoring of all the pathlib tests, no?
|
That is curious indeed, especially since Linux is mentioned there. @bittner do you have an idea which OS Travis is running on?
I agree it's difficult and you don't have to take it on. One simple idea would be to run a test only in cases where |
Ram Rachum <[email protected]> writes:
I agree it's difficult and you don't have to take it on. One simple
idea would be to run a test only in cases where `os.link` isn't
defined, and then have that test call `Path.link_to` and expect the
`NotImplementedError`.
That I can certainly do :)
|
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.
Looks good, just a bit of cleanup here:
Misc/NEWS.d/next/Library/2019-11-15-18-06-04.bpo-38811.AmdQ6M.rst
Outdated
Show resolved
Hide resolved
Also, the CLA is linked to your BPO account, so you'll need to follow the bot's instructions to sign it. |
I wonder if Travis intentionally disables symlinks, as a security measure. |
Also, welcome to CPython @tohojo! |
Thanks! I'll see if I can figure out the correct way to handle the CLA :) |
Here's the link again. |
Yeah, the trouble with that is that I can't really sign that since my corporate overlord already owns the rights to everything I do; so they will have to sign it. "They" being Red Hat, I'm assuming they already did, I just need to figure out how to get that into the PSF system. I seem to recall there being something about this on our intranet, but that is just giving me "service unavailable" errors right now, so I guess I'll have to try again a bit later :) |
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 |
Commit 6b5b013 ("bpo-26978: Implement pathlib.Path.link_to (Using os.link) (pythonGH-12990)") introduced a new link_to method in pathlib. However, this makes pathlib crash when the 'os' module is missing a 'link' method. Fix this by checking for the presence of the 'link' method on pathlib module import, and if it's not present, turn it into a runtime error like those emitted when there is no lchmod() or symlink(). Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
This adds a test case to test_pathlib.py to test the NotImplementedError raised when symlink support is not present on the system. Also add the missing @staticmethod decorator to the function definition in pathlib.py for that error path. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Oh, BTW, is there an automatic process to get this into 3.8.1, or should I open another pull request against the 3.8 branch? |
@tohojo I add backport label for 3.8. Bot will auto-create the PR for 3.8! |
Dong-hee Na <[email protected]> writes:
@tohojo I add backport label for 3.8. Bot will auto-create the PR for
3.8!
Great, thanks!
|
Thanks @tohojo for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-17204 is a backport of this pull request to the 3.8 branch. |
|
@serhiy-storchaka This was merged without a signed CLA... |
|
…-17170) Fix also the Path.symplink() method implementation for the case when symlinks are not supported.
…ythonGH-17170)" (python#17219) This reverts commit 111772f.
…-17170) Fix also the Path.symplink() method implementation for the case when symlinks are not supported.
…ythonGH-17170)" (python#17219) This reverts commit 111772f.
Commit 6b5b013 ("bpo-26978: Implement pathlib.Path.link_to (Using
os.link) (GH-12990)") introduced a new link_to method in pathlib. However,
this makes pathlib crash when the 'os' module is missing a 'link' method.
Fix this by checking for the presence of the 'link' method on pathlib
module import, and if it's not present, turn it into a runtime error like
those emitted when there is no lchmod() or symlink().
Signed-off-by: Toke Høiland-Jørgensen [email protected]
https://bugs.python.org/issue38811