Skip to content

Commit 317a8a5

Browse files
author
Bob Farrell
committed
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. committer: Bob Farrell <bob@keys.(none)>
1 parent 739ba06 commit 317a8a5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ handling as well as C-w for deleting words - thanks a lot!
1212

1313
raw_input() and all its friends now work fine.
1414

15+
PYTHONSTARTUP handled without blowing up on stupid errors (it now parses the
16+
file at once instead of feeding it to the repl line-by-line).
17+
1518
v0.6.4
1619
======
1720
KeyboardInterrupt handler clears the list window properly now.

bpython.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -789,14 +789,14 @@ def repl( self ):
789789
entered for using up/down to go back and forth (which has to be separate
790790
to the evaluation history, which will be truncated when undoing."""
791791

792-
# This was a feature request to have the PYTHONSTARTUP
793-
# file executed on startup - I personally don't use this
794-
# feature so please notify me of any breakage.
792+
# This was a feature request to have the PYTHONSTARTUP
793+
# file executed on startup - I personally don't use this
794+
# feature so please notify me of any breakage.
795795
filename = os.environ.get('PYTHONSTARTUP')
796796
if filename and os.path.isfile(filename):
797-
for line in open(filename, 'r'):
798-
self.push( line )
799-
self.push( '\n' )
797+
f = open(filename, 'r')
798+
self.interp.runsource(f.read())
799+
f.close()
800800

801801
# The regular help() function uses PAGER to display the help, which
802802
# screws with bpython.
@@ -826,8 +826,9 @@ def repl( self ):
826826
self.h_i = 0
827827
self.history.append( inp )
828828
self.s_hist[-1] += self.f_string
829-
self.stdout_hist += inp + '\n'#.rstrip('\n')
830-
self.rl_hist.append( inp ) # Keep two copies so you can go up and down in the hist
829+
self.stdout_hist += inp + '\n'
830+
# Keep two copies so you can go up and down in the hist:
831+
self.rl_hist.append( inp )
831832
more = self.push( inp )
832833

833834
def size( self ):

0 commit comments

Comments
 (0)