diff --git a/CHANGELOG b/CHANGELOG index f184add..05a7816 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/bpython/cli.py b/bpython/cli.py index 1d9a26c..81975c5 100644 --- a/bpython/cli.py +++ b/bpython/cli.py @@ -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: