You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When getpass.getuser() fails to fetch the env variables for Windows, it tries to import pwd, this causes an exception "No module named 'pwd'" on line 168
Several months ago I worked on an enhanced implementation of getpass.getuser() in #90789, but no one else and no core developer showed interest. The proposed implementation not only avoids trying to import pwd on Windows, it implements a working alternative for Windows that's based on the logon session of the process token. It's equivalent to the pwd.getpwuid(os.getuid())[0] call on POSIX.
Bug report
When
getpass.getuser()fails to fetch the env variables for Windows, it tries toimport pwd, this causes an exception "No module named 'pwd'" on line 168cpython/Lib/getpass.py
Lines 154 to 169 in f3c23fc
From what I gather, Windows does not have such module, maybe check the platform before importing?
Your environment
The text was updated successfully, but these errors were encountered: