Skip to content

[mypyc] Fix reference leaks on vecs module initialization failure - #22246

Merged
p-sawicki merged 2 commits into
python:masterfrom
p-sawicki:librt_vecs-release-init-temps
Oct 21, 2026
Merged

p-sawicki merged 2 commits into
python:masterfrom
p-sawicki:librt_vecs-release-init-temps

Conversation

@p-sawicki

Copy link
Copy Markdown
Collaborator

Add decrefs for temporaries that would leak on initialization failure.

Remove decref of VecType after it's been successfully added to the module because that steals it.

assert v == vec[u8]([1, 2, 1, 2, 3])
assert new == vec[u8]([1, 2, 3])

[case testLibrtVecsFailedImportOwnership_librt]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is testing such a niche use case that I don't think it's worth it have an expensive run test for it. I think you can just remove the test -- the test has already served its purpose and shown that the fix works.

@p-sawicki
p-sawicki merged commit c66551d into python:master Oct 21, 2026
18 checks passed
@p-sawicki
p-sawicki deleted the librt_vecs-release-init-temps branch October 21, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants