This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jesse.p.ogle
Recipients Arfrever, Sworddragon, eric.araujo, jesse.p.ogle, jwilk, martin.panter, pitrou, r.david.murray
Date 2018-06-01.17:25:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527873959.64.0.81473610881.issue20886@psf.upfronthosting.co.za>
In-reply-to
Content
Greetings, I came across this issue while looking into XDG Base Directory Specification. This issue is only tagged with version 3.4, but the underlying issue (not being able to change the history file / size through environment variables) appears to still exist in the definiton of enablerlcompleter() in Lib/site.py for master. I may be wrong about that.

Tag 3.4:
https://github.com/python/cpython/blob/3.4/Lib/site.py#L423

Tag 3.7.0b5 (latest as of writing)
https://github.com/python/cpython/blob/v3.7.0b5/Lib/site.py#L436


This seems to me like a fairly straight forward fix. I made the change by copying enablercompleter() to a startup.py file and changing that line to the following:

        if 'PYTHONHISTFILE' in os.environ:
            history = os.path.expanduser(os.environ['PYTHONHISTFILE'])
        elif 'XDG_DATA_HOME' in os.environ:
            history = os.path.join(os.path.expanduser(os.environ['XDG_DATA_HOME']),
                                   'python', 'python_history')
        else:
            history = os.path.join(os.path.expanduser('~'),
                                   '.python_history')

        history = os.path.abspath(history)
        _dir, _ = os.path.split(history)
        os.makedirs(_dir, exist_ok=True)

This enables specifying the history file via PYTHONHISTFILE or using XDG_DATA_HOME. XDG_DATA_HOME is convenient but not necessary as PYTHONHISTFILE would at least provide a work around. One could disable logging by setting PYTHONHISTFILE=/dev/null or whatever it is on Windows.

I apologize for not providing a patch but I have literally no idea where to start for that. I assume addition of environment variables requires iterating on the mailing list first?
History
Date User Action Args
2018-06-01 17:25:59jesse.p.oglesetrecipients: + jesse.p.ogle, pitrou, jwilk, eric.araujo, Arfrever, r.david.murray, Sworddragon, martin.panter
2018-06-01 17:25:59jesse.p.oglesetmessageid: <1527873959.64.0.81473610881.issue20886@psf.upfronthosting.co.za>
2018-06-01 17:25:59jesse.p.oglelinkissue20886 messages
2018-06-01 17:25:59jesse.p.oglecreate