classification
Title: readlink for pathlib paths
Type: enhancement Stage: commit review
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: berker.peksag, girts, gregory.p.smith, miss-islington, pitrou, planet36, smheidrich, spatz, tuxtimo
Priority: normal Keywords: patch

Created on 2017-06-09 23:55 by smheidrich, last changed 2019-10-23 22:37 by gregory.p.smith. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8285 merged girts, 2018-07-14 20:44
Messages (5)
msg295592 - (view) Author: (smheidrich) Date: 2017-06-09 23:55
Is there any reason why there is no equivalent of os.readlink in pathlib.Path? Note that Path.resolve does *not* fit the bill, as it always produces an absolute path, whereas readlink just spits out the symlink target exactly the way it is stored, which may be relative to the symlink itself:

>>> import pathlib, os
>>> p = pathlib.Path("/lib64/libc.so.6")
>>> p.resolve()
PosixPath('/lib64/libc-2.24.so')
>>> os.readlink(str(p))
'libc-2.24.so'
msg320335 - (view) Author: girts (girts) Date: 2018-06-23 21:33
Just ran into the same thing. I would be interested in adding support for a "readlink" call if a pull request on this would be welcome.
msg324364 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-08-30 04:31
The resolve() method already solves symlinks, but I think this is a reasonable feature request. I've just reviewed PR 8285.
msg355266 - (view) Author: miss-islington (miss-islington) Date: 2019-10-23 21:18
New changeset a01ba333affcc0677146dc8af57179bdb808d608 by Miss Skeleton (bot) (Girts) in branch 'master':
bpo-30618: add readlink to pathlib.Path (GH-8285)
https://github.com/python/cpython/commit/a01ba333affcc0677146dc8af57179bdb808d608
msg355271 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2019-10-23 22:37
Thanks Girts!
History
Date User Action Args
2019-10-23 22:37:43gregory.p.smithsetstatus: open -> closed
resolution: fixed
messages: + msg355271

stage: patch review -> commit review
2019-10-23 21:18:46miss-islingtonsetnosy: + miss-islington
messages: + msg355266
2019-10-23 20:55:16gregory.p.smithsetassignee: gregory.p.smith

nosy: + gregory.p.smith
2019-07-20 04:41:23girtsfsetversions: + Python 3.9, - Python 3.8
2018-08-30 04:31:25berker.peksagsetnosy: + pitrou, berker.peksag

messages: + msg324364
versions: + Python 3.8, - Python 3.7
2018-07-14 20:44:51girtssetkeywords: + patch
stage: patch review
pull_requests: + pull_request7819
2018-06-23 21:33:59girtssetnosy: + girts
messages: + msg320335
2018-05-31 16:16:06tuxtimosetnosy: + tuxtimo
2018-05-21 08:55:26spatzsetnosy: + spatz
2017-07-21 11:01:29planet36setnosy: + smheidrich
2017-07-21 11:01:00planet36setnosy: + planet36, - smheidrich
2017-06-09 23:55:59smheidrichcreate