Issue 29779: New environment variable PYTHONHISTORY (original) (raw)

Created on 2017-03-10 07:40 by 0xl3vi, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 473 closed 0xl3vi,2017-03-10 07:40
PR 13208 open ZackerySpytz,2019-05-08 19:17
Messages (5)
msg289342 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-10 08:10
$HISTFILE is the name of the file in which Bash command history is saved. Shouldn't the name of similar environment variable for Python be PYTHONHISTFILE? Bash uses several environment variables for control its command history: HISTCONTROL, HISTFILE, HISTFILESIZE, HISTIGNORE, HISTSIZE, HISTTIMEFORMAT. Does Python need corresponding environment variables? Wouldn't be better to control all these details by Python code in .pythonrc.py rather than by environment variables? For example I have the following code in my .pythonrc.py: if sys.version_info < (3,): try: import readline, os, atexit histfile = os.path.join(os.path.expanduser("~"), ".python2_history") try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile except ImportError: pass
msg289402 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-03-10 18:57
I don't think the Python envar has to follow the contraction from bash. PYTHONHISTORYreadsverynicely.IhavesimilarcodeinmyPYTHONHISTORY reads very nicely. I have similar code in my PYTHONHISTORYreadsverynicely.IhavesimilarcodeinmyPYTHONSTARTUP, but it would be nice to be able to get rid of it and just let Python do the common thing.
msg289497 - (view) Author: (yan12125) * Date: 2017-03-12 11:42
That's a great feature! Here's a question: what should be CPython's behavior when PYTHONHISTORY is explicitly set to empty? Currently there's an error: $ PYTHONHISTORY= ./python Python 3.7.0a0 (master:f6595983e08fe20cf06a2535d74d912c6dbb044f, Mar 12 2017, 19:22:29) [GCC 6.3.1 20170306] on linux Type "help", "copyright", "credits" or "license" for more information. >>> Error in atexit._run_exitfuncs: FileNotFoundError: [Errno 2] No such file or directory Maybe it's better to just disable the history functionality in this case? By the way, seems comments starting from https://github.com/python/cpython/pull/473/files#diff-f34a16518c608b2ca946d3f5ca0a1942R419 should be updated too.
msg289624 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2017-03-14 22:05
On Mar 12, 2017, at 11:42 AM, Chi Hsuan Yen wrote: >That's a great feature! Here's a question: what should be CPython's behavior >when PYTHONHISTORY is explicitly set to empty? Currently there's an error: > >$ PYTHONHISTORY= ./python >Python 3.7.0a0 (master:f6595983e08fe20cf06a2535d74d912c6dbb044f, Mar 12 2017, 19:22:29) >[GCC 6.3.1 20170306] on linux >Type "help", "copyright", "credits" or "license" for more information. >>>> >Error in atexit._run_exitfuncs: >FileNotFoundError: [Errno 2] No such file or directory Yeah, that's not good. I'll note that in the PR. (But also note that you have to unset PYTHONSTARTUP if you, like me, use that as the old school way of enabling history.) >Maybe it's better to just disable the history functionality in this case? It should use the default, but it shouldn't cause an error.
msg343375 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-05-24 11:34
PR 473 was closed by its author. I have created a new pull request (PR 13208) that addresses all of Berker Peksag's comments on the old PR. Please have a look.
History
Date User Action Args
2022-04-11 14:58:44 admin set github: 73965
2019-05-24 11:34:21 ZackerySpytz set nosy: + ZackerySpytzmessages: + versions: + Python 3.8, - Python 3.7
2019-05-08 19:17:03 ZackerySpytz set keywords: + patchpull_requests: + <pull%5Frequest13119>
2017-03-22 08:51:06 berker.peksag set nosy: + berker.peksagtype: enhancementcomponents: + Library (Lib)stage: patch review
2017-03-14 22:05:22 barry set messages: +
2017-03-12 11:42:51 yan12125 set messages: +
2017-03-12 11:13:54 yan12125 set nosy: + yan12125
2017-03-10 18:57:13 barry set messages: +
2017-03-10 18:54:06 barry set nosy: + barry
2017-03-10 08:10:24 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2017-03-10 07:40:03 0xl3vi create