Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
ghost wants to merge1 commit intopython:masterfromunknown repository
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletionsDoc/using/cmdline.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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
Copy link
Member

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

file, by default it will be in ~/.python_history.
Copy link
Member

Choose a reason for hiding this comment

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

``~/.python_history``


.. versionadded:: 3.7

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

Expand Down
21 changes: 14 additions & 7 deletionsLib/site.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -372,6 +372,17 @@ def setcopyright():
defsethelper():
builtins.help=_sitebuiltins._Helper()

defgethistoryfile():
"""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")
ifh!='':
Copy link
Member

Choose a reason for hiding this comment

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

What ifos.environ.get("PYTHONHISTORY") returnsNone?

returnh
returnos.path.join(os.path.expanduser('~'),
'.python_history')

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

ifreadline.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)
exceptIOError:
Expand Down
4 changes: 4 additions & 0 deletionsLib/test/test_site.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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"
Copy link
Member

Choose a reason for hiding this comment

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

Please useEnvironmentVarGuard intest.support to set env variables.

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

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

Expand Down
3 changes: 3 additions & 0 deletionsMisc/NEWS
View file
Open in desktop
Original file line numberDiff line numberDiff 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.
Copy link
Member

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


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

Expand Down
4 changes: 4 additions & 0 deletionsMisc/python.man
View file
Open in desktop
Original file line numberDiff line numberDiff 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.
Copy link
Member

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.


.SH AUTHOR
The Python Software Foundation: https://www.python.org/psf/
.SH INTERNET RESOURCES
Expand Down
3 changes: 2 additions & 1 deletionModules/main.c
View file
Open in desktop
Original file line numberDiff line numberDiff 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";
Copy link
Member

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.


static int
usage(int exitcode, const wchar_t* program)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp