[issue20886] Disabling logging to ~/.python_history is not simple enough

2018-06-01 Thread Jesse Paul Ogle


Jesse Paul Ogle  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2016-05-15 Thread Sworddragon

Sworddragon added the comment:

I'm assuming this means this must be called on every interactive python 
instance. If not just correct me.

While this might be an enhancement it would still be too inconvenient. 
Basically something that can be configured permanently for example with 
~/.bashrc would be the preferred solution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2016-05-14 Thread Martin Panter

Martin Panter added the comment:

Thanks to Issue 26870, in Python 3.6 you should be able to call 
readline.set_auto_history(False) to stop entries being added to the history 
list. Does that change anything here?

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-06-01 Thread Jakub Wilk

Changes by Jakub Wilk :


--
nosy: +jwilk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-11 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +eric.araujo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

On mar., 2014-03-11 at 02:38 +, Arfrever Frehtes Taifersar Arahesis
wrote:
> Arfrever Frehtes Taifersar Arahesis added the comment:
> 
> Antoine Pitrou:
> > What sure not the "panic mode" is about, but in any case you can simply
> > use e.g. "chmod 111 .python_history" (which will forbid both reading and 
> > writing the file).
> 
> It surely does not work:

It probably depends on the OS. It worked here.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-10 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

Antoine Pitrou:
> What sure not the "panic mode" is about, but in any case you can simply
> use e.g. "chmod 111 .python_history" (which will forbid both reading and 
> writing the file).

It surely does not work:

$ rm -f .python_history
$ touch .python_history
$ chmod 111 .python_history
mode of ‘.python_history’ changed from 0640 (rw-r-) to 0111 (--x--x--x)
$ python3.4 -q
>>> 123
123
>>> ^D
$ cat .python_history
123
$

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

What sure not the "panic mode" is about, but in any case you can simply use 
e.g. "chmod 111 .python_history" (which will forbid both reading and writing 
the file).

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-10 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

I would suggest to support PYTHONHISTFILE variable (similar to HISTFILE and 
LESSHISTFILE) and to not replace file pointed by this variable.

This shows that file is being currently replaced:
# cp /dev/null .python_history
# LC_ALL="C" stat -c "%F" .python_history
character special file
# python3.4 -q
>>> ^D
# LC_ALL="C" stat -c "%F" .python_history
regular empty file

--
nosy: +Arfrever

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-10 Thread R. David Murray

R. David Murray added the comment:

readline (all uses of readline, not just by python) can be controlled via the 
'.inputrc' file, which is documented in the readline man page, which should be 
available if readline is available :)  Perhaps this should be mentioned in the 
paragraph(s) where we talk about disabling readline.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20886] Disabling logging to ~/.python_history is not simple enough

2014-03-10 Thread Sworddragon

New submission from Sworddragon:

I have noticed that since Python 3.4 the interactive mode does log all commands 
to ~/.python_history. This caused me to switch into "normal user mode" and look 
for a solution. With Google I have found the related entry in the documentation:

On systems that support readline, this module will also import and configure 
the rlcompleter module, if Python is started in interactive mode and without 
the -S option. The default behavior is enable tab-completion and to use 
~/.python_history as the history save file. To disable it, delete (or override) 
the sys.__interactivehook__ attribute in your sitecustomize or usercustomize 
module or your PYTHONSTARTUP file.


On my system PYTHONSTARTUP is empty and if I would still pretending that I 
would be a normal user I would now get in panic. I think either the 
documentation needs an enhancement or disabling logging should be more 
simplified. For example the shell controls this with the HISTFILESIZE 
environment variable. Maybe Python can use for this case an environment 
variable too that the user can store in his ~/.bashrc.

--
components: Library (Lib)
messages: 213079
nosy: Sworddragon
priority: normal
severity: normal
status: open
title: Disabling logging to ~/.python_history is not simple enough
type: enhancement
versions: Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com