[issue19878] bz2.BZ2File.__init__() cannot be called twice

STINNER Victor report at bugs.python.org
Tue Dec 3 22:01:56 CET 2013


STINNER Victor added the comment:

I can reproduce the issue with Python 2.7. The problem is that BZ2File.__init__() doesn't reset the object when __init__() is called twice.

For example, the following script fails with "too many open files" error, before the previous file is not called:
---
import bz2
obj = bz2.BZ2File('bla.bz2')
for loop in range(1024*10):
    obj.__init__('bla.bz2')
---

By the way, why do you call __init__() twice? Why not creating a new object?

BZ2File was rewritten in pure Python in Python 3.3. Python 3.3+ is not affected by this issue.

----------
nosy: +haypo, serhiy.storchaka
resolution: rejected -> 
stage: committed/rejected -> 
status: closed -> open
title: PyFile_DecUseCount() SIGSEGV -> bz2.BZ2File.__init__() cannot be called twice
versions: +Python 2.7 -Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19878>
_______________________________________


More information about the Python-bugs-list mailing list