[pypy-commit] pyrepl default: Port 5e062fe507c3 from pypy.
arigo
noreply at buildbot.pypy.org
Tue Nov 1 08:39:14 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r154:8f621e5d5cb7
Date: 2011-11-01 08:39 +0100
http://bitbucket.org/pypy/pyrepl/changeset/8f621e5d5cb7/
Log: Port 5e062fe507c3 from pypy.
diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -231,7 +231,11 @@
return ''.join(chars)
def _histline(self, line):
- return unicode(line.rstrip('\n'), ENCODING)
+ line = line.rstrip('\n')
+ try:
+ return unicode(line, ENCODING)
+ except UnicodeDecodeError: # bah, silently fall back...
+ return unicode(line, 'utf-8')
def get_history_length(self):
return self.saved_history_length
@@ -268,7 +272,10 @@
f = open(os.path.expanduser(filename), 'w')
for entry in history:
if isinstance(entry, unicode):
- entry = entry.encode(ENCODING)
+ try:
+ entry = entry.encode(ENCODING)
+ except UnicodeEncodeError: # bah, silently fall back...
+ entry = entry.encode('utf-8')
entry = entry.replace('\n', '\r\n') # multiline history support
f.write(entry + '\n')
f.close()
More information about the pypy-commit
mailing list