From 6b28a7b96f3b63a8d4238f936a43248485eb47a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=9D=A8=E5=B8=86?= <39647285+leno23@users.noreply.github.com> Date: Mon, 18 May 2026 00:10:39 +0800 Subject: [PATCH] fix: avoid splitting .zipx paths as zip files --- pydevd_file_utils.py | 3 +++ tests_python/test_pydevd_file_utils.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests_python/test_pydevd_file_utils.py diff --git a/pydevd_file_utils.py b/pydevd_file_utils.py index 92919c4f..e562308d 100644 --- a/pydevd_file_utils.py +++ b/pydevd_file_utils.py @@ -503,6 +503,9 @@ def _apply_func_and_normalize_case(filename, func, isabs, normalize_case, os_pat ind += 4 zip_path = r[:ind] inner_path = r[ind:] + if inner_path and not inner_path.startswith(("!", "/", "\\")): + # Keep paths such as ".zipx/main.py" as regular filesystem paths. + inner_path = "" if inner_path.startswith("!"): # Note (fabioz): although I can replicate this by creating a file ending as # .zip! or .egg!, I don't really know what's the real-world case for this diff --git a/tests_python/test_pydevd_file_utils.py b/tests_python/test_pydevd_file_utils.py new file mode 100644 index 00000000..05d384e8 --- /dev/null +++ b/tests_python/test_pydevd_file_utils.py @@ -0,0 +1,12 @@ +import os + +import pydevd_file_utils + + +def test_normalize_case_does_not_split_dot_zipx_directory(tmpdir): + zipx_dir = tmpdir.mkdir(".zipx") + filename = str(zipx_dir.join("main.py")) + zipx_dir.join("main.py").write("print('ok')\n") + + expected = os.path.abspath(filename) + assert pydevd_file_utils._apply_func_and_normalize_case(filename, os.path.abspath, True, False) == expected