#18113: Objects associated to a curses.panel object with set_userptr() were leaked.
Reported by Atsuo Ishimoto.
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index fa0d469..387a185 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -250,6 +250,18 @@
except curses.panel.error:
pass
+def test_userptr_memory_leak(stdscr):
+ w = curses.newwin(10, 10)
+ p = curses.panel.new_panel(w)
+ obj = object()
+ nrefs = sys.getrefcount(obj)
+ for i in range(100):
+ p.set_userptr(obj)
+
+ p.set_userptr(None)
+ if sys.getrefcount(obj) != nrefs:
+ raise RuntimeError, "set_userptr leaked references"
+
def test_resize_term(stdscr):
if hasattr(curses, 'resizeterm'):
lines, cols = curses.LINES, curses.COLS
@@ -268,6 +280,7 @@
module_funcs(stdscr)
window_funcs(stdscr)
test_userptr_without_set(stdscr)
+ test_userptr_memory_leak(stdscr)
test_resize_term(stdscr)
test_issue6243(stdscr)
finally: