Skip to content

Keep OS errors and match Python OSError text for atomic writes and state locks - #78

Closed
HaoZeke wants to merge 6 commits into
mainfrom
fix/zc75r2-oserror
Closed

HaoZeke wants to merge 6 commits into
mainfrom
fix/zc75r2-oserror

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Supersedes #75.

This keeps operating-system errors intact across the atomic-write and state-lock paths, and makes the reported text match Python's OSError.

  • Keep the system error when formatting a diagnostic runs out of memory, and use the static fallback message.
  • Preserve the current errno when a short write is synthesized, and stop probing a temporary path after it was renamed away.
  • Report the ancestor that the failing makedirs call received.
  • Populate osFailure for state-root preflight failures, with full joined paths on lock-file errors; non-OS lock refusals leave it empty.
  • Name the right file for a failed state lock open or pid write.
  • Name the temporary file, no file, or both files for a failed replacement, as Python does.

Each commit carries its own news fragment.

A failed open of the temporary file named the destination. A failed
write or flush named it as well, and a failed rename named only that
destination. Python names the temporary file, no file, or both files.
The message follows Python.
A failed open of .lock named the state root, and so did a failed pid
write. Python names .lock, .lock.posix, the directory, or no file.
The acquisition snapshots that text before a later close.
State-root preflight failures now populate osFailure. Lock-file errors carry their full joined paths, while non-operating-system lock refusals leave osFailure empty.
Recursive directory creation now carries the path passed to the system call that failed. Atomic writes and state locks use that ancestor in their OSError diagnostics.
Lock acquisition starts with a clean errno before synthesizing a short-write failure. Atomic replacement cleanup no longer probes a temporary path after that path has been renamed away.
Every allocation failure while formatting an OSError now keeps that system error and uses the static fallback message. Atomic-write callers deinitialize diagnostics after any failure.
@HaoZeke

HaoZeke commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #75.

@HaoZeke HaoZeke closed this Nov 20, 2026
@HaoZeke
HaoZeke deleted the fix/zc75r2-oserror branch November 20, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant