The following code causes refleaks: import zipimport zi = zipimport.zipimporter.__new__(zipimport.zipimporter) zi.__init__('bar.zip') zi.__init__('bar.zip') zi.__init__('bar.zip\\foo') This is because zipimport_zipimporter___init___impl() (in Modules/zipimport.c) doesn't decref (if needed) before assigning to `self->files`, `self->archive` and `self->prefix`. I would open a PR to fix this soon. Should i add a test to test_zipimport? If yes, could you point out some similar refcount test to help me write this test?
> The following code causes refleaks: I'm curious, how did you find this code? Are you using a code generator coupled with a tool to track for reference leaks?
I merged your PR, thanks! As I wrote on the PR: I don't think that a NEWS entry is needed, since you are not supposed to call __init__() multiple times. I don't think that it's worth it to backport the fix to Python 2.7 and 3.6. So I close the issue.
> I'm curious, how did you find this code? Are you using a code generator coupled with a tool to track for reference leaks? Oh, I think that the issue is related to bpo-31718.