Skip to content

Commit 62d7d95

Browse files
committed
Use io instead of codecs
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
1 parent 844d350 commit 62d7d95

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bpython/history.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# THE SOFTWARE.
2525

2626

27-
import codecs
27+
import io
2828
import os
2929
from itertools import islice
3030
from six.moves import range
@@ -175,7 +175,8 @@ def reset(self):
175175
self.saved_line = ''
176176

177177
def load(self, filename, encoding):
178-
with codecs.open(filename, 'r', encoding, 'ignore') as hfile:
178+
with io.open(filename, 'r', encoding=encoding,
179+
errors='ignore') as hfile:
179180
with FileLock(hfile):
180181
self.entries = self.load_from(hfile)
181182

@@ -186,7 +187,8 @@ def load_from(self, fd):
186187
return entries
187188

188189
def save(self, filename, encoding, lines=0):
189-
with codecs.open(filename, 'w', encoding, 'ignore') as hfile:
190+
with io.open(filename, 'w', encoding=encoding,
191+
errors='ignore') as hfile:
190192
with FileLock(hfile):
191193
self.save_to(hfile, self.entries, lines)
192194

@@ -202,7 +204,8 @@ def append_reload_and_write(self, s, filename, encoding):
202204
return self.append(s)
203205

204206
try:
205-
with codecs.open(filename, 'a+', encoding, 'ignore') as hfile:
207+
with io.open(filename, 'a+', encoding=encoding,
208+
errors='ignore') as hfile:
206209
with FileLock(hfile):
207210
# read entries
208211
hfile.seek(0, os.SEEK_SET)

0 commit comments

Comments
 (0)