Skip to content

test.support.os_helper.rmtree() does not clear BSD file flags #154308

Description

@serhiy-storchaka

On BSD systems a test may leave behind files or directories with flags such as UF_IMMUTABLE or UF_NOUNLINK set, which prevent the directory from being modified or removed. os_helper.rmtree() retries with os.chmod() but never clears the flags with os.chflags(), so it fails to remove such content.

This surfaced as a regrtest WORKER BUG on DragonFly: test_tempfile left UF_NOUNLINK-flagged directories in the worker's temporary directory (gh-154307), and the worker's os_helper.rmtree() cleanup then crashed with PermissionError, killing the workers and aborting the run.

os_helper.rmtree() should clear file flags before removing.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixestestsTests in the Lib/test dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions