Title: ValueError: I/O operation on closed file. in ZipFile destructor
Type: crash Stage:
Components: Versions: Python 3.9, Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: joernheissler, pitrou, serhiy.storchaka, xtreak
Priority: normal Keywords: 3.8regression

Created on 2019-08-06 09:35 by joernheissler, last changed 2019-08-06 10:51 by serhiy.storchaka.

Messages (2)
msg349104 - (view) Author: Jörn Heissler (joernheissler) * Date: 2019-08-06 09:35
When running this code:

from zipfile import ZipFile
import io

def foo():

data = io.BytesIO()
zf = ZipFile(data, "w")

I get this message:

Exception ignored in: <function ZipFile.__del__ at 0x7f9005caa160>
Traceback (most recent call last):
  File "/home/user/git/oss/cpython/Lib/", line 1800, in __del__
  File "/home/user/git/oss/cpython/Lib/", line 1817, in close
ValueError: I/O operation on closed file.

Comment out def foo: pass, and there is no error.

It looks like the bug was introduced with commit ada319bb6d0ebcc68d3e0ef2b4279ea061877ac8 (bpo-32388).
msg349105 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-08-06 09:41
This looks like a regression in 3.8 so I have added 3.8 regression tag.
Date User Action Args
2019-08-06 10:51:16serhiy.storchakasetnosy: + serhiy.storchaka
2019-08-06 09:41:22xtreaksetkeywords: + 3.8regression
nosy: + xtreak
messages: + msg349105

2019-08-06 09:35:50joernheisslercreate