Skip to content

Commit

Permalink
BUG: fixed errors in python2
Browse files Browse the repository at this point in the history
  • Loading branch information
deflatSOCO committed Jun 24, 2018
1 parent 050e8b5 commit 48f5685
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import csv
import codecs
import mmap
import io
from contextlib import contextmanager, closing
import zipfile

Expand Down Expand Up @@ -395,7 +394,9 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,
elif is_path:
if compat.PY2:
# Python 2
f = io.open(path_or_buf, mode, newline='\n')
if mode == 'w':
mode = 'wb'
f = open(path_or_buf, mode)
elif encoding:
# Python 3 and encoding
f = open(path_or_buf, mode, encoding=encoding, newline='\n')
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/formats/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def test_to_csv_string_with_lf(self):
assert f.read() == expected_bin

# 'line_terminator' should not change inner element
expected_bin =(
expected_bin = (
b'int,str_lf\r\n'
b'1,abc\r\n'
b'2,"d\nef"\r\n'
Expand Down

0 comments on commit 48f5685

Please sign in to comment.