Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

snapshot(fix): Reject attribute deletion - #207

Merged
tony merged 1 commit into
masterfrom
fix/198-snapshot-delattr
Dec 5, 2026
Merged

tony merged 1 commit into
masterfrom
fix/198-snapshot-delattr

Conversation

@tony

@tony tony commented Dec 5, 2026

Copy link
Copy Markdown
Member

Fixes #198

Summary

  • Aligns Snapshot in src/libvt/snapshot.py with sibling SyncToken: removes the _frozen slot bypass, initializes all 22 slots via object.__setattr__ in _make_snapshot, and defines both __setattr__ -> t.NoReturn and __delattr__ -> t.NoReturn raising AttributeError.
  • Prevents del frame.cursor (or any other slot/attribute deletion) from corrupting cached Terminal.committed / Terminal.snapshot() frames returned to subsequent callers, and surfaces invalid assignment/deletion statically in ty.
  • Adds regression tests in tests/test_terminal.py (literal serialized frames, all Snapshot.__slots__ + properties, ?2026 held/committed & CoW isolation, Screen.snapshot(), SyncToken, ScreenDelta) and tests/test_screen.py (ephemeral view immutability + copy/pickle), plus a CHANGES entry under 0.0.1a7.

Verification

  • Ruff, ty (3.12–3.15 + win32 3.12, valid calls + invalid-assignment misuse), pytest (1237 passed, 2 skipped including doctests), Sphinx dirhtml -W (0 warnings).
  • Independent staff review verdict: adopt as is (Gates 1–4 PASS, new code 9.7/10, all applicable items 9.5–9.8/10).

why: Snapshot guarded attribute assignment via __setattr__ without a
matching __delattr__, letting callers delete slotted fields like cursor
or _frozen from a cached Terminal.committed frame and corrupting reads
for subsequent consumers.

what:
- Add Snapshot.__delattr__ and type __setattr__/__delattr__ as NoReturn
- Initialize Snapshot slots via object.__setattr__ and drop _frozen
- Add regression tests for cached, ?2026-held, and sibling views
- Record the fix in CHANGES under 0.0.1a7

Fixes #198
@tony
tony merged commit 84a5a21 into master Dec 5, 2026
9 checks passed
@tony
tony deleted the fix/198-snapshot-delattr branch December 5, 2026 16:39

This branch was successfully deployed

1 active deployment
docs — cf713dc6 Deployed Dec 5, 2026 by tony via build (3.14) #503
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.

Deleting a snapshot attribute damages the cached committed frame

1 participant