New submission from STINNER Victor <vstin...@python.org>:
In bpo-1635741, many C extension modules were ported to the new PEP 489 multiphase initialization. Some of these changes suddenly make old bugs visible. I mean that bugs were there for years, but nobody noticed them previously. * _weakref in importlib: bpo-40050 (commit 83d46e0622d2efdf5f3bf8bf8904d0dcb55fc322) * leak in _testcapi: commit 310e2d25170a88ef03f6fd31efcc899fe062da2c (bpo-36854) * Reference leak in select: bpo-32604 (commit 18a90248fdd92b27098cc4db773686a2d10a4d24) * test_threading vs the garbage collector: bpo-40217 "The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type"... This issue has a controversial history... Read bpo-40217 discussion. * etc. The problem is that these issues are discovered afterwards, usually when "Refleaks" buildbots complete. I propose to add a new test case to test_interpreters which would run "import xxx" in _testcapi.run_in_subinterp() on the 34 C extensions already ported to PyModuleDef_Init(): $ grep -l PyModuleDef_Init Modules/*.c Modules/_abc.c Modules/arraymodule.c Modules/atexitmodule.c Modules/audioop.c Modules/binascii.c Modules/_bz2module.c Modules/_codecsmodule.c Modules/_collectionsmodule.c Modules/_contextvarsmodule.c Modules/_cryptmodule.c Modules/errnomodule.c Modules/fcntlmodule.c Modules/_functoolsmodule.c Modules/_heapqmodule.c Modules/itertoolsmodule.c Modules/_json.c Modules/_localemodule.c Modules/mathmodule.c Modules/mmapmodule.c Modules/nismodule.c Modules/_operator.c Modules/posixmodule.c Modules/resource.c Modules/_stat.c Modules/_statisticsmodule.c Modules/syslogmodule.c Modules/_testmultiphase.c Modules/timemodule.c Modules/_uuidmodule.c Modules/_weakref.c Modules/xxlimited.c Modules/xxmodule.c Modules/xxsubtype.c Modules/_zoneinfo.c The test case should explain the purpose of these tests: * ensure that the import doesn't crash * help to discover reference leaks when running "python -m test test_interpreters -R 3:3" Maybe later we could elaborate these tests to ensure that the sub interpreter module is unrelated to the module in the main interpreter. For example, add a specific attribute in the subinterpreter, and then check that it doesn't exist in the main interpreter. But I'm not sure if it's a good idea to import 34 modules in test_interpreters. ---------- components: Tests messages: 371568 nosy: corona10, vstinner priority: normal severity: normal status: open title: Add tests to test_interpreters to import C extension modules converted to PEP 489 multiphase initialization versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40987> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com