Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Eclips4 opened this issue Aug 8, 2023 · 3 comments
Closed

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

Eclips4 opened this issue Aug 8, 2023 · 3 comments
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Aug 8, 2023

Originally taken from #107577.

import sys
import importlib

def foo():
    name = "_socket"
    importlib.import_module(name)
    sys.modules.pop(name)


for _ in range(4):
    foo()

./python.exe -X showrefcount example.py
[1025 refs, 653 blocks]

Same with _decimal.

### Tasks
- [ ] https://github.com/python/cpython/pull/108241
@Eclips4 Eclips4 added the type-bug An unexpected behavior, bug, or error label Aug 8, 2023
@Eclips4
Copy link
Member Author

Eclips4 commented Aug 8, 2023

сс @kumaraditya303

@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Aug 8, 2023
@Eclips4 Eclips4 added extension-modules C modules in the Modules dir and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 21, 2023
@Eclips4
Copy link
Member Author

Eclips4 commented Aug 21, 2023

Related: #108240

@vstinner
Copy link
Member

vstinner commented Aug 21, 2023

I close this issue as a duplicate of issue #108240 which more complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants