[New-bugs-announce] [issue31723] refleaks in zipimport when calling zipimporter.__init__() more than once

Oren Milman report at bugs.python.org
Sat Oct 7 11:27:27 EDT 2017


New submission from Oren Milman <orenmn at gmail.com>:

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?

----------
components: Extension Modules
messages: 303883
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: refleaks in zipimport when calling zipimporter.__init__() more than once
type: resource usage
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31723>
_______________________________________


More information about the New-bugs-announce mailing list