Fix crash when passing a very long cmdline argument (#11404)
Fixes #11394
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import atexit
|
||||
import contextlib
|
||||
import errno
|
||||
import fnmatch
|
||||
import importlib.util
|
||||
import itertools
|
||||
@@ -773,3 +774,13 @@ def bestrelpath(directory: Path, dest: Path) -> str:
|
||||
# Forward from base to dest.
|
||||
*reldest.parts,
|
||||
)
|
||||
|
||||
|
||||
def safe_exists(p: Path) -> bool:
|
||||
"""Like Path.exists(), but account for input arguments that might be too long (#11394)."""
|
||||
try:
|
||||
return p.exists()
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENAMETOOLONG:
|
||||
return False
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user