Skip to content

Commit 023402d

Browse files
committed
Make it so we setting hist_length to zero does not cause you to not have session history
1 parent 8c5b02a commit 023402d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

bpython/repl.py

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

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())
753-
self.rl_history.append(s)
754-
try:
755-
self.rl_history.save(histfilename, getpreferredencoding(), self.config.hist_length)
756-
except EnvironmentError as (errno, strerr):
757-
self.interact.notify("Write error for file: %s. %s " % (histfilename, strerr))
748+
if insert_into_history:
749+
if self.config.hist_length:
750+
histfilename = os.path.expanduser(self.config.hist_file)
751+
self.rl_history.entries = []
752+
if os.path.exists(histfilename):
753+
self.rl_history.load(histfilename, getpreferredencoding())
754+
self.rl_history.append(s)
755+
try:
756+
self.rl_history.save(histfilename, getpreferredencoding(), self.config.hist_length)
757+
except EnvironmentError as (errno, strerr):
758+
self.interact.notify("Write error for file: %s. %s " % (histfilename, strerr))
759+
else:
760+
self.rl_history.append(s)
758761

759762
more = self.interp.runsource('\n'.join(self.buffer))
760763

0 commit comments

Comments
 (0)