From 853d07cd95b1a625fc7facdb8450ab41739bf2f9 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Mon, 12 Aug 2024 19:39:00 +0200 Subject: [PATCH] Add debug info --- pyfakefs/fake_file.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfakefs/fake_file.py b/pyfakefs/fake_file.py index 200014c9..7a583ca8 100644 --- a/pyfakefs/fake_file.py +++ b/pyfakefs/fake_file.py @@ -596,6 +596,7 @@ 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 @@ -603,8 +604,8 @@ def remove_entry(self, pathname_name: str, recursive: bool = True) -> None: 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: @@ -612,6 +613,8 @@ def remove_entry(self, pathname_name: str, recursive: bool = True) -> None: 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(