File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -231,7 +231,11 @@ def get_completer_delims(self):
231
231
return '' .join (chars )
232
232
233
233
def _histline (self , line ):
234
- return unicode (line .rstrip ('\n ' ), ENCODING )
234
+ line = line .rstrip ('\n ' )
235
+ try :
236
+ return unicode (line , ENCODING )
237
+ except UnicodeDecodeError : # bah, silently fall back...
238
+ return unicode (line , 'utf-8' )
235
239
236
240
def get_history_length (self ):
237
241
return self .saved_history_length
@@ -268,7 +272,10 @@ def write_history_file(self, filename='~/.history'):
268
272
f = open (os .path .expanduser (filename ), 'w' )
269
273
for entry in history :
270
274
if isinstance (entry , unicode ):
271
- entry = entry .encode (ENCODING )
275
+ try :
276
+ entry = entry .encode (ENCODING )
277
+ except UnicodeEncodeError : # bah, silently fall back...
278
+ entry = entry .encode ('utf-8' )
272
279
entry = entry .replace ('\n ' , '\r \n ' ) # multiline history support
273
280
f .write (entry + '\n ' )
274
281
f .close ()
You can’t perform that action at this time.
0 commit comments