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-30177: Fix misleading description of path.resolve() #1649
Conversation
…e library/pathlib
@Traceur759, thanks for your PR! By analyzing the history of the files in this pull request, we identified @eliben, @serhiy-storchaka and @marco-buttu to be potential reviewers. |
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
I was able to reproduce this bug, but I really don't think This behavior is really confusing for multiple reasons, and I think the best way would be for it to work as currently documented, which is equivalent to the behavior of If you want to check existence, you already have the |
Thanks @Traceur759, I do not know whether there is a bug or the documentation is wrong. Maybe @zooba knows. In case the documentation is wrong, IMHO you can extend the patch with a short example, like this one:
|
It should not be a bug, inside of pathlib tests (path/to/cpython/Lib/test/test_pathlib.py), there is this piece of code starting at line 1491:
As you can see, the test expects the rest to be omitted, no way of being a bug inside the test. This behavior raises lots of controversy and most likely should be discussed with the upstream, but for now it seems like the docs should be edited. |
Thanks @Traceur759. About adding the example I proposed in the previous message, let's wait for a core-dev opinion. |
I'd like to add that in Windows + Python 3.6, the behavior matches the documented one (which is the correct one, imho).
|
For what it's worth, if this can have any impact in the decision making, this bug was the cause of an important downtime in our organization, because someone needed to normalize a path that was later passed to a |
I would argue that the documentation is correct in this case and there is a bug in the code. The
The documented behaviour also seems much more useful than the current behaviour. I encountered this bug in much the same was as @seirl - I needed a path which was both absolute and useable for |
Let's keep the discussion on http://bugs.python.org/issue30177 please, and use this thread solely for code review. |
I'd like this PR to be rejected, as this clearly is not the desirable solution to the original issue. |
Seconded. |
According to the documentation https://docs.python.org/3/library/pathlib.html#pathlib.Path.resolve
If strict is False, the path is resolved as far as possible and any remainder is appended without checking whether it exists.
The current behavior is not consistent with this, and only appends the first remainder.
This commit fixes the documentation