Skip to content

Commit d0e18f1

Browse files
authored
Merge pull request #786 from python-cmd2/history_error
Fixed ValueError exception when opening old history file
2 parents 8b45f3a + 32efbfb commit d0e18f1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.19 (TBD, 2019)
2+
* Bug Fixes
3+
* Fixed `ValueError` exception which could occur when an old format persistent history file is loaded with new `cmd2`
4+
15
## 0.9.18 (October 1, 2019)
26
* Bug Fixes
37
* Fixed bug introduced in 0.9.17 where help functions for hidden and disabled commands were not being filtered

cmd2/cmd2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,8 +3592,9 @@ def _initialize_history(self, hist_file):
35923592
try:
35933593
with open(hist_file, 'rb') as fobj:
35943594
history = pickle.load(fobj)
3595-
except (AttributeError, EOFError, FileNotFoundError, ImportError, IndexError, KeyError, pickle.UnpicklingError):
3596-
# If any non-operating system error occurs when attempting to unpickle, just use an empty history
3595+
except (AttributeError, EOFError, FileNotFoundError, ImportError, IndexError, KeyError, ValueError,
3596+
pickle.UnpicklingError):
3597+
# If any of these errors occur when attempting to unpickle, just use an empty history
35973598
pass
35983599
except OSError as ex:
35993600
msg = "Can not read persistent history file '{}': {}"

0 commit comments

Comments
 (0)