From 242b72c527cfbf84df6cf5c45572c4acd724559f Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Mon, 5 Jan 2009 10:17:10 +0000 Subject: [PATCH] Unicode + string concatenation bug in output bufffer fixed Thanks to Mark Florisson for the patch. --- CHANGELOG | 4 ++++ bpython/cli.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index e77e003..f184add 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,10 @@ stdout or not on exit. Piping something to bpython made it lock up as stdin was not the keyboard - bpython just executes stdin and exits instead of trying to do something clever. +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. + 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 e243815..1d9a26c 100644 --- a/bpython/cli.py +++ b/bpython/cli.py @@ -950,6 +950,9 @@ class Repl(object): else: t = s + if isinstance(t, unicode): + t = t.encode(sys.__stdout__.encoding) + if not self.stdout_hist: self.stdout_hist = t else: @@ -982,6 +985,8 @@ class Repl(object): uses the formatting method as defined in formatter.py to parse the 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) a = curses.color_pair(0) if '\x01' in s: