Skip to content

Refleak when some "internal modules" are imported multiple times. #107789

Description

@Eclips4

Originally taken from #107577.

importsysimportimportlibdeffoo():
name="_socket"importlib.import_module(name)
sys.modules.pop(name)
for_inrange(4):
foo()
./python.exe-Xshowrefcountexample.py
[1025refs, 653blocks]

Same with _decimal.

### Tasks
- [ ] https://github.com/python/cpython/pull/108241

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions