cpython: 687dd81cee3b (original) (raw)
Mercurial > cpython
changeset 85871:687dd81cee3b
Issue #5845: In site.py, only load readline history from ~/.python_history if no history has been read already. This avoids double writes to the history file at shutdown. [#5845]
Antoine Pitrou solipsis@pitrou.net | |
---|---|
date | Sun, 29 Sep 2013 22🔞38 +0200 |
parents | 280d403434c4 |
children | 067159ee704f |
files | Lib/site.py Misc/NEWS |
diffstat | 2 files changed, 17 insertions(+), 6 deletions(-)[+] [-] Lib/site.py 19 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/site.py +++ b/Lib/site.py @@ -405,12 +405,19 @@ def enablerlcompleter(): # want to ignore the exception. pass
history = os.path.join(os.path.expanduser('~'), '.python_history')[](#l1.7)
try:[](#l1.8)
readline.read_history_file(history)[](#l1.9)
except IOError:[](#l1.10)
pass[](#l1.11)
atexit.register(readline.write_history_file, history)[](#l1.12)
if readline.get_history_item(1) is None:[](#l1.13)
# If no history was loaded, default to .python_history.[](#l1.14)
# The guard is necessary to avoid doubling history size at[](#l1.15)
# each interpreter exit when readline was already configured[](#l1.16)
# through a PYTHONSTARTUP hook, see:[](#l1.17)
# http://bugs.python.org/issue5845#msg198636[](#l1.18)
history = os.path.join(os.path.expanduser('~'),[](#l1.19)
'.python_history')[](#l1.20)
try:[](#l1.21)
readline.read_history_file(history)[](#l1.22)
except IOError:[](#l1.23)
pass[](#l1.24)
atexit.register(readline.write_history_file, history)[](#l1.25)
sys.interactivehook = register_readline
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -15,6 +15,10 @@ Core and Builtins Library ------- +- Issue #5845: In site.py, only load readline history from ~/.python_history