Skip to content

Commit 0ec7737

Browse files
committed
Fix pathlib.glob() for Python 3.14
- glob() defines another static method that has to be patched
1 parent 3c3b0b3 commit 0ec7737

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ The released versions correspond to PyPI releases.
1414
the real filesystem behavior
1515
* remove support for Python versions before 3.10 (if needed, patches may be backported to the 5.10.x branch)
1616

17+
### Fixes
18+
* fixed `pathlib.glob()` for Python 3.14 (see [#1239](../../issues/1239))
19+
1720
## [Version 5.10.1](https://pypi.python.org/pypi/pyfakefs/5.10.1) (2025-10-27)
1821
Fixes a regression introduced in version 5.9.0.
1922

pyfakefs/fake_filesystem_unittest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,8 @@ def _set_glob_os_functions(self):
11011101
globber.lstat = staticmethod(os.lstat)
11021102
if sys.version_info < (3, 14):
11031103
globber.scandir = staticmethod(os.scandir)
1104+
if sys.version_info >= (3, 14):
1105+
globber.lexists = staticmethod(os.path.lexists)
11041106

11051107
def patch_functions(self) -> None:
11061108
assert self._stubs is not None

pyfakefs/tests/fake_pathlib_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,13 @@ def test_glob(self):
988988
sorted(path.glob("*.py")),
989989
)
990990

991+
def test_glob_dir(self):
992+
# regression test for #1239
993+
root_dir = self.path(self.make_path("root"))
994+
test_file = self.make_path(root_dir, "foo", "bar.txt")
995+
self.create_file(test_file)
996+
self.assertEqual([root_dir / "foo"], list(root_dir.glob("foo")))
997+
991998
def test_glob_case_windows(self):
992999
self.check_windows_only()
9931000
self.create_file(self.make_path("foo", "setup.py"))

0 commit comments

Comments
 (0)