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
+3
View File
@@ -16,6 +16,9 @@ Mark Florisson (eggy) gave me a patch that stops weird breakage when unicode
objects get added into the output buffer - they now get encoded into the output
encoding.
Bohdan Vlasyuk sent me a patch that fixes a problem with the above patch from
Mark if sys.__stdout__.encoding didn't exist.
v0.7.1
======
Added support for a history file, defaults to ~/.pythonhist and 100 lines but
+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: