Like Path.exists(), but account for input arguments that might be too long (#11394).
(p: Path)
| 1037 | |
| 1038 | |
| 1039 | def 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 | |
| 1049 | def samefile_nofollow(p1: Path, p2: Path) -> bool: |