Mercurial > cpython-lru_cache-weakref
changeset 84153:fcb686e720ff
Merge with 3.3
| author | Andrew Kuchling <amk@amk.ca> |
|---|---|
| date | Sat, 15 Jun 2013 15:10:08 -0400 |
| parents | 1e141c2cc0d7 (current diff) 3d75bd69e5a9 (diff) |
| children | bc18b5d4920e |
| files | Misc/NEWS |
| diffstat | 3 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/test/test_curses.py Sat Jun 15 14:32:11 2013 -0400 +++ b/Lib/test/test_curses.py Sat Jun 15 15:10:08 2013 -0400 @@ -252,6 +252,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 @@ -317,6 +329,7 @@ module_funcs(stdscr) window_funcs(stdscr) test_userptr_without_set(stdscr) + test_userptr_memory_leak(stdscr) test_resize_term(stdscr) test_issue6243(stdscr) test_unget_wch(stdscr)
--- a/Misc/NEWS Sat Jun 15 14:32:11 2013 -0400 +++ b/Misc/NEWS Sat Jun 15 15:10:08 2013 -0400 @@ -383,6 +383,9 @@ the default for linking if LDSHARED is not also overriden. This restores Distutils behavior introduced in 3.2.3 and inadvertently dropped in 3.3.0. +- Issue #18113: Fixed a refcount leak in the curses.panel module's + set_userptr() method. Reported by Atsuo Ishimoto. + - Implement PEP 443 "Single-dispatch generic functions". - Implement PEP 435 "Adding an Enum type to the Python standard library".
--- a/Modules/_curses_panel.c Sat Jun 15 14:32:11 2013 -0400 +++ b/Modules/_curses_panel.c Sat Jun 15 15:10:08 2013 -0400 @@ -322,6 +322,10 @@ static PyObject * PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj) { + PyObject *oldobj; + PyCursesInitialised; + oldobj = (PyObject *) panel_userptr(self->pan); + Py_XDECREF(oldobj); Py_INCREF(obj); return PyCursesCheckERR(set_panel_userptr(self->pan, (void*)obj), "set_panel_userptr");
