Skip to content
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

bpo-29779: New environment variable PYTHONHISTORY #13208

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented May 8, 2019

It can be used to set the location of a .python_history file.

Co-Authored-By: Levi Sabah 0xl3vi@gmail.com

https://bugs.python.org/issue29779

It can be used to set the location of a .python_history file.

Co-Authored-By: Levi Sabah <0xl3vi@gmail.com>
Doc/using/cmdline.rst Outdated Show resolved Hide resolved
Lib/site.py Outdated Show resolved Hide resolved
Lib/site.py Outdated Show resolved Hide resolved
Misc/python.man Outdated
@@ -502,6 +502,9 @@ show how long each import takes. This is exactly equivalent to setting
.IP PYTHONBREAKPOINT
If this environment variable is set to 0, it disables the default debugger. It
can be set to the callable of your debugger of choice.
.IP PYTHONHISTORY
This environment variable can be used to set the location of a history file
(it is \fI~/.python_history\fP by default).
Copy link
Member

@pablogsal pablogsal May 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the windows default as well.

Copy link
Contributor Author

@ZackerySpytz ZackerySpytz May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be frank, I'm not sure if the Windows default should be mentioned in the man page...

Copy link

@eabase eabase Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing wrong with mentioning Windows ops in man pages.

@tirkarthi
Copy link
Member

@tirkarthi tirkarthi commented May 11, 2019

There are few other places in Docs where hardcoded value of ~/.python_history is referred to.

$ rg python_history Doc
Doc/tutorial/interactive.rst
28:history into a file named :file:`.python_history` in your user directory.

Doc/library/readline.rst
292:file named :file:`.python_history` from the user's home directory.  The code
300:   histfile = os.path.join(os.path.expanduser("~"), ".python_history")
319:   histfile = os.path.join(os.path.expanduser("~"), ".python_history")

Doc/library/site.rst
135::file:`~/.python_history` as the history save file.  To disable it, delete (or

@ZackerySpytz
Copy link
Contributor Author

@ZackerySpytz ZackerySpytz commented May 14, 2019

@tirkarthi The first three cases mention .python_history, not ~/.python_history, no?

The fourth case mentions ~/.python_history in the context of the readline
module, which is not available on Windows. So, I'm not sure if those parts of
the docs need to be modified.

@ZackerySpytz
Copy link
Contributor Author

@ZackerySpytz ZackerySpytz commented May 15, 2019

By the way, on Windows, os.path.expanduser("~") returns (for example) 'C:\\Users\\Tim'.

Copy link
Member

@tiran tiran left a comment

The new env var does not obey the sys.flags.ignore_environment flag. Please add a test that the new env var is ignored with -E or -I mode.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 15, 2019

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@tiran
Copy link
Member

@tiran tiran commented May 15, 2019

Could you please reword to explain what the history file actually does? It's non-obvious to users that are not familiar with readline module internals.

Lib/site.py Show resolved Hide resolved
@ZackerySpytz
Copy link
Contributor Author

@ZackerySpytz ZackerySpytz commented May 19, 2019

I have made the requested changes; please review again.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 19, 2019

Thanks for making the requested changes!

@tiran: please review the changes made to this pull request.

@ZackerySpytz
Copy link
Contributor Author

@ZackerySpytz ZackerySpytz commented May 19, 2019

Could you please reword to explain what the history file actually does?

Reword what?

@vszakats
Copy link

@vszakats vszakats commented Aug 28, 2019

Can this be merged? It seems fairly obvious what .python_history means and it'd be quite nice to be able to control where it goes.

@EmilRehnberg
Copy link

@EmilRehnberg EmilRehnberg commented Dec 30, 2019

Thanks for this!

Please make sure there will be no problem with paths with subdirectories that might not be created. E.g. "export PYTHONHISTORY=$HOME/.cache/python/history please assert that the path will be created if missing.

@wren
Copy link

@wren wren commented Jul 4, 2020

Any way to help get this through? It looks like it's been ready for a while.

@ZLima12
Copy link

@ZLima12 ZLima12 commented Sep 23, 2020

I'd like to see this merged as well; if there's anything I can do, I'd be happy to help.

@nash-pillai
Copy link

@nash-pillai nash-pillai commented Aug 28, 2021

I would like this feature very much. @tiran and @pablogsal, please review this soon.

@i2
Copy link

@i2 i2 commented Oct 22, 2021

What is the holdup for this merge?

@warsaw
Copy link
Member

@warsaw warsaw commented Oct 22, 2021

Looks like there are conflicts now which need to be resolved, and probably rebased.

@eabase
Copy link

@eabase eabase commented Jan 24, 2022

Guys, why on earth are you hard-coding a commonly used and often changed file-path like this?

I was sincerely expecting to find an internal built-in variable named something like DEFAULT_HISTORY_FILE, but to my unpleasant surprise, I instead find history = os.path.join(os.path.expanduser('~'),'.python_history').

While at the same time being met with:

readline.write_history_file.__doc__
# 'Save a readline history file. The default filename is ~/.history.'

@lucas-mior

This comment was marked as disruptive content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet