Skip to content

[3.14] gh-162246: Fix leak when re-initializing BufferedRWPair (GH-162405) - #162458

Merged
cmaloney merged 2 commits into
python:3.14from
cmaloney:backport-5257a3d-3.14
Nov 22, 2026
Merged

cmaloney merged 2 commits into
python:3.14from
cmaloney:backport-5257a3d-3.14

Conversation

@cmaloney

@cmaloney cmaloney commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Calling BufferedRWPair.__init__() on an already initialized object overwrote the reader and writer pointers without releasing the previous objects. Build the new reader and writer first, then swap them in, releasing the old writer before the old reader as in bufferedrwpair_clear().

Make the Python implementation release the old writer before the old reader too, so pending writes are not lost when both share a raw stream. (cherry picked from commit 5257a3d)

pythonGH-162405)

Calling `BufferedRWPair.__init__()` on an already initialized object
overwrote the reader and writer pointers without releasing the previous
objects. Build the new reader and writer first, then swap them in,
releasing the old writer before the old reader as in
`bufferedrwpair_clear()`.

Make the Python implementation release the old writer before the old
reader too, so pending writes are not lost when both share a raw stream.
(cherry picked from commit 5257a3d)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@cmaloney

Copy link
Copy Markdown
Contributor Author

Backport GH-162459 will fix the bots (that is already on 3.15 and main)

@cmaloney
cmaloney merged commit b2c1367 into python:3.14 Nov 22, 2026
49 checks passed
@cmaloney
cmaloney deleted the backport-5257a3d-3.14 branch November 22, 2026 22:12
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