mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix memory leaks in test_capi (#98017)
This commit is contained in:
parent
f99bb20cde
commit
be4099e55d
2 changed files with 6 additions and 0 deletions
|
@ -1495,6 +1495,9 @@ class TestDictWatchers(unittest.TestCase):
|
|||
unraisable = unraisables[0]
|
||||
self.assertIs(unraisable.object, d)
|
||||
self.assertEqual(str(unraisable.exc_value), "boom!")
|
||||
# avoid leaking reference cycles
|
||||
del unraisable
|
||||
del unraisables
|
||||
|
||||
def test_two_watchers(self):
|
||||
d1 = {}
|
||||
|
|
|
@ -5210,6 +5210,7 @@ dict_watch_callback(PyDict_WatchEvent event,
|
|||
Py_DECREF(msg);
|
||||
return -1;
|
||||
}
|
||||
Py_DECREF(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5224,8 +5225,10 @@ dict_watch_callback_second(PyDict_WatchEvent event,
|
|||
return -1;
|
||||
}
|
||||
if (PyList_Append(g_dict_watch_events, msg) < 0) {
|
||||
Py_DECREF(msg);
|
||||
return -1;
|
||||
}
|
||||
Py_DECREF(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue