Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34e0422

Browse files
cgohlkemdboom
authored andcommitted
Use file open modes required by csv module
1 parent 656c88f commit 34e0422

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/tests/test_mlab.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from __future__ import print_function
2+
3+
import sys
4+
25
import numpy as np
36
import matplotlib.mlab as mlab
47
import tempfile
@@ -19,7 +22,10 @@ def test_recarray_csv_roundtrip():
1922
expected['x'][:] = np.linspace(-1e9, -1, 99)
2023
expected['y'][:] = np.linspace(1, 1e9, 99)
2124
expected['t'][:] = np.linspace(0, 0.01, 99)
22-
fd = tempfile.TemporaryFile(suffix='csv', mode="w+")
25+
if sys.version_info[0] == 2:
26+
fd = tempfile.TemporaryFile(suffix='csv', mode="wb+")
27+
else:
28+
fd = tempfile.TemporaryFile(suffix='csv', mode="w+", newline='')
2329
mlab.rec2csv(expected,fd)
2430
fd.seek(0)
2531
actual = mlab.csv2rec(fd)

0 commit comments

Comments
 (0)