bpo-43757: make pathlib use os.path.realpath() to resolve all symlinks in a path#25264
bpo-43757: make pathlib use os.path.realpath() to resolve all symlinks in a path#25264zooba merged 23 commits into
Conversation
46b35c6 to
2bb4dd4
Compare
April 7, 2021 22:18
|
Summary of the differences between Before this patch:
After this patch:
|
Sorry, something went wrong.
|
Note that |
Sorry, something went wrong.
b6ca430 to
984a6fc
Compare
April 8, 2021 01:59
Thanks. I've made this adjustment and also rebased to fix conflicts. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
|
Sorry, something went wrong.
I have nothing useful to add. I think @serhiy-storchaka is the person to ask. |
Sorry, something went wrong.
zooba
left a comment
There was a problem hiding this comment.
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.)
Sorry, something went wrong.
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 |
Sorry, something went wrong.
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). |
Sorry, something went wrong.
|
Sounds very reasonable, thanks! I'll revise this patch. |
Sorry, something went wrong.
|
Some options for how we could retain the current
Leaning towards option 3. Any thoughts, or options I've missed? |
Sorry, something went wrong.
|
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) |
Sorry, something went wrong.
…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
df04357
Compare
April 24, 2021 21:15
zooba
left a comment
There was a problem hiding this comment.
I'm happy with this now, just want to wait for one more approval before merging.
Sorry, something went wrong.
|
Going to interpret silence as approval. Good work! Thanks for this patch. |
Sorry, something went wrong.
|
Thanks very much for your help! |
Sorry, something went wrong.
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)
Removes a pathlib-specific implementation of
realpath()that's mostlycopied from
ntpathandposixpath.https://bugs.python.org/issue43757