Skip to content

Commit 1c9d1b3

Browse files
committed
Read in the history file before writing. This prevents stomping of history from multiple bpython sessions. History from multiple sessions will be interleaved.
1 parent 48aea6a commit 1c9d1b3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

bpython/repl.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,13 @@ def push(self, s, insert_into_history=True):
745745
s = s.rstrip('\n')
746746
self.buffer.append(s)
747747

748-
749-
if insert_into_history:
748+
if insert_into_history and self.config.hist_length:
749+
histfilename = os.path.expanduser(self.config.hist_file)
750+
self.rl_history.entries = []
751+
if os.path.exists(histfilename):
752+
self.rl_history.load(histfilename, getpreferredencoding())
750753
self.rl_history.append(s)
751-
if self.config.hist_length:
752-
histfilename = os.path.expanduser(self.config.hist_file)
753-
self.rl_history.save(histfilename, getpreferredencoding(), self.config.hist_length)
754+
self.rl_history.save(histfilename, getpreferredencoding(), self.config.hist_length)
754755

755756
more = self.interp.runsource('\n'.join(self.buffer))
756757

0 commit comments

Comments
 (0)