diff --git a/Doc/library/getpass.rst b/Doc/library/getpass.rst index 82b11919a3d2bf..65d8aaece1a4e3 100644 --- a/Doc/library/getpass.rst +++ b/Doc/library/getpass.rst @@ -43,9 +43,10 @@ The :mod:`getpass` module provides two functions: 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. + returns the value of the first one which is set to a non-empty string. + If none are set, the function attempts to retrieve the login name from the + password database. On systems which the :mod:`pwd` module is not supported, + an :exc:`ImportError` is raised. If no login name is found, an + :exc:`KeyError` is raised :func:`pwd.getpwuid`. In general, this function should be preferred over :func:`os.getlogin()`. diff --git a/Misc/NEWS.d/next/Documentation/2018-02-11-03-23-36.bpo-32731.eHIUEe.rst b/Misc/NEWS.d/next/Documentation/2018-02-11-03-23-36.bpo-32731.eHIUEe.rst new file mode 100644 index 00000000000000..a44f0f607c103b --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2018-02-11-03-23-36.bpo-32731.eHIUEe.rst @@ -0,0 +1 @@ +Improve documentation of exception raised in :func:`getpass.getuser()`