Skip to content

Use platform defined data directories instead of ~/.python_history #88405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
oxalica mannequin opened this issue May 26, 2021 · 4 comments
Open

Use platform defined data directories instead of ~/.python_history #88405

oxalica mannequin opened this issue May 26, 2021 · 4 comments
Labels
3.13 bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@oxalica
Copy link
Mannequin

oxalica mannequin commented May 26, 2021

BPO 44239
Nosy @oxalica
PRs
  • gh-88405: Use platform defined data directories instead of ~/.python_history #26377
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2021-05-26.10:58:43.729>
    labels = ['type-feature', 'library', '3.11']
    title = 'Use platform defined data directories instead of ~/.python_history'
    updated_at = <Date 2021-05-26.11:39:53.868>
    user = 'https://github.com/oxalica'

    bugs.python.org fields:

    activity = <Date 2021-05-26.11:39:53.868>
    actor = 'python-dev'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-05-26.10:58:43.729>
    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']

    @oxalica
    Copy link
    Mannequin Author

    oxalica mannequin commented May 26, 2021

    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.

    @oxalica oxalica mannequin added 3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 26, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @Igetin
    Copy link

    Igetin commented May 27, 2022

    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, …)

    @hauntsaninja
    Copy link
    Contributor

    hauntsaninja commented Jan 7, 2024

    Note that we merged #73965 , so the location of this file can now be controlled by PYTHON_HISTORY

    @python python deleted a comment Jan 7, 2024
    @python python locked as spam and limited conversation to collaborators Jan 7, 2024
    @python python deleted a comment Jan 7, 2024
    @python python deleted a comment Jan 7, 2024
    @python python deleted a comment Jan 7, 2024
    @python python unlocked this conversation Jan 7, 2024
    @returnDanilo
    Copy link

    If this is ever to be merged, maybe you could add something about pdb's ~/.pdbrc file? ;)

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants
    @arhadthedev @hauntsaninja @Igetin @returnDanilo and others