Bohdan Vlasyuk patch applied to check beforehand if sys.__stdout__.encoding exists

It falls back to sys.getdefaultencoding() if the stdout object doesn't have an encoding attribute.
This commit is contained in:
Bob Farrell
2009-01-26 09:53:37 +00:00
parent 242b72c527
commit 4f8a616674
2 changed files with 5 additions and 2 deletions
+2 -2
View File
@@ -951,7 +951,7 @@ class Repl(object):
t = s
if isinstance(t, unicode):
t = t.encode(sys.__stdout__.encoding)
t = t.encode(getattr(sys.__stdout__, 'encoding') or sys.getdefaultencoding())
if not self.stdout_hist:
self.stdout_hist = t
@@ -986,7 +986,7 @@ class Repl(object):
srings. It won't update the screen if it's reevaluating the code (as it
does with undo)."""
if isinstance(s, unicode):
s = s.encode(sys.__stdout__.encoding)
s = s.encode(getattr(sys.__stdout__, 'encoding') or sys.getdefaultencoding())
a = curses.color_pair(0)
if '\x01' in s: