MCPcopy
hub / github.com/pytest-dev/pytest / safe_exists

Function safe_exists

src/_pytest/pathlib.py:1039–1046  ·  view source on GitHub ↗

Like Path.exists(), but account for input arguments that might be too long (#11394).

(p: Path)

Source from the content-addressed store, hash-verified

1037
1038
1039def safe_exists(p: Path) -> bool:
1040 """Like Path.exists(), but account for input arguments that might be too long (#11394)."""
1041 try:
1042 return p.exists()
1043 except (ValueError, OSError):
1044 # ValueError: stat: path too long for Windows
1045 # OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect
1046 return False
1047
1048
1049def samefile_nofollow(p1: Path, p2: Path) -> bool:

Callers 4

get_dirs_from_argsFunction · 0.90
test_safe_existsFunction · 0.90

Calls 1

existsMethod · 0.45

Tested by 1

test_safe_existsFunction · 0.72