From 2fde5c415abb74b5466ade180f48065d0487d971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20PEREGI?= Date: Thu, 20 Jul 2023 12:06:06 +0200 Subject: [PATCH] Add assert to make issue #1949 more apparent --- src/virtualenv/util/zipapp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/virtualenv/util/zipapp.py b/src/virtualenv/util/zipapp.py index 3049b8400..b59116391 100644 --- a/src/virtualenv/util/zipapp.py +++ b/src/virtualenv/util/zipapp.py @@ -24,7 +24,9 @@ def extract(full_path, dest): def _get_path_within_zip(full_path): full_path = os.path.abspath(str(full_path)) - sub_file = full_path[len(ROOT) + 1 :] + prefix = ROOT + os.sep + assert full_path.startswith(prefix), f"full_path={full_path} should start with prefix={prefix}" + sub_file = full_path[len(prefix) :] if IS_WIN: # paths are always UNIX separators, even on Windows, though __file__ still follows platform default sub_file = sub_file.replace(os.sep, "/")