From b94fef9ddf0ccb10333ed6f92156a9ef3735cf5f Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 17 Jun 2025 09:29:15 -0700 Subject: [PATCH 1/2] gh-127146: Emscripten: Fix pathlib glob_dotdot test The Emscripten path resolver uses the same mechanism for resolving .. at a file system root as for resolving symlinks. This is because roots don't store their mountpoints. If the parent of a node is itself, it is a root but it might be a mountpoint in some other file system. Anyways, if a path has enough ..'s at the root, it will return ELOOP. Enough turns out to be 49. --- Lib/test/test_pathlib/test_pathlib.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 13356b4cfe082b..7de3ba28e06aa0 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -2954,7 +2954,12 @@ def test_glob_dotdot(self): else: # ".." segments are normalized first on Windows, so this path is stat()able. self.assertEqual(set(p.glob("xyzzy/..")), { P(self.base, "xyzzy", "..") }) - self.assertEqual(set(p.glob("/".join([".."] * 50))), { P(self.base, *[".."] * 50)}) + if sys.platform == "emscripten": + # Emscripten will return ELOOP if there are 49 or more ..'s. + NDOTDOTS = 48 + else: + NDOTDOTS = 50 + self.assertEqual(set(p.glob("/".join([".."] * NDOTDOTS))), { P(self.base, *[".."] * NDOTDOTS)}) def test_glob_inaccessible(self): P = self.cls From e6c9ce3d9cf1c90812a4061b7dd064985004ad09 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 17 Jun 2025 10:05:32 -0700 Subject: [PATCH 2/2] Add link to fix --- Lib/test/test_pathlib/test_pathlib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_pathlib/test_pathlib.py b/Lib/test/test_pathlib/test_pathlib.py index 7de3ba28e06aa0..b2e2cdb3338beb 100644 --- a/Lib/test/test_pathlib/test_pathlib.py +++ b/Lib/test/test_pathlib/test_pathlib.py @@ -2956,6 +2956,7 @@ def test_glob_dotdot(self): self.assertEqual(set(p.glob("xyzzy/..")), { P(self.base, "xyzzy", "..") }) if sys.platform == "emscripten": # Emscripten will return ELOOP if there are 49 or more ..'s. + # Can remove when https://github.com/emscripten-core/emscripten/pull/24591 is merged. NDOTDOTS = 48 else: NDOTDOTS = 50