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.
This commit is contained in:
Bob Farrell
2008-08-25 00:08:53 +01:00
parent b7eac8de8c
commit b43ba3da9d
2 changed files with 12 additions and 8 deletions
+3
View File
@@ -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.
+9 -8
View File
@@ -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 ):