Skip to content

Commit b31b8e0

Browse files
committed
Fix handling of strict argument in Python 3.9.23
- had been backported together with ALLOW_MISSING -
1 parent b722bcc commit b31b8e0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGES.md

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

16+
## Unreleased
17+
18+
### Fixes
19+
* fixed handling of added `strict` argument in Python 3.9.23
20+
1621
## [Version 5.9.0](https://pypi.python.org/pypi/pyfakefs/5.8.0) (2025-06-21)
1722
Adds support for an API change in latest Python patch releases.
1823

pyfakefs/fake_path.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,11 @@ def realpath(self, filename: AnyStr, strict: Optional[bool] = None) -> AnyStr:
359359
"""Return the canonical path of the specified filename, eliminating any
360360
symbolic links encountered in the path.
361361
"""
362-
if strict is not None and sys.version_info < (3, 10):
363-
raise TypeError("realpath() got an unexpected keyword argument 'strict'")
364362
has_allow_missing = hasattr(os.path, "ALLOW_MISSING")
363+
# the strict argument was backported to Python 3.9.23
364+
# together with support for os.path.ALLOW_MISSING
365+
if strict is not None and sys.version_info < (3, 10) and not has_allow_missing:
366+
raise TypeError("realpath() got an unexpected keyword argument 'strict'")
365367
if has_allow_missing and strict == os.path.ALLOW_MISSING: # type: ignore[attr-defined]
366368
# ignores non-existing file, but not other errors
367369
ignored_error: Any = FileNotFoundError

0 commit comments

Comments
 (0)