◐ Shell
clean mode source ↗

gh-88405: Use platform defined data directories instead of ~/.python_history by oxalica · Pull Request #26377 · python/cpython

Currently we use path ~/.python_history for history file in all platforms.
It is not a good choice since it spams in user's home directory.

This patch use platform defined directories for put the history file.
For Windows, it's %APPDATA%/Python/history;
for Mac OS, it's ~/Library/Application Support/Python/history;
for other POSIX platforms, it's $XDG_STATE_HOME/python/history or ~/.local/state/python/history;
otherwise, fallback to ~/.python_history.

Also if ~/.python_history exists and is readable, it will always be used for compatibility.

https://bugs.python.org/issue44239