Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
pd.read_csv('2022_01_k.zip')
# ValueError: Multiple files found in ZIP file. Only one file per ZIP: ['k_d_01_2022.csv', 'k_d_t_01_2022.csv']
Issue Description
Handle to 2022_01_k.zip is left open after failed read attempt (resource leak).
Expected Behavior
Handle to file 2022_01_k.zip is closed. File can be renamed/deleted on Windows.
Installed Versions
Comment From: jsjeon-um
take
Comment From: twoertwein
@jsjeon-um Feel free to ping me if you have questions or when you have a PR!
Comment From: abeltavares
@jsjeon-um are you still working on it? can i take it?
Comment From: tev-dixon
I'll take this.
Comment From: tev-dixon
I was not able to recreate this bug. I tried on both Windows 10/11 and Linux systems with multiple zip files. Looking over the relevant code, I didn't see anything glaringly incorrect. Can anyone else reproduce this?
Comment From: twoertwein
I was not able to recreate this bug. I tried on both Windows 10/11 and Linux systems with multiple zip files. Looking over the relevant code, I didn't see anything glaringly incorrect. Can anyone else reproduce this?
The bug should still exists as we still raise without first cleaning up opened file handlers: https://github.com/pandas-dev/pandas/blob/8a286fa16f3160e939b192cbe8e218992a84e6fc/pandas/io/common.py#L812
You probably need to enable ResoruceWarnings, for example, with python -W default