Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r202:bf651562fa0c
Date: 2012-10-27 09:37 +0200
http://bitbucket.org/pypy/pyrepl/changeset/bf651562fa0c/

Log:    - When the history file contains non-utf8 character sequences,
        don't crash but just replace them with the "unknown" unicode char.

        - When writing out text to the terminal, use "?" instead of crashing
        when the text cannot be encoded.

diff --git a/pyrepl/readline.py b/pyrepl/readline.py
--- a/pyrepl/readline.py
+++ b/pyrepl/readline.py
@@ -235,7 +235,7 @@
         try:
             return unicode(line, ENCODING)
         except UnicodeDecodeError:   # bah, silently fall back...
-            return unicode(line, 'utf-8')
+            return unicode(line, 'utf-8', 'replace')
 
     def get_history_length(self):
         return self.saved_history_length
diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py
--- a/pyrepl/unix_console.py
+++ b/pyrepl/unix_console.py
@@ -477,7 +477,7 @@
             if iscode:
                 self.__tputs(text)
             else:
-                os.write(self.output_fd, text.encode(self.encoding))
+                os.write(self.output_fd, text.encode(self.encoding, 'replace'))
         del self.__buffer[:]
 
     def __tputs(self, fmt, prog=delayprog):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to