From 7ae7d20cf9c6ae60017bf98a0bebcd6f7f001502 Mon Sep 17 00:00:00 2001 From: SanHsien <34234698+SanHsien@users.noreply.github.com> Date: Sun, 6 Sep 2026 10:18:35 +0800 Subject: [PATCH] fix(scripts): resolve editable file:// URLs with url2pathname A Windows file URL's path is "/C:/Users/...". Path() reads the leading slash as a root, so unquote() produced "C:\C:\Users\..." and the following resolve(strict=True) raised WinError 123. url2pathname is the stdlib conversion for this and is identical to the old behavior on POSIX, where the path has no drive letter to double. test_runtime_probe_hashes_installed_and_editable_dependency_bytes already covers this; it just never runs on a Windows host in CI. On Windows 11 / Python 3.13 it fails before this change and passes after. Fixes #485 Co-Authored-By: Claude Opus 5 Signed-off-by: SanHsien <34234698+SanHsien@users.noreply.github.com> --- scripts/compare_scan_accuracy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/compare_scan_accuracy.py b/scripts/compare_scan_accuracy.py index 50e1b569..8f4441ca 100644 --- a/scripts/compare_scan_accuracy.py +++ b/scripts/compare_scan_accuracy.py @@ -61,6 +61,7 @@ import platform import sys import urllib.parse +import urllib.request from pathlib import Path MAX_DEPENDENCY_FILES = 200_000 @@ -178,7 +179,9 @@ def hash_file(digest, label, path): parsed = urllib.parse.urlsplit(raw_url) if parsed.scheme != "file" or parsed.netloc not in {"", "localhost"}: raise RuntimeError(f"editable dependency is not a local file target: {normalized_name}") - editable_root = Path(urllib.parse.unquote(parsed.path)).resolve(strict=True) + # url2pathname, not unquote: a Windows file URL's path is "/C:/..." + # and Path() would read the leading slash as a root, producing "C:\C:\...". + editable_root = Path(urllib.request.url2pathname(parsed.path)).resolve(strict=True) if not editable_root.is_dir(): raise RuntimeError(f"editable dependency target is not a directory: {normalized_name}") for editable_path in sorted(editable_root.rglob("*")):