diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-03-09 16:03:30 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-03-09 16:03:30 (GMT) |
commit | 4e40cec924d5c2cac4c3b6755fe390c94404fa86 (patch) | |
tree | d5aacce8123cba58af787d5dc9c0cd827569e490 | |
parent | 04ea3f35bd0bbaa1afdf5d39c60b7087a03ddd2f (diff) | |
download | cpython-4e40cec924d5c2cac4c3b6755fe390c94404fa86.zip cpython-4e40cec924d5c2cac4c3b6755fe390c94404fa86.tar.gz cpython-4e40cec924d5c2cac4c3b6755fe390c94404fa86.tar.bz2 |
whatsnew: sys.__interactivehook__. (#5845)
I decided to leave the (slightly expanded) Other Improvements
entry as well, since someone looking for command line behavior
changes isn't going to look in the 'sys' module section.
-rw-r--r-- | Doc/library/site.rst | 10 | ||||
-rw-r--r-- | Doc/library/sys.rst | 9 | ||||
-rw-r--r-- | Doc/whatsnew/3.4.rst | 17 |
3 files changed, 28 insertions, 8 deletions
diff --git a/Doc/library/site.rst b/Doc/library/site.rst index d93e938..2fdf303 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -123,9 +123,13 @@ On systems that support :mod:`readline`, this module will also import and configure the :mod:`rlcompleter` module, if Python is started in :ref:`interactive mode <tut-interactive>` and without the :option:`-S` option. The default behavior is enable tab-completion and to use -:file:`~/.python_history` as the history save file. To disable it, override -the :data:`sys.__interactivehook__` attribute in your :mod:`sitecustomize` -or :mod:`usercustomize` module or your :envvar:`PYTHONSTARTUP` file. +:file:`~/.python_history` as the history save file. To disable it, delete (or +override) the :data:`sys.__interactivehook__` attribute in your +:mod:`sitecustomize` or :mod:`usercustomize` module or your +:envvar:`PYTHONSTARTUP` file. + +.. versionchanged:: 3.4 + Activation of rlcompleter and history was made automatic. Module contents diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 5ff7178..ab612c2 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -692,10 +692,11 @@ always available. .. data:: __interactivehook__ - When present, this function is automatically called (with no arguments) - when the interpreter is launched in :ref:`interactive mode <tut-interactive>`. - This is done after the :envvar:`PYTHONSTARTUP` file is read, so that you - can set this hook there. + When this attribute exists, its value is automatically called (with no + arguments) when the interpreter is launched in :ref:`interactive mode + <tut-interactive>`. This is done after the :envvar:`PYTHONSTARTUP` file is + read, so that you can set this hook there. The :mod:`site` module + :ref:`sets this <rlcompleter-config>`. .. versionadded:: 3.4 diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst index 7681fae..c8791e4 100644 --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -1360,6 +1360,19 @@ blocks allocated by the interpreter (in CPython with the default especially if automated via a test suite. (Contributed by Antoine Pitrou in :issue:`13390`.) +When the Python interpreter starts in :ref:`interactive mode +<tut-interactive>`, it checks for an :data:`~sys.__interactivehook__` attribute +on the :mod:`sys` module. If the attribute exists, its value is called with no +arguments just before interactive mode is started. The check is made after the +:envvar:`PYTHONSTARTUP` file is read, so it can be set there. The :mod:`site` +module :ref:`sets it <rlcompleter-config>` to a function that enables tab +completion and history saving (in :file:`~/.python-history`) if the platform +supports :mod:`readline`. If you do not want this (new) behavior, you can +override it in :envvar:`PYTHONSTARTUP`, :mod:`sitecustomize`, or +:mod:`usercustomize` by deleting this attribute from :mod:`sys` (or setting it +to some other callable). (Contributed by Éric Araujo and Antoine Pitrou in +:issue:`5845`.) + textwrap -------- @@ -1694,7 +1707,9 @@ Other Improvements most POSIX systems it can and should be used in the ``#!`` line of system scripts. (Contributed by Christian Heimes in :issue:`16499`.) -* Tab-completion is now enabled by default in the interactive interpreter. +* Tab-completion is now enabled by default in the interactive interpreter + on systems that support :mod:`readline`. History is also enabled by default, + and is written to (and read from) the file :file:`~/.python-history`. (Contributed by Antoine Pitrou and Éric Araujo in :issue:`5845`.) * Invoking the Python interpreter with ``--version`` now outputs the version to |