Skip to content

Commit 640dc1b

Browse files
committed
Simplify TextIOWrapper usage
1 parent 4774b75 commit 640dc1b

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

pandas/io/common.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,6 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,
359359

360360
handles.append(f)
361361

362-
# In Python 3
363-
if compat.PY3:
364-
from io import TextIOWrapper
365-
f = TextIOWrapper(f, encoding=encoding)
366-
handles.append(f)
367-
368-
return f, handles
369-
370362
elif is_path:
371363
if compat.PY2:
372364
# Python 2
@@ -380,7 +372,7 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,
380372
handles.append(f)
381373

382374
# in Python 3, convert BytesIO or fileobjects passed with an encoding
383-
if compat.PY3 and isinstance(path_or_buf, compat.BytesIO):
375+
if compat.PY3 and (compression or isinstance(f, compat.BytesIO)):
384376
from io import TextIOWrapper
385377
f = TextIOWrapper(f, encoding=encoding)
386378
handles.append(f)

0 commit comments

Comments
 (0)