[New-bugs-announce] [issue42866] test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references
STINNER Victor
report at bugs.python.org
Fri Jan 8 04:28:39 EST 2021
New submission from STINNER Victor <vstinner at python.org>:
$ ./python -m test test_multibytecodec -m test.test_multibytecodec.Test_IncrementalEncoder.test_subinterp -R 3:3
(...)
test_multibytecodec leaked [258, 258, 258] references, sum=774
I simplified the code. The following test leaks references:
def test_subinterp(self):
import _testcapi
code = textwrap.dedent("""
import _codecs_jp
codec = _codecs_jp.getcodec('cp932')
codec = None
""")
_testcapi.run_in_subinterp(code)
_codecs_jp.getcodec() is defined in Modules/cjkcodecs/cjkcodecs.h. Extract:
cofunc = getmultibytecodec();
...
codecobj = PyCapsule_New((void *)codec, PyMultibyteCodec_CAPSULE_NAME, NULL);
if (codecobj == NULL)
return NULL;
r = PyObject_CallOneArg(cofunc, codecobj);
Py_DECREF(codecobj);
getmultibytecodec() is the _multibytecodec.__create_codec() which is defined in Modules/cjkcodecs/multibytecodec.c. Simplified code:
codec = PyCapsule_GetPointer(arg, PyMultibyteCodec_CAPSULE_NAME);
_multibytecodec_state *state = _multibytecodec_get_state(module);
self = PyObject_New(MultibyteCodecObject, state->multibytecodec_type);
self->codec = codec;
return (PyObject *)self;
----------
components: Library (Lib)
messages: 384643
nosy: vstinner
priority: normal
severity: normal
status: open
title: test test_multibytecodec: Test_IncrementalEncoder.test_subinterp() leaks references
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42866>
_______________________________________
More information about the New-bugs-announce
mailing list