Skip to content

Commit b94fef9

Browse files
committed
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.
1 parent fba5dde commit b94fef9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_pathlib/test_pathlib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2954,7 +2954,12 @@ def test_glob_dotdot(self):
29542954
else:
29552955
# ".." segments are normalized first on Windows, so this path is stat()able.
29562956
self.assertEqual(set(p.glob("xyzzy/..")), { P(self.base, "xyzzy", "..") })
2957-
self.assertEqual(set(p.glob("/".join([".."] * 50))), { P(self.base, *[".."] * 50)})
2957+
if sys.platform == "emscripten":
2958+
# Emscripten will return ELOOP if there are 49 or more ..'s.
2959+
NDOTDOTS = 48
2960+
else:
2961+
NDOTDOTS = 50
2962+
self.assertEqual(set(p.glob("/".join([".."] * NDOTDOTS))), { P(self.base, *[".."] * NDOTDOTS)})
29582963

29592964
def test_glob_inaccessible(self):
29602965
P = self.cls

0 commit comments

Comments
 (0)