Skip to content

Commit d3248ca

Browse files
committed
Replace io.open with open
1 parent fe22153 commit d3248ca

File tree

9 files changed

+11
-16
lines changed

9 files changed

+11
-16
lines changed

bpython/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def exec_code(interpreter, args):
134134
Helper to execute code in a given interpreter. args should be a [faked]
135135
sys.argv
136136
"""
137-
with open(args[0], "r") as sourcefile:
137+
with open(args[0]) as sourcefile:
138138
source = sourcefile.read()
139139
old_argv, sys.argv = sys.argv, args
140140
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))

bpython/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def get_key_no_doublebind(command):
304304

305305
def load_theme(struct, path, colors, default_colors):
306306
theme = ConfigParser()
307-
with open(path, "r") as f:
307+
with open(path) as f:
308308
theme.readfp(f)
309309
for k, v in chain(theme.items("syntax"), theme.items("interface")):
310310
if theme.has_option("syntax", k):

bpython/curtsies.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import collections
2-
import io
32
import logging
43
import sys
54
from optparse import Option
@@ -178,7 +177,7 @@ def main(args=None, locals_=None, banner=None, welcome_message=None):
178177
if options.paste:
179178
paste = curtsies.events.PasteEvent()
180179
encoding = inspection.get_encoding_file(exec_args[0])
181-
with io.open(exec_args[0], encoding=encoding) as f:
180+
with open(exec_args[0], encoding=encoding) as f:
182181
sourcecode = f.read()
183182
paste.events.extend(sourcecode)
184183
else:

bpython/history.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323

24-
import io
2524
import os
2625
import stat
2726
from itertools import islice
@@ -170,7 +169,7 @@ def reset(self):
170169
self.saved_line = ""
171170

172171
def load(self, filename, encoding):
173-
with io.open(
172+
with open(
174173
filename, "r", encoding=encoding, errors="ignore"
175174
) as hfile:
176175
with FileLock(hfile, filename=filename):
@@ -188,7 +187,7 @@ def save(self, filename, encoding, lines=0):
188187
os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
189188
stat.S_IRUSR | stat.S_IWUSR,
190189
)
191-
with io.open(fd, "w", encoding=encoding, errors="ignore") as hfile:
190+
with open(fd, "w", encoding=encoding, errors="ignore") as hfile:
192191
with FileLock(hfile, filename=filename):
193192
self.save_to(hfile, self.entries, lines)
194193

@@ -209,7 +208,7 @@ def append_reload_and_write(self, s, filename, encoding):
209208
os.O_APPEND | os.O_RDWR | os.O_CREAT,
210209
stat.S_IRUSR | stat.S_IWUSR,
211210
)
212-
with io.open(fd, "a+", encoding=encoding, errors="ignore") as hfile:
211+
with open(fd, "a+", encoding=encoding, errors="ignore") as hfile:
213212
with FileLock(hfile, filename=filename):
214213
# read entries
215214
hfile.seek(0, os.SEEK_SET)

bpython/inspection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424

2525
import inspect
26-
import io
2726
import keyword
2827
import pydoc
2928
from collections import namedtuple
@@ -350,7 +349,7 @@ def get_encoding_comment(source):
350349

351350
def get_encoding_file(fname):
352351
"""Try to obtain encoding information from a Python source file."""
353-
with io.open(fname, "rt", encoding="ascii", errors="ignore") as f:
352+
with open(fname, "rt", encoding="ascii", errors="ignore") as f:
354353
for unused in range(2):
355354
line = f.readline()
356355
match = get_encoding_line_re.search(line)

bpython/repl.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import code
2626
import inspect
27-
import io
2827
import os
2928
import pkgutil
3029
import pydoc
@@ -481,7 +480,7 @@ def startup(self):
481480
filename = os.environ.get("PYTHONSTARTUP")
482481
if filename:
483482
encoding = inspection.get_encoding_file(filename)
484-
with io.open(filename, "rt", encoding=encoding) as f:
483+
with open(filename, "rt", encoding=encoding) as f:
485484
source = f.read()
486485
self.interp.runsource(source, filename, "exec", encode=False)
487486

bpython/test/test_curtsies_repl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def setUp(self):
434434
self.repl = create_repl()
435435

436436
def write_startup_file(self, fname, encoding):
437-
with io.open(fname, mode="wt", encoding=encoding) as f:
437+
with open(fname, mode="wt", encoding=encoding) as f:
438438
f.write("# coding: ")
439439
f.write(encoding)
440440
f.write("\n")

bpython/test/test_history.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import io
21
import os
32

43

@@ -89,7 +88,7 @@ def setUp(self):
8988
self.filename = "history_temp_file"
9089
self.encoding = getpreferredencoding()
9190

92-
with io.open(
91+
with open(
9392
self.filename, "w", encoding=self.encoding, errors="ignore"
9493
) as f:
9594
f.write(b"#1\n#2\n".decode())

bpython/urwid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ def start(main_loop, user_data):
13381338
# this is CLIRepl.startup inlined.
13391339
filename = os.environ.get("PYTHONSTARTUP")
13401340
if filename and os.path.isfile(filename):
1341-
with open(filename, "r") as f:
1341+
with open(filename) as f:
13421342
interpreter.runsource(f.read(), filename, "exec")
13431343

13441344
if banner is not None:

0 commit comments

Comments
 (0)