BUG: Pandas doesn't release the lock when a corrupted file is fed in. pandas==1.2.1 worked fine but pandas==1.2.4 has this issue. #41778
Labels
Bug
IO Excel
read_excel, to_excel
Regression
Functionality that used to work in a prior pandas version
Milestone
Kindly refer the following code snippet.
import pandas as pd
import os
# Creating a corrupted file
with open('a.xlsx', 'w') as f:
pass
# Reading using pd.ExcelFile
data = pd.ExcelFile('a.xlsx', engine='openpyxl')
# Deleting the file
os.remove('a.xlsx')
Here, I create a .xlsx file which is not the correct way to make xlsx file but this will express my concern. Then I use pd.ExcelFile to read the xlsx file but it gives me
zipfile.BadZipFile: File is not a zip file
which is fine but later when I try to delete that file I getPermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'a.xlsx'
. This doesn't happen inpandas==1.2.1
and lower version. The current version i.e.pandas==1.2.4
has this bug.The text was updated successfully, but these errors were encountered: