Skip to content

tempfile.TemporaryDirectory cleanup fails on DragonFly BSD for files with UF_NOUNLINK #154307

Closed

Description

@serhiy-storchaka

On DragonFly BSD, TemporaryDirectory.cleanup() fails to remove a directory containing files or directories with the UF_NOUNLINK flag set (as exercised by test.test_tempfile...test_cleanup_with_symlink_flags).

Unlike FreeBSD, DragonFly's unlink() on a UF_NOUNLINK file fails with EISDIR (IsADirectoryError) instead of EPERM. The cleanup's onexc handler only resets flags for PermissionError, so the IsADirectoryError propagates and the flags are never cleared:

IsADirectoryError: [Errno 21] Is a directory: '.../test0.txt'

Handling IsADirectoryError the same way as PermissionError fixes it. Related: gh-91133.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Jul 20, 2026
  2. added 4 commits that reference this issue on Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixes3.14bugs and security fixes3.15bugs and security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions