diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-12-15 17:21:23 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-12-15 17:21:23 +0100 |
commit | 3d3f264849580ab1e8f3a8e8e8ba402bfe2c6523 (patch) | |
tree | ffaff02924ed14efdc077f7385e98da21e33f9d4 /Modules/_testcapimodule.c | |
parent | 8320193d106c63445e8186d9f8c9455ba931150d (diff) | |
download | cpython-git-3d3f264849580ab1e8f3a8e8e8ba402bfe2c6523.tar.gz |
Fix a memory leak in split-table dictionaries
Issue #28147: Fix a memory leak in split-table dictionaries: setattr() must not
convert combined table into split table.
Patch written by INADA Naoki.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index ecfc0858c1..f09205f63c 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -259,6 +259,19 @@ dict_getitem_knownhash(PyObject *self, PyObject *args) return result; } +static PyObject* +dict_hassplittable(PyObject *self, PyObject *arg) +{ + if (!PyDict_Check(arg)) { + PyErr_Format(PyExc_TypeError, + "dict_hassplittable() argument must be dict, not '%s'", + arg->ob_type->tp_name); + return NULL; + } + + return PyBool_FromLong(_PyDict_HasSplitTable((PyDictObject*)arg)); +} + /* Issue #4701: Check that PyObject_Hash implicitly calls * PyType_Ready if it hasn't already been called */ @@ -4024,6 +4037,7 @@ static PyMethodDef TestMethods[] = { {"test_list_api", (PyCFunction)test_list_api, METH_NOARGS}, {"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS}, {"dict_getitem_knownhash", dict_getitem_knownhash, METH_VARARGS}, + {"dict_hassplittable", dict_hassplittable, METH_O}, {"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS}, {"test_long_api", (PyCFunction)test_long_api, METH_NOARGS}, {"test_xincref_doesnt_leak",(PyCFunction)test_xincref_doesnt_leak, METH_NOARGS}, |