New submission from STINNER Victor <[email protected]>:
$ ./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 <[email protected]>
<https://bugs.python.org/issue42866>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com