Skip to content

Commit 2c96da0

Browse files
committed
Switch back to os.path from pathlib
python 3.4 pathlib doesn’t have .expanduser()
1 parent 8fd6d50 commit 2c96da0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

cmd2/cmd2.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import glob
3535
import inspect
3636
import os
37-
import pathlib
3837
import pickle
3938
import re
4039
import sys
@@ -3466,29 +3465,29 @@ def _initialize_history(self, hist_file):
34663465
self.persistent_history_file = hist_file
34673466
return
34683467

3469-
histpath = pathlib.Path(hist_file).expanduser().resolve()
3468+
hist_file = os.path.expanduser(hist_file)
34703469

34713470
# first we try and unpickle the history file
34723471
history = History()
34733472
# on Windows, trying to open a directory throws a permission
34743473
# error, not a `IsADirectoryError`. So we'll check it ourselves.
3475-
if histpath.is_dir():
3474+
if os.path.isdir(hist_file):
34763475
msg = "persistent history file '{}' is a directory"
3477-
self.perror(msg.format(histpath))
3476+
self.perror(msg.format(hist_file))
34783477
return
34793478

34803479
try:
3481-
with open(str(histpath), 'rb') as fobj:
3480+
with open(hist_file, 'rb') as fobj:
34823481
history = pickle.load(fobj)
34833482
except (FileNotFoundError, KeyError, EOFError):
34843483
pass
34853484
except OSError as ex:
34863485
msg = "can not read persistent history file '{}': {}"
3487-
self.perror(msg.format(histpath, ex), traceback_war=False)
3486+
self.perror(msg.format(hist_file, ex), traceback_war=False)
34883487
return
34893488

34903489
self.history = history
3491-
self.persistent_history_file = str(histpath)
3490+
self.persistent_history_file = hist_file
34923491

34933492
# populate readline history
34943493
if rl_type != RlType.NONE:

0 commit comments

Comments
 (0)