window.insnstr(str, n, attr) sets the window rendition before the write, and when that fails it never releases the bytes object it converted its argument to, so every failing call leaks one reference. addstr(), addnstr() and insstr() got that release in GH-145609 (gh-145376); insnstr() was missed.
A window detached by screen.close() makes the rendition call fail:
Activity
gh-156953: Fix a reference leak in curses window.insnstr() (GH-156954)
pythongh-156953: Fix a reference leak in curses window.insnstr() (pyt…
[3.15] gh-156953: Fix a reference leak in curses window.insnstr() (GH…