From b6a5ecc88af554bb929db2c9bd170afeb82f7634 Mon Sep 17 00:00:00 2001 From: Zhonghao Huang Date: Wed, 13 Nov 2024 17:00:22 +0000 Subject: [PATCH] Add try-catch for os.path.commonpath to handle paths on different drives Enhanced the function to use a try-catch block around os.path.commonpath to gracefully handle cases where file paths are located on different drives. This ensures compatibility and prevents errors related to drive differences. R=aredulla@google.com, ayatane@chromium.org, sokcevic@chromium.org Bug: b/360206460 Change-Id: Iee51ba282fd85d211194d8678765a72783727db5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6018123 Reviewed-by: Josip Sokcevic Commit-Queue: Josip Sokcevic --- bootstrap/bootstrap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 2667227021..229bc6b1be 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -247,7 +247,10 @@ GIT_POSTPROCESS_VERSION = '2' def _within_depot_tools(path): """Returns whether the given path is within depot_tools.""" - return os.path.commonpath([os.path.abspath(path), ROOT_DIR]) == ROOT_DIR + try: + return os.path.commonpath([os.path.abspath(path), ROOT_DIR]) == ROOT_DIR + except ValueError: + return False def _traverse_to_git_root(abspath):