-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
pathlib ABCs: remove duplicate realpath()
implementation.
#119178
Conversation
Add private `posixpath._realpath()` function, which is a generic version of `realpath()` that can be parameterised with string tokens (`sep`, `curdir`, `pardir`) and query functions (`getcwd`, `lstat`, `readlink`). Also add support for limiting the number of symlink traversals. In the private `pathlib._abc.PathBase` class, call `posixpath._realpath()` and remove our re-implementation of the same algorithm. This speeds up `PathBase.resolve()` because we instantiate fewer `PathBase` objects, and because `_realpath()` caches symlink targets.
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.
Don't hard code the error message, like eryksun pointed out in the other pull request.
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
…19178) Add private `posixpath._realpath()` function, which is a generic version of `realpath()` that can be parameterised with string tokens (`sep`, `curdir`, `pardir`) and query functions (`getcwd`, `lstat`, `readlink`). Also add support for limiting the number of symlink traversals. In the private `pathlib._abc.PathBase` class, call `posixpath._realpath()` and remove our re-implementation of the same algorithm. No change to any public APIs, either in `posixpath` or `pathlib`. Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Will backport to make backporting #120127 easier. |
Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
2 similar comments
Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @barneygale, I could not cleanly backport this to
|
Ah foo, nevermind then! |
Sorry, @barneygale, I could not cleanly backport this to
|
Sorry, @barneygale, I could not cleanly backport this to
|
…19178) Add private `posixpath._realpath()` function, which is a generic version of `realpath()` that can be parameterised with string tokens (`sep`, `curdir`, `pardir`) and query functions (`getcwd`, `lstat`, `readlink`). Also add support for limiting the number of symlink traversals. In the private `pathlib._abc.PathBase` class, call `posixpath._realpath()` and remove our re-implementation of the same algorithm. No change to any public APIs, either in `posixpath` or `pathlib`. Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
…19178) Add private `posixpath._realpath()` function, which is a generic version of `realpath()` that can be parameterised with string tokens (`sep`, `curdir`, `pardir`) and query functions (`getcwd`, `lstat`, `readlink`). Also add support for limiting the number of symlink traversals. In the private `pathlib._abc.PathBase` class, call `posixpath._realpath()` and remove our re-implementation of the same algorithm. No change to any public APIs, either in `posixpath` or `pathlib`. Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Add private
posixpath._realpath()
function, which is a generic version ofrealpath()
that can be parameterised with string tokens (sep
,curdir
,pardir
) and query functions (getcwd
,lstat
,readlink
). Also add support for limiting the number of symlink traversals.In the private
pathlib._abc.PathBase
class, callposixpath._realpath()
and remove our re-implementation of the same algorithm. This speeds upPathBase.resolve()
because we instantiate fewerPathBase
objects, and because_realpath()
caches symlink targets.No change to any public APIs, either in
posixpath
orpathlib
.