summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-01-24 19:09:56 (GMT)
committerBarry Warsaw <barry@python.org>2018-01-24 19:09:56 (GMT)
commit196b8cbab2b5044b92077f0b3c07c798fff68bc6 (patch)
tree0c676fd799bdde70221675c30d868a20341af7f6 /Doc
parentfd844efa9c31e1f00e04b07940875b9dacff3d77 (diff)
downloadcpython-196b8cbab2b5044b92077f0b3c07c798fff68bc6.zip
cpython-196b8cbab2b5044b92077f0b3c07c798fff68bc6.tar.gz
cpython-196b8cbab2b5044b92077f0b3c07c798fff68bc6.tar.bz2
bpo-32651 Recommend getpass.getuser() (GH-5301) (#5304)
* bpo-32651 - In the documentation for os.getlogin(), recommend getpass.getuser() (cherry picked from commit d499031f5f33c3ef71be7c81ef52eee6b47c42e1)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/getpass.rst10
-rw-r--r--Doc/library/os.rst9
2 files changed, 11 insertions, 8 deletions
diff --git a/Doc/library/getpass.rst b/Doc/library/getpass.rst
index 5eb9f04..82b1191 100644
--- a/Doc/library/getpass.rst
+++ b/Doc/library/getpass.rst
@@ -42,8 +42,10 @@ The :mod:`getpass` module provides two functions:
Return the "login name" of the user.
This function checks the environment variables :envvar:`LOGNAME`,
- :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and returns
- the value of the first one which is set to a non-empty string. If none are set,
- the login name from the password database is returned on systems which support
- the :mod:`pwd` module, otherwise, an exception is raised.
+ :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and
+ returns the value of the first one which is set to a non-empty string. If
+ none are set, the login name from the password database is returned on
+ systems which support the :mod:`pwd` module, otherwise, an exception is
+ raised.
+ In general, this function should be preferred over :func:`os.getlogin()`.
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index 974ab2d..b272216 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -325,10 +325,11 @@ process and user.
.. function:: getlogin()
Return the name of the user logged in on the controlling terminal of the
- process. For most purposes, it is more useful to use the environment
- variables :envvar:`LOGNAME` or :envvar:`USERNAME` to find out who the user
- is, or ``pwd.getpwuid(os.getuid())[0]`` to get the login name of the current
- real user id.
+ process. For most purposes, it is more useful to use
+ :func:`getpass.getuser` since the latter checks the environment variables
+ :envvar:`LOGNAME` or :envvar:`USERNAME` to find out who the user is, and
+ falls back to ``pwd.getpwuid(os.getuid())[0]`` to get the login name of the
+ current real user id.
Availability: Unix, Windows.