Skip to content

Commit 05f134b

Browse files
committed
Adapt error codes to match newer Windows 11 behavior
- for some OSError exceptions, errno has changed
1 parent 8b484cf commit 05f134b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The released versions correspond to PyPI releases.
1717

1818
## Fixes
1919
* fixes patching of Debian-specific `tempfile` in Python 3.13 (see [#1214](../../issues/1214))
20-
* adapted some error codes for `OSError` to match Windows 11 behavior
20+
* adapted some error codes for `OSError` to match Windows 11/Windows Server 2025 behavior
2121

2222
## [Version 5.9.3](https://pypi.python.org/pypi/pyfakefs/5.9.3) (2025-08-28)
2323
Fixes a utility method.

pyfakefs/fake_filesystem.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ def _rename_to_existing_path(
20732073
new_object = self._get_object(new_file_path)
20742074
if old_file_path == new_file_path:
20752075
if not S_ISLNK(new_object.st_mode) and ends_with_sep:
2076-
error = errno.EINVAL if self.is_windows_fs else errno.ENOTDIR
2076+
error = errno.ENOTDIR if self.is_windows_fs else errno.ENOTDIR
20772077
self.raise_os_error(error, old_file_path)
20782078
return None # Nothing to do here
20792079

@@ -3113,7 +3113,9 @@ def remove(self, path: AnyStr) -> None:
31133113
self.raise_os_error(error, norm_path)
31143114

31153115
if path.endswith(self.get_path_separator(path)):
3116-
if self.is_macos:
3116+
if self.is_windows_fs:
3117+
error = errno.EACCES
3118+
elif self.is_macos:
31173119
error = errno.EPERM
31183120
else:
31193121
error = errno.ENOTDIR

0 commit comments

Comments
 (0)