Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e8f5059

Browse files
committedFeb 21, 2022
Fix python-postgres#90: getuser() on w32 can raise ImportError due to pwd
1 parent f1a57f4 commit e8f5059

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎postgresql/clientparameters.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,17 @@ class ServiceDoesNotExistError(ClientParameterError):
4747
code = '-*srv'
4848

4949
try:
50-
from getpass import getuser, getpass
50+
from getpass import getuser as _getuser, getpass
5151
except ImportError:
5252
getpass = raw_input
5353
def getuser():
5454
return 'postgres'
55+
else:
56+
def getuser():
57+
try:
58+
return _getuser()
59+
except ImportError: # w32 doesn't have module pwd
60+
return 'postgres'
5561

5662
default_host = 'localhost'
5763
default_port = 5432

0 commit comments

Comments
 (0)
Please sign in to comment.