pathlib ABCs: remove duplicate realpath() implementation.#119178
pathlib ABCs: remove duplicate realpath() implementation.#119178barneygale merged 7 commits intopython:mainfrom
realpath() implementation.#119178Conversation
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.
nineteendo
left a comment
There was a problem hiding this comment.
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.PathBaseclass, callposixpath._realpath()and remove our re-implementation of the same algorithm. This speeds upPathBase.resolve()because we instantiate fewerPathBaseobjects, and because_realpath()caches symlink targets.No change to any public APIs, either in
posixpathorpathlib.