python: Handle non-existing history file
Create a dummy entry in the history file if it does not exist yet or is empty. Otherwise `~/.python_history` would be used by site.py.
This commit is contained in:
@@ -19,6 +19,11 @@ try:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Create dummy entry if the file does not yet exist, as otherwise
|
||||
# ~/.python_history is used by site.py
|
||||
if not readline.get_current_history_length():
|
||||
readline.add_history("# python history file")
|
||||
|
||||
def write_history():
|
||||
try:
|
||||
readline.write_history_file(history)
|
||||
|
||||
Reference in New Issue
Block a user