MCPcopy Index your code
hub / github.com/python/cpython / _safe_realpath

Method _safe_realpath

Lib/pdb.py:211–220  ·  view source on GitHub ↗

Return the canonical path (realpath) if it is accessible from the userspace. Otherwise (for example, if the path is a symlink to an anonymous pipe), return the original path. See GH-142315.

(path)

Source from the content-addressed store, hash-verified

209
210 @staticmethod
211 def _safe_realpath(path):
212 """
213 Return the canonical path (realpath) if it is accessible from the userspace.
214 Otherwise (for example, if the path is a symlink to an anonymous pipe),
215 return the original path.
216
217 See GH-142315.
218 """
219 realpath = os.path.realpath(path)
220 return realpath if os.path.exists(realpath) else path
221
222 def __repr__(self):
223 return self._target

Callers 1

__init__Method · 0.95

Calls 2

realpathMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected