Skip to content

Commit 9069471

Browse files
committed
Removed redundant history.save() calls in gtk_.py, cli.py and urwid.py.
Fixed the bug that caused every command entered in the gtk interface to be appended twice to the history.
1 parent 396652b commit 9069471

File tree

4 files changed

+4
-15
lines changed

4 files changed

+4
-15
lines changed

bpython/cli.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,9 +1716,6 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
17161716
clirepl.write(banner)
17171717
clirepl.write('\n')
17181718
clirepl.repl()
1719-
if config.hist_length:
1720-
histfilename = os.path.expanduser(config.hist_file)
1721-
clirepl.rl_history.save(histfilename, getpreferredencoding())
17221719

17231720
main_win.erase()
17241721
main_win.refresh()

bpython/gtk_.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,6 @@ def push_line(self):
688688
# Save mark for easy referencing later
689689
self.text_buffer.create_mark('line%i_start' % (len(self.buffer), ),
690690
self.get_line_start_iter(), True)
691-
self.rl_history.append(line)
692691
iter_ = self.get_line_end_iter()
693692
self.text_buffer.place_cursor(iter_)
694693
with self.editing:
@@ -859,10 +858,7 @@ def main(args=None):
859858
gtk.main()
860859
except KeyboardInterrupt:
861860
pass
862-
finally:
863-
if config.hist_length:
864-
histfilename = os.path.expanduser(config.hist_file)
865-
repl_widget.rl_history.save(histfilename, getpreferredencoding())
861+
866862
return 0
867863

868864
if __name__ == '__main__':

bpython/repl.py

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

748-
histfilename = os.path.expanduser(self.config.hist_file)
749748

750749
if insert_into_history:
751750
self.rl_history.append(s)
752-
self.rl_history.save(histfilename, getpreferredencoding())
751+
if self.config.hist_length:
752+
histfilename = os.path.expanduser(self.config.hist_file)
753+
self.rl_history.save(histfilename, getpreferredencoding())
753754

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

bpython/urwid.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,11 +1019,6 @@ def run_with_screen_before_mainloop():
10191019
continue
10201020
break
10211021

1022-
if config.hist_length:
1023-
histfilename = os.path.expanduser(config.hist_file)
1024-
myrepl.rl_history.save(histfilename,
1025-
locale.getpreferredencoding())
1026-
10271022
finally:
10281023
sys.stdin = orig_stdin
10291024
sys.stderr = orig_stderr

0 commit comments

Comments
 (0)