From 54b1b3d17a74746b868e5f54eee6c08d895674f9 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 14 Jun 2026 18:10:41 +0200 Subject: [PATCH] conftest: fix rmtree cleanup crash on Linux (os.lchflags does not exist) The archiver fixture's rmtree onerror handler called os.lchflags(path, 0) when has_lchflags was True. But has_lchflags is also True on Linux (flags are cleared via ioctl there), where os.lchflags does not exist, raising an uncaught AttributeError and turning teardown into an ERROR. Use borg's cross-platform platform.set_flags instead. Co-Authored-By: Claude Opus 4.8 --- src/borg/conftest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/borg/conftest.py b/src/borg/conftest.py index c76cfcf626..981d288049 100644 --- a/src/borg/conftest.py +++ b/src/borg/conftest.py @@ -15,6 +15,7 @@ setup_logging() from borg.archiver import Archiver # noqa: E402 +from borg.platform import set_flags # noqa: E402 from borg.testsuite import has_lchflags, has_llfuse, has_pyfuse3, has_mfusepy # noqa: E402 from borg.testsuite import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported # noqa: E402 from borg.testsuite.archiver import BORG_EXES @@ -196,8 +197,10 @@ def archiver(tmp_path, set_env_variables): def maybe_clear_flags_and_retry(func, path, _exc_info): if has_lchflags: # Clear any BSD flags (e.g. UF_APPEND) that may have prevented removal, then retry once. + # Note: use borg's cross-platform set_flags, not os.lchflags - the latter does not exist + # on Linux even though has_lchflags is True there (Linux clears flags via ioctl). try: - os.lchflags(path, 0) + set_flags(path, 0) func(path) except OSError: pass