gh-162246: Fix leak when re-initializing `BufferedRWPair` (#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.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed