2424# THE SOFTWARE.
2525
2626
27- import codecs
27+ import io
2828import os
2929from itertools import islice
3030from 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