Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-43757: make pathlib use os.path.realpath() to resolve all symlinks in a path#25264
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
barneygale commented Apr 7, 2021 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
46b35c6 to 2bb4dd4Comparebarneygale commented Apr 8, 2021
Summary of the differences between Before this patch:
After this patch:
|
eryksun commented Apr 8, 2021
Note that |
b6ca430 to 984a6fcComparebarneygale commented Apr 8, 2021
Thanks. I've made this adjustment and also rebased to fix conflicts. |
barneygale commented Apr 8, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Looks like the
This doesn't agree with my expectations, nor with the first sentence of the function documentation:
A symlink loop doesn't seem like a good reason to break the bolded guarantee. |
Uh oh!
There was an error while loading. Please reload this page.
barneygale commented Apr 8, 2021
|
Uh oh!
There was an error while loading. Please reload this page.
eryksun commented Apr 8, 2021
I have nothing useful to add. I think @serhiy-storchaka is the person to ask. |
zooba left a comment
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.
Not declaring an opinion yet on the behaviour change, but I think it's probably okay. I'd be happier if the link cycle change was also tied to the strict argument. (My main concern is that virtually nobody will be testing for it, and it can become an issue based entirely on user's setup - nothing to do with the code that will fail.)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Misc/NEWS.d/next/Library/2021-04-08-22-11-27.bpo-25264.hEqA5d.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
barneygale commented Apr 9, 2021
I can make the new symlink loop handling optional, but in order to use it from pathlib it would need to be an additional argument, as I'd argue that the new behaviour is justified because the current behaviour seems entirely non-useful. I can't find another example of a |
Uh oh!
There was an error while loading. Please reload this page.
zooba commented Apr 12, 2021
This is probably true, but I don't want to add an earlier (and less expected) failure without more warning. Raising a warning in this case but not an error would be fine for 3.10 and 3.11, and then we could confidently make it raise an error in 3.12. That gives devs a few years to realise that an error might be occurring here and handle it properly (or choose to suppress it explicitly). |
barneygale commented Apr 12, 2021
Sounds very reasonable, thanks! I'll revise this patch. |
barneygale commented Apr 12, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Some options for how we could retain the current
Leaning towards option 3. Any thoughts, or options I've missed? |
barneygale commented Apr 13, 2021 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
OK, I've updated this such that there's no change in non-strict Before this PR:
After this PR:
(by "muddle on" I mean append the remaining path components and return) |
…s in a path Removes a pathlib-specific implementation of `realpath()` that's mostly copied from `ntpath` and `posixpath`.
… when a new `strict=True` keyword-only argument is passed.
8ee02f2 to df04357Compare
zooba left a comment
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 happy with this now, just want to wait for one more approval before merging.
zooba commented Apr 28, 2021
Going to interpret silence as approval. Good work! Thanks for this patch. |
barneygale commented Apr 28, 2021
Thanks very much for your help! |
Bug was fixed by pythonGH-25264 which, for other reasons, moved to a system independent resolve. Adds tests for verifying resolve() on cases other than for symlinks. New cases include relative and absolute paths with and without dotted (./..) paths. Also renames test helper function to avoid name overloading and adds new REL_PATH test constant.
… a path (pythonGH-25264) Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation.
… a path (pythonGH-25264) Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation.
… a path (pythonGH-25264) Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation. (cherry-picked from commit baecfbd)
…nks in a path (pythonGH-25264) Also adds a new "strict" argument to realpath() to avoid changing the default behaviour of pathlib while sharing the implementation. (cherry-picked from commit baecfbd)
GH-135035 is a backport of this pull request to the 3.9 branch. |
Removes a pathlib-specific implementation of
realpath()that's mostlycopied from
ntpathandposixpath.https://bugs.python.org/issue43757