Jesse Paul Ogle <jesse.p.o...@gmail.com> added the comment:

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?

----------
nosy: +jesse.p.ogle

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue20886>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to