summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
authorGirts <girtsf@users.noreply.github.com>2019-10-23 21:18:40 (GMT)
committerMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2019-10-23 21:18:40 (GMT)
commita01ba333affcc0677146dc8af57179bdb808d608 (patch)
tree5b3c67ab51bc2c5074b19828c24de7a3d2eac119 /Lib/pathlib.py
parent01659ca62c4508518478a74615ac91c0009427ad (diff)
downloadcpython-a01ba333affcc0677146dc8af57179bdb808d608.zip
cpython-a01ba333affcc0677146dc8af57179bdb808d608.tar.gz
cpython-a01ba333affcc0677146dc8af57179bdb808d608.tar.bz2
bpo-30618: add readlink to pathlib.Path (GH-8285)
This adds a "readlink" method to pathlib.Path objects that calls through to os.readlink. https://bugs.python.org/issue30618 Automerge-Triggered-By: @gpshead
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r--Lib/pathlib.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 67b94e0..825533d 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -1244,6 +1244,15 @@ class Path(PurePath):
with self.open(mode='w', encoding=encoding, errors=errors) as f:
return f.write(data)
+ def readlink(self):
+ """
+ Return the path to which the symbolic link points.
+ """
+ path = self._accessor.readlink(self)
+ obj = self._from_parts((path,), init=False)
+ obj._init(template=self)
+ return obj
+
def touch(self, mode=0o666, exist_ok=True):
"""
Create this file with the given access mode, if it doesn't exist.