|
34 | 34 | import glob |
35 | 35 | import inspect |
36 | 36 | import os |
37 | | -import pathlib |
38 | 37 | import pickle |
39 | 38 | import re |
40 | 39 | import sys |
@@ -3466,29 +3465,29 @@ def _initialize_history(self, hist_file): |
3466 | 3465 | self.persistent_history_file = hist_file |
3467 | 3466 | return |
3468 | 3467 |
|
3469 | | - histpath = pathlib.Path(hist_file).expanduser().resolve() |
| 3468 | + hist_file = os.path.expanduser(hist_file) |
3470 | 3469 |
|
3471 | 3470 | # first we try and unpickle the history file |
3472 | 3471 | history = History() |
3473 | 3472 | # on Windows, trying to open a directory throws a permission |
3474 | 3473 | # error, not a `IsADirectoryError`. So we'll check it ourselves. |
3475 | | - if histpath.is_dir(): |
| 3474 | + if os.path.isdir(hist_file): |
3476 | 3475 | msg = "persistent history file '{}' is a directory" |
3477 | | - self.perror(msg.format(histpath)) |
| 3476 | + self.perror(msg.format(hist_file)) |
3478 | 3477 | return |
3479 | 3478 |
|
3480 | 3479 | try: |
3481 | | - with open(str(histpath), 'rb') as fobj: |
| 3480 | + with open(hist_file, 'rb') as fobj: |
3482 | 3481 | history = pickle.load(fobj) |
3483 | 3482 | except (FileNotFoundError, KeyError, EOFError): |
3484 | 3483 | pass |
3485 | 3484 | except OSError as ex: |
3486 | 3485 | 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) |
3488 | 3487 | return |
3489 | 3488 |
|
3490 | 3489 | self.history = history |
3491 | | - self.persistent_history_file = str(histpath) |
| 3490 | + self.persistent_history_file = hist_file |
3492 | 3491 |
|
3493 | 3492 | # populate readline history |
3494 | 3493 | if rl_type != RlType.NONE: |
|
0 commit comments