Skip to content

Commit 48f5685

Browse files
committed
BUG: fixed errors in python2
1 parent 050e8b5 commit 48f5685

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pandas/io/common.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import csv
55
import codecs
66
import mmap
7-
import io
87
from contextlib import contextmanager, closing
98
import zipfile
109

@@ -395,7 +394,9 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,
395394
elif is_path:
396395
if compat.PY2:
397396
# Python 2
398-
f = io.open(path_or_buf, mode, newline='\n')
397+
if mode == 'w':
398+
mode = 'wb'
399+
f = open(path_or_buf, mode)
399400
elif encoding:
400401
# Python 3 and encoding
401402
f = open(path_or_buf, mode, encoding=encoding, newline='\n')

pandas/tests/io/formats/test_to_csv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def test_to_csv_string_with_lf(self):
307307
assert f.read() == expected_bin
308308

309309
# 'line_terminator' should not change inner element
310-
expected_bin =(
310+
expected_bin = (
311311
b'int,str_lf\r\n'
312312
b'1,abc\r\n'
313313
b'2,"d\nef"\r\n'

0 commit comments

Comments
 (0)