diff options
author | Andrew Kuchling <amk@amk.ca> | 2013-06-22 16:33:05 (GMT) |
---|---|---|
committer | Andrew Kuchling <amk@amk.ca> | 2013-06-22 16:33:05 (GMT) |
commit | aa6c297316a62baed42f10508cf21d781b0fbee4 (patch) | |
tree | 992a09204b27e988360e928a838056823d15684d /Lib/test/test_curses.py | |
parent | 22b4b4cef4a4ed290d4c4941674f4e472f6bc3dc (diff) | |
download | cpython-aa6c297316a62baed42f10508cf21d781b0fbee4.zip cpython-aa6c297316a62baed42f10508cf21d781b0fbee4.tar.gz cpython-aa6c297316a62baed42f10508cf21d781b0fbee4.tar.bz2 |
#18113: avoid segfault if Py_XDECREF triggers code that calls set_panel_userptr again
Problem noted & original patch by Serhiy Storchaka; I tweaked the patch a bit.
Diffstat (limited to 'Lib/test/test_curses.py')
-rw-r--r-- | Lib/test/test_curses.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py index 387a185..fcf9618 100644 --- a/Lib/test/test_curses.py +++ b/Lib/test/test_curses.py @@ -262,6 +262,14 @@ def test_userptr_memory_leak(stdscr): if sys.getrefcount(obj) != nrefs: raise RuntimeError, "set_userptr leaked references" +def test_userptr_segfault(stdscr): + panel = curses.panel.new_panel(stdscr) + class A: + def __del__(self): + panel.set_userptr(None) + panel.set_userptr(A()) + panel.set_userptr(None) + def test_resize_term(stdscr): if hasattr(curses, 'resizeterm'): lines, cols = curses.LINES, curses.COLS @@ -281,6 +289,7 @@ def main(stdscr): window_funcs(stdscr) test_userptr_without_set(stdscr) test_userptr_memory_leak(stdscr) + test_userptr_segfault(stdscr) test_resize_term(stdscr) test_issue6243(stdscr) finally: |