Skip to content

Commit 4dd340e

Browse files
committed
CLN/DEPR: Fix instances of 'U'/'rU' in open(...)
#7131
1 parent 255e82a commit 4dd340e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandas/io/tests/test_sql.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ def _get_exec(self):
157157
return self.conn.cursor()
158158

159159
def _load_iris_data(self):
160+
import io
160161
iris_csv_file = os.path.join(tm.get_data_path(), 'iris.csv')
161162

162163
self.drop_table('iris')
163164
self._get_exec().execute(SQL_STRINGS['create_iris'][self.flavor])
164165

165-
with open(iris_csv_file, 'rU') as iris_csv:
166+
with io.open(iris_csv_file, mode='r', newline=None) as iris_csv:
166167
r = csv.reader(iris_csv)
167168
next(r) # skip header row
168169
ins = SQL_STRINGS['insert_iris'][self.flavor]

pandas/tests/test_series.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4235,11 +4235,12 @@ def test_from_csv(self):
42354235
assert_series_equal(checkseries, series)
42364236

42374237
def test_to_csv(self):
4238+
import io
42384239

42394240
with ensure_clean() as path:
42404241
self.ts.to_csv(path)
42414242

4242-
lines = open(path, 'U').readlines()
4243+
lines = io.open(path, newline=None).readlines()
42434244
assert(lines[1] != '\n')
42444245

42454246
self.ts.to_csv(path, index=False)

0 commit comments

Comments
 (0)