Skip to content

Commit a52a5d4

Browse files
committed
MNT: migrate from codecs.open to open
1 parent 4257ad6 commit a52a5d4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

pandas/tests/io/formats/test_to_latex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ def test_to_latex_to_file_utf8_with_encoding(self):
4242
df = DataFrame([["au\xdfgangen"]])
4343
with tm.ensure_clean("test.tex") as path:
4444
df.to_latex(path, encoding="utf-8")
45-
with codecs.open(path, "r", encoding="utf-8") as f:
45+
with open(path, "r", encoding="utf-8") as f:
4646
assert df.to_latex() == f.read()
4747

4848
def test_to_latex_to_file_utf8_without_encoding(self):
4949
# test with utf-8 without encoding option
5050
df = DataFrame([["au\xdfgangen"]])
5151
with tm.ensure_clean("test.tex") as path:
5252
df.to_latex(path)
53-
with codecs.open(path, "r", encoding="utf-8") as f:
53+
with open(path, "r", encoding="utf-8") as f:
5454
assert df.to_latex() == f.read()
5555

5656
def test_to_latex_tabular_with_index(self):

pandas/tests/io/test_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,9 @@ def test_codecs_encoding(encoding, format):
523523
index=pd.Index([f"i-{i}" for i in range(30)]),
524524
)
525525
with tm.ensure_clean() as path:
526-
with codecs.open(path, mode="w", encoding=encoding) as handle:
526+
with open(path, mode="w", encoding=encoding) as handle:
527527
getattr(expected, f"to_{format}")(handle)
528-
with codecs.open(path, mode="r", encoding=encoding) as handle:
528+
with open(path, mode="r", encoding=encoding) as handle:
529529
if format == "csv":
530530
df = pd.read_csv(handle, index_col=0)
531531
else:

pandas/util/_print_versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def show_versions(as_json: str | bool = False) -> None:
143143
sys.stdout.writelines(json.dumps(j, indent=2))
144144
else:
145145
assert isinstance(as_json, str) # needed for mypy
146-
with codecs.open(as_json, "wb", encoding="utf8") as f:
146+
with open(as_json, "w", encoding="utf-8") as f:
147147
json.dump(j, f, indent=2)
148148

149149
else:

0 commit comments

Comments
 (0)