diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-01-28 16:49:19 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-01-28 16:49:19 -0500 |
commit | 188f251fa339eda74a97a790ac33b02a18363462 (patch) | |
tree | 7be5143852e055f2479dc5acb4b93d93e544cb9d | |
parent | da203d25dff1f05511af43b4f73fd537678d6e03 (diff) | |
download | cmd2-git-header_tabs.tar.gz |
Fixed FileNotFoundError which occurred when running 'history --clear' and no history file existed.header_tabs
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cmd2/cmd2.py | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index be38ceb9..9bb30141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Fixed bug where setting `always_show_hint=True` did not show a hint when completing `Settables` * Fixed bug in editor detection logic on Linux systems that do not have `which` * Fixed bug in table creator where column headers with tabs would result in an incorrect width calculation + * Fixed `FileNotFoundError` which occurred when running `history --clear` and no history file existed. * Enhancements * Added `silent_startup_script` option to `cmd2.Cmd.__init__()`. If `True`, then the startup script's output will be suppressed. Anything written to stderr will still display. diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 8ad3f7ba..ab72f1a6 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3989,7 +3989,10 @@ class Cmd(cmd.Cmd): self.history.clear() if self.persistent_history_file: - os.remove(self.persistent_history_file) + try: + os.remove(self.persistent_history_file) + except FileNotFoundError: + pass if rl_type != RlType.NONE: readline.clear_history() |