mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
gh-76912: Raise OSError from any failure in getpass.getuser() (#29739)
* bpo-32731: Raise OSError from any failure in getpass.getuser() Previously, if the username was not set in certain environment variables, ImportError escaped on Windows systems, and it was possible for KeyError to escape on other systems if getpwuid() failed.
This commit is contained in:
parent
936c503a44
commit
99a73c3465
5 changed files with 24 additions and 7 deletions
|
|
@ -46,7 +46,10 @@ The :mod:`getpass` module provides two functions:
|
|||
: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.
|
||||
systems which support the :mod:`pwd` module, otherwise, an :exc:`OSError`
|
||||
is raised.
|
||||
|
||||
In general, this function should be preferred over :func:`os.getlogin()`.
|
||||
|
||||
.. versionchanged:: 3.13
|
||||
Previously, various exceptions beyond just :exc:`OSError` were raised.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue