Skip to content

Preserve sparse character positions in spooled text writes - #667

Open
ShahadatTest wants to merge 1 commit into
mahmoud:masterfrom
ShahadatTest:fix/spooled-text-sparse-seeks
Open

ShahadatTest wants to merge 1 commit into
mahmoud:masterfrom
ShahadatTest:fix/spooled-text-sparse-seeks

Conversation

@ShahadatTest

Copy link
Copy Markdown

The change

Seeking beyond EOF in SpooledStringIO updates tell() but leaves the backing byte cursor at EOF. Writing then appends immediately instead of preserving the NUL gap expected from StringIO. Count actual characters traversed and, when EOF is reached early, seek over the remaining single-byte NUL positions.

All seven regression cases fail against the unchanged production source. Tests use StringIO as the content/cursor reference and cover absolute/current/end-relative seeks, UTF-8 text, memory/disk storage, an empty read after seeking, and a sparse write that triggers automatic rollover. Nonzero relative seeks are an existing SpooledStringIO extension; their reference destination is calculated as an absolute StringIO seek.

This changes sparse seek positioning, independently of #624's length-query read-ahead bug and #630's write-after-read-ahead alignment. Different-width UTF-8 overwrites remain outside this patch.

Validation on Windows:

  • Python 3.12 full unit suite and module doctests: 781 passed, 1 skipped, 22 subtests passed in 5.88s.
  • Python 3.10 focused regressions and affected module doctests: 10 passed in 0.09s.
  • New-test Flake8, basic source error checks, Python 3.7 syntax parsing and diff checks pass. Other interpreter/platform matrices were not run.

The backstory

Earlier contribution: #665. This was found during source inspection and controlled local probes; no personal application use or human review is claimed.

AI assistance

  • Harness/tooling: OpenAI Codex.
  • Model: GPT-6.
  • Original user prompt: new 20ta koro (make 20 new contributions). Codex investigated the bug, checked existing work and policies, implemented and tested the change, and prepared this PR.

This branch has not been deployed

No deployments
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