From b43ba3da9d4091ab148b4906d2da726e63c59940 Mon Sep 17 00:00:00 2001 From: Bob Farrell Date: Mon, 25 Aug 2008 00:08:53 +0100 Subject: [PATCH] Bug fix re: PYTHONSTARTUP I've never used this feature but Thorsten Kampe reported problems with it. Unfortunately the way I was parsing the file was line-by-line which was causing bpython to blow up when it encountered a double line-break, which was pretty stupid on my part. It now takes the whole file at once. --- CHANGELOG | 3 +++ bpython.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c7a3d29..d2f39c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,9 @@ handling as well as C-w for deleting words - thanks a lot! raw_input() and all its friends now work fine. +PYTHONSTARTUP handled without blowing up on stupid errors (it now parses the +file at once instead of feeding it to the repl line-by-line). + v0.6.4 ====== KeyboardInterrupt handler clears the list window properly now. diff --git a/bpython.py b/bpython.py index 53ec817..8f0260f 100644 --- a/bpython.py +++ b/bpython.py @@ -789,14 +789,14 @@ class Repl( object ): entered for using up/down to go back and forth (which has to be separate to the evaluation history, which will be truncated when undoing.""" - # This was a feature request to have the PYTHONSTARTUP - # file executed on startup - I personally don't use this - # feature so please notify me of any breakage. +# This was a feature request to have the PYTHONSTARTUP +# file executed on startup - I personally don't use this +# feature so please notify me of any breakage. filename = os.environ.get('PYTHONSTARTUP') if filename and os.path.isfile(filename): - for line in open(filename, 'r'): - self.push( line ) - self.push( '\n' ) + f = open(filename, 'r') + self.interp.runsource(f.read()) + f.close() # The regular help() function uses PAGER to display the help, which # screws with bpython. @@ -826,8 +826,9 @@ class Repl( object ): self.h_i = 0 self.history.append( inp ) self.s_hist[-1] += self.f_string - self.stdout_hist += inp + '\n'#.rstrip('\n') - self.rl_hist.append( inp ) # Keep two copies so you can go up and down in the hist + self.stdout_hist += inp + '\n' +# Keep two copies so you can go up and down in the hist: + self.rl_hist.append( inp ) more = self.push( inp ) def size( self ):