Fixes ptpython/ptipython config and history (#278) #279
+56
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the ptpython/ptipython configuration issue from #278. It will now iterate through a list of all possible config directory locations in order of priority and use the first one it finds, if one exists.
Additionally, very similar logic is now applied to the history filename location to address these 2 bugs:
On linux, ptpython no longer keeps the history file inside the config directory, but in a different place entirely. Fixing the config directory issue does not make history work properly.
Previously, a
history_filename
was being passed toembed
whether it existed or not. If it doesn't exist, ptpython will try to create it and write to it, but unfortunately it only checks whether the file exists, and not whether its parent directories do. Giving it ahistory_filename
that doesn't exist is fine as long as its parent directory does, but if not, it throws an exception.It now looks for the history directory in the correct places, and if it cannot find one, it passes
history_filename=None
toembed
.