Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-29779: new environment variable PYTHONHISTORY.#473
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
the-knights-who-say-ni commented Mar 5, 2017
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:
Thanks again to your contribution and we look forward to looking at it! |
mention-bot commented Mar 5, 2017
@0xl3vi, thanks for your PR! By analyzing the history of the files in this pull request, we identified @brettcannon, @tiran, @vsajip, @doko42 and @freddrake to be potential reviewers. |
ghost commented Mar 5, 2017
I signed the CLA 😉 |
warsaw commented Mar 5, 2017
This is a nice change, and it would probably let me get rid of my $PYTHONSTARTUP setting. I wonder if |
ghost commented Mar 8, 2017
@warsaw I added this to Misc/python.man |
warsaw commented Mar 8, 2017
@0xl3vi Thanks, that looks good. It's still not mentioned in |
warsaw left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with one very minor style nit.
Lib/site.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor style nit: You don't need this extra blank line.
ghost commented Mar 9, 2017
@warsaw I updated main.c for |
warsaw commented Mar 9, 2017
The changes look great to me, but I'm going to wait just a bit before merging this.
I don't have a Windows environment to test that on. Maybe @zooba can weigh in on that. Alternatively, try rebasing against master if it's been fixed there. If there are no other follow ups by this weekend, I'll merge your change. Can you please also add a |
ned-deily left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variables are also documented in the Python Setup and Usage document (https://docs.python.org/3/using/cmdline.html#environment-variables) which is generated from Doc/using/cmdline.rst.
ned-deily commented Mar 9, 2017
Also there should be an issue opened on bugs.python.org to document this and the issue number added to the title of this pull request. |
ghost commented Mar 10, 2017
@warsaw I tried rebasing against master and the build passed! @ned-deily I updated cmdline.rst and created new issue http://bugs.python.org/issue29779 P.S: I need to add bpo-XXX or just the issue number in bugs.python.org? |
warsaw left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of other thoughts on the implementation and NEWS file entry.
Lib/site.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do something like:
returnos.environ.get( 'PYTHONHISTORY', os.path.expanduser(os.path.join('~', '.python_history')))Also set_history_file() is a little bit of a misnomer since it's not actually setting it, but calculating it instead. OTOH, I bet the more compact form could just be inlined below.
Misc/NEWS Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change Issue #29779 to bpo-29779. That's the new style of marking issue numbers.
warsaw commented Mar 10, 2017
Oh, and it would be nice to add a test for codecov. |
ned-deily commented Mar 10, 2017
Thanks for addressing my comments! |
ghost commented Mar 10, 2017 • edited by ghost
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by ghost
Uh oh!
There was an error while loading. Please reload this page.
@warsaw all done, I changed set_history_file() to gethistoryfile(). |
warsaw commented Mar 14, 2017
@0xl3vi We still need a test. |
warsaw commented Mar 14, 2017
Oh and yay for Misc/NEWS conflicts. :( |
warsaw commented Mar 14, 2017
Also note this report which I can confirm. |
ghost commented Mar 15, 2017
warsaw commented Mar 15, 2017
@0xl3vi At the very least, I think a test covering The bug happens when the file pointed to by |
this patch adds new environment variable PYTHONHISTORY, with this you can change the location of a python_history file, without using readline hook in PYTHONSTARTUP. In case PYTHONHISTORY will be empty or not set, it wil fall back to the default history file.
ghost commented Mar 15, 2017 • edited by ghost
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by ghost
Uh oh!
There was an error while loading. Please reload this page.
@warsaw OK updated.
The test checks if gethistoryfile() reads the variable. what do you think? |
berkerpeksag left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be documented in Doc/whatsnew/3.7.rst (and please add "(Contributed by Your Name.)")
Thanks!
| .. envvar:: PYTHONHISTORY | ||
| If set to a non-empty string, you can change the location of a python_history | ||
| file, by default it will be in ~/.python_history. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``~/.python_history``
| .. envvar:: PYTHONHISTORY | ||
| If set to a non-empty string, you can change the location of a python_history |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a ``.python_history`` file" or just "a history file".
| if not use the default ~/.python_history file. | ||
| """ | ||
| h = os.environ.get("PYTHONHISTORY") | ||
| if h != '': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if os.environ.get("PYTHONHISTORY") returns None?
| self.assertEqual(dirs[1], wanted) | ||
| def test_gethistoryfile(self): | ||
| os.environ['PYTHONHISTORY'] = "xoxo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use EnvironmentVarGuard in test.support to set env variables.
| ----------------- | ||
| - bpo-29779: New environment variable PYTHONHISTORY if | ||
| this is set you can change the location of a python_history file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add "Patch by Your Name."
| the value 0 will disable hash randomization. | ||
| .IP PYTHONHISTORY | ||
| If this is set you can change the location of a | ||
| python_history file, by default it will be ~/.python_history. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File names should be italic in man pages so \fI~/.python_history\fI or
python_history file, by default it will be .IR ~/.python_history .You may need to escape ~ or / characters.
| " on Python memory allocators. Use PYTHONMALLOC=debug to install debug\n" | ||
| " hooks.\n" | ||
| " hooks.\n" | ||
| "PYTHONHISTORY: If this is set, you can change the location of a python_history file.\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a bit long.
ghost commented Mar 23, 2017
OK, I don't have time to do it. |
warsaw commented Mar 27, 2017
@0xl3vi Hi. I'm sorry this has taken so long. Are you saying in your comment that you don't have time to finish this branch? If so, that's okay and we greatly appreciate your contribution so far. I'm willing to finish this branch for you if you'd like. |
ghost commented Mar 28, 2017
@warsaw sure if you want. |
ZackerySpytz commented May 15, 2019
@warsaw@berkerpeksag I have created a new PR for this feature: GH-13208. It addresses all of @berkerpeksag's comments. |
Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 1.1.0 to 1.3.1. - [Release notes](https://github.com/getsentry/sentry-python/releases) - [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md) - [Commits](getsentry/sentry-python@1.1.0...1.3.1) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
if this variable is set the user can change the location of
a ~/.python_history file without adding hook to PYTHONSTARTUP.