GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-29779: new environment variable PYTHONHISTORY. · Pull Request #473 · python/cpython

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.

Sign up for GitHub

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

Closed
ghost wants to merge 1 commit into python:master from unknown repository

Uh oh!

There was an error while loading. Please reload this page.

Closed

bpo-29779: new environment variable PYTHONHISTORY. #473

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
5baa03e
bpo-29779: new environment variable PYTHONHISTORY.
Mar 15, 2017
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

7 changes: 7 additions & 0 deletions 7 Doc/using/cmdline.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,13 @@ conflict.

.. versionadded:: 3.6

.. envvar:: PYTHONHISTORY

If set to a non-empty string, you can change the location of a python_history
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
file, by default it will be in ~/.python_history.
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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``

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

.. versionadded:: 3.7

Debug-mode variables
~~~~~~~~~~~~~~~~~~~~

Expand Down
21 changes: 14 additions & 7 deletions 21 Lib/site.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ def setcopyright():
def sethelper():
builtins.help = _sitebuiltins._Helper()

def gethistoryfile():
"""Check if PYTHONHISTORY environment variable
is set and define it as python_history file,
if not use the default ~/.python_history file.
"""
h = os.environ.get("PYTHONHISTORY")
if h != '':
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
return h
return os.path.join(os.path.expanduser('~'),
'.python_history')

def enablerlcompleter():
"""Enable default readline configuration on interactive prompts, by
registering a sys.__interactivehook__.
Expand Down Expand Up @@ -407,13 +418,9 @@ def register_readline():
pass

if readline.get_current_history_length() == 0:
# If no history was loaded, default to .python_history.
# The guard is necessary to avoid doubling history size at
# each interpreter exit when readline was already configured
# through a PYTHONSTARTUP hook, see:
# http://bugs.python.org/issue5845#msg198636
history = os.path.join(os.path.expanduser('~'),
'.python_history')
# If no history was loaded, default to .python_history,
# or PYTHONHISTORY.
history = gethistoryfile()
try:
readline.read_history_file(history)
except IOError:
Expand Down
4 changes: 4 additions & 0 deletions 4 Lib/test/test_site.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ def test_getsitepackages(self):
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)

def test_gethistoryfile(self):
os.environ['PYTHONHISTORY'] = "xoxo"
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
self.assertEqual(site.gethistoryfile(), "xoxo")

class PthFile(object):
"""Helper class for handling testing of .pth files"""

Expand Down
3 changes: 3 additions & 0 deletions 3 Misc/NEWS
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
-----------------

- bpo-29779: New environment variable PYTHONHISTORY if
this is set you can change the location of a python_history file.
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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."

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

- bpo-28856: Fix an oversight that %b format for bytes should support objects
follow the buffer protocol.

Expand Down
4 changes: 4 additions & 0 deletions 4 Misc/python.man
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ values.

The integer must be a decimal number in the range [0,4294967295]. Specifying
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.
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

.SH AUTHOR
The Python Software Foundation: https://www.python.org/psf/
.SH INTERNET RESOURCES
Expand Down
3 changes: 2 additions & 1 deletion 3 Modules/main.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ static const char usage_6[] =
" predictable seed.\n"
"PYTHONMALLOC: set the Python memory allocators and/or install debug hooks\n"
" 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";
Comment thread

@berkerpeksag berkerpeksag Mar 22, 2017

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

static int
usage(int exitcode, const wchar_t* program)
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.