Skip to content

Commit

Permalink
Add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbean-bremen committed Aug 12, 2024
1 parent 3e8d07e commit 853d07c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyfakefs/fake_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,22 +596,25 @@ def remove_entry(self, pathname_name: str, recursive: bool = True) -> None:
self.filesystem.raise_os_error(errno.EACCES, pathname_name)
if self.filesystem.has_open_file(entry):
raise_error = True
st: List[traceback.FrameSummary] = []
if os.name == "posix" and not hasattr(os, "O_TMPFILE"):
# special handling for emulating Windows under macOS and PyPi
# tempfile uses unlink based on the real OS while deleting
# a temporary file, so we ignore that error in this specific case
st = traceback.extract_stack(limit=6)
if sys.version_info < (3, 10):
if (
st[1].name == "TemporaryFile"
and st[1].line == "_os.unlink(name)"
st[0].name == "TemporaryFile"
and st[0].line == "_os.unlink(name)"
):
raise_error = False
else:
# TemporaryFile implementation has changed in Python 3.10
if st[0].name == "opener" and st[0].line == "_os.unlink(name)":
raise_error = False
if raise_error:
for f in st:
print(f"{f.name=}, {f.line=}")
self.filesystem.raise_os_error(errno.EACCES, pathname_name)
else:
if not helpers.is_root() and not self.has_permission(
Expand Down

0 comments on commit 853d07c

Please sign in to comment.