Open 86c43416-f4df-473d-aaf4-adedf5b2c460 opened 3 years ago
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.
There are already specifications for where to store program data.
For Windows, we should use %APPDATA%/Python/history
;
for Mac OS, we should use ~/Library/Application Support/Python/history
;
for other POSIX platforms, we should use $XDG_DATA_HOME/python/history
or ~/.local/share/python/history
according to XDG Spec.
These paths should be preferred as default. But we can also check and use ~/.python_history
if it exists and readable, for compatibility.
for other POSIX platforms, we should use
$XDG_DATA_HOME/python/history
or~/.local/share/python/history
according to XDG Spec.
The specification actually received an amendment on the very month this message was originally posted. It now additionally specifies $XDG_STATE_HOME
, which should be the way to go here instead of $XDG_DATA_HOME
:
The
$XDG_STATE_HOME
contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in$XDG_DATA_HOME
. It may contain:
- actions history (logs, history, recently used files, …)
- current state of the application that can be reused on a restart (view, layout, open files, undo history, …)
Note that we merged https://github.com/python/cpython/issues/73965 , so the location of this file can now be controlled by PYTHON_HISTORY
If this is ever to be merged, maybe you could add something about pdb's ~/.pdbrc file? ;)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at = None created_at =
labels = ['type-feature', 'library', '3.11']
title = 'Use platform defined data directories instead of ~/.python_history'
updated_at =
user = 'https://github.com/oxalica'
```
bugs.python.org fields:
```python
activity =
actor = 'python-dev'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation =
creator = 'oxalica'
dependencies = []
files = []
hgrepos = []
issue_num = 44239
keywords = ['patch']
message_count = 1.0
messages = ['394429']
nosy_count = 2.0
nosy_names = ['python-dev', 'oxalica']
pr_nums = ['26377']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue44239'
versions = ['Python 3.11']
```