read_csv and others derived from _read close user-provided filehandles · Issue #14418 · pandas-dev/pandas (original) (raw)
I believe the "regression" was introduced on this line. That being said, tracking which filehandles a library owns vs what a user provided is hard, and I can't fault you guys if this is considered correct behavior from now on. Just wanted to bring it to your attention. Thanks!
A small, complete example of the issue
In [1]: import pandas as pd
In [2]: import io
In [3]: fh = io.StringIO('a,b\n1,2\n')
In [4]: fh.closed Out[4]: False
In [5]: pd.read_csv(fh) Out[5]: a b 0 1 2
In [6]: fh.closed Out[6]: True
Expected Output
In [6]: fh.closed Out[6]: False
Output of pd.show_versions()
## INSTALLED VERSIONS
commit: None
python: 3.4.4.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-96-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.19.0
nose: 1.3.7
pip: 8.1.2
setuptools: 20.1.1
Cython: None
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.5a2
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None