Skip to content

Commit a48ad53

Browse files
authored
Merge pull request #9352 from jdufresne/io-codecs-open
Replace io.open() and codecs.open() with builtin open()
2 parents 86afa89 + a1fff4a commit a48ad53

File tree

5 files changed

+4
-8
lines changed

5 files changed

+4
-8
lines changed

news/dc9e5ecc-9fc9-4762-914e-34014e8d09bf.trivial.rst

Whitespace-only changes.

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# The following comment should be removed at some point in the future.
22
# mypy: disallow-untyped-defs=False
33

4-
import codecs
54
import os
65
import sys
76

@@ -12,7 +11,7 @@ def read(rel_path):
1211
here = os.path.abspath(os.path.dirname(__file__))
1312
# intentionally *not* adding an encoding option to open, See:
1413
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
15-
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
14+
with open(os.path.join(here, rel_path), 'r') as fp:
1615
return fp.read()
1716

1817

src/pip/_internal/pyproject.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import io
21
import os
32
from collections import namedtuple
43

@@ -62,7 +61,7 @@ def load_pyproject_toml(
6261
has_setup = os.path.isfile(setup_py)
6362

6463
if has_pyproject:
65-
with io.open(pyproject_toml, encoding="utf-8") as f:
64+
with open(pyproject_toml, encoding="utf-8") as f:
6665
pp_toml = toml.load(f)
6766
build_system = pp_toml.get("build-system")
6867
else:

src/pip/_internal/utils/virtualenv.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import io
21
import logging
32
import os
43
import re
@@ -52,7 +51,7 @@ def _get_pyvenv_cfg_lines():
5251
try:
5352
# Although PEP 405 does not specify, the built-in venv module always
5453
# writes with UTF-8. (pypa/pip#8717)
55-
with io.open(pyvenv_cfg_file, encoding='utf-8') as f:
54+
with open(pyvenv_cfg_file, encoding='utf-8') as f:
5655
return f.read().splitlines() # avoids trailing newlines
5756
except IOError:
5857
return None

tools/automation/release/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
import contextlib
7-
import io
87
import os
98
import pathlib
109
import subprocess
@@ -75,7 +74,7 @@ def generate_authors(filename: str) -> None:
7574
authors = get_author_list()
7675

7776
# Write our authors to the AUTHORS file
78-
with io.open(filename, "w", encoding="utf-8") as fp:
77+
with open(filename, "w", encoding="utf-8") as fp:
7978
fp.write("\n".join(authors))
8079
fp.write("\n")
8180

0 commit comments

Comments
 (0)