pd.ExcelFile closes stream on destruction in pandas 1.0.0 · Issue #31467 · pandas-dev/pandas (original) (raw)
Code Sample, a copy-pastable example if possible
import pandas as pd print(pd.version) a = open('some_file.xlsx', 'rb') x = pd.ExcelFile(a) del x print(a.read())
Problem description
Above script behaves in different way in pandas 0.25.3 and 1.0.0:
$ python3 t1.py 0.25.3 b'' $ sudo pip3 install pandas --upgrade --quiet $ python3 t1.py 1.0.0 Traceback (most recent call last): File "t1.py", line 6, in print(a.read()) ValueError: read of closed file
It seems that stream is closed when ExcelFile is destroyed - and I don't see why.
Expected Output
I'd expect either notice in release notes, or the same output in 0.25.3 and 1.0.0.
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.0.0-1028-gcp
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 9.0.1
setuptools : 39.0.1
Cython : None
pytest : 4.3.0
hypothesis : None
sphinx : 1.8.5
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.1
html5lib : 0.999999999
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : None
pandas_datareader: None
bs4 : 4.8.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.1
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 2.5.14
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 4.3.0
pyxlsb : None
s3fs : None
scipy : 1.2.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None