[PR #866] [CLOSED] spirv_stubs: restore write mode before remove on replace failure and publish mode (SPIRV-STUBS-STAGE-CLEANUP) #904

Closed
opened 2026-11-26 20:19:26 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/866
Author: @trigger337
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: fix/spirv-stubs-stage-cleanup


📝 Commits (1)

  • 612e1d1 spirv_stubs: restore write mode before remove on replace failure and publish mode (SPIRV-STUBS-STAGE-CLEANUP)

📊 Changes

2 files changed (+27 additions, -5 deletions)

View changed files

📝 tests/test_spirv_stubs.py (+19 -0)
📝 tools/spirv_stubs.py (+8 -5)

📄 Description

Overview

In tools/spirv_stubs.py, apply published_mode(target) to the staged temporary stub before atomic replacement (replacing the POSIX-only shutil.copymode), and ensure write mode (0o600) is restored before removing in the exception block if replacement fails.

On Windows, unlinking/removing a read-only staged file or cleaning up on os.replace failure causes a PermissionError [WinError 5], leaving stranded temporary files behind.

Changes

  1. tools/spirv_stubs.py: Import published_mode, apply it to staged before replacement, and restore write mode before os.remove in except BaseException:.
  2. tests/test_spirv_stubs.py: Add test_stage_cleanup_restores_write_mode_on_replace_failure asserting write mode restoration on replace failure.

agent: yes
AI-assisted: yes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/866 **Author:** [@trigger337](https://github.com/trigger337) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/spirv-stubs-stage-cleanup` --- ### 📝 Commits (1) - [`612e1d1`](https://github.com/ubiquitarianism/leonida/commit/612e1d15c716a1978f2613a3465e09121b2c466a) spirv_stubs: restore write mode before remove on replace failure and publish mode (SPIRV-STUBS-STAGE-CLEANUP) ### 📊 Changes **2 files changed** (+27 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_spirv_stubs.py` (+19 -0) 📝 `tools/spirv_stubs.py` (+8 -5) </details> ### 📄 Description ### Overview In `tools/spirv_stubs.py`, apply `published_mode(target)` to the staged temporary stub before atomic replacement (replacing the POSIX-only `shutil.copymode`), and ensure write mode (`0o600`) is restored before removing in the exception block if replacement fails. On Windows, unlinking/removing a read-only staged file or cleaning up on `os.replace` failure causes a `PermissionError` [WinError 5], leaving stranded temporary files behind. ### Changes 1. `tools/spirv_stubs.py`: Import `published_mode`, apply it to `staged` before replacement, and restore write mode before `os.remove` in `except BaseException:`. 2. `tests/test_spirv_stubs.py`: Add `test_stage_cleanup_restores_write_mode_on_replace_failure` asserting write mode restoration on replace failure. agent: yes AI-assisted: yes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:26 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#904
No description provided.