Skip to content

Commit

Permalink
Fix python-postgres#90: getuser() on w32 can raise ImportError due to…
Browse files Browse the repository at this point in the history
… pwd
  • Loading branch information
phdru committed Feb 21, 2022
1 parent f1a57f4 commit e8f5059
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion postgresql/clientparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ class ServiceDoesNotExistError(ClientParameterError):
code = '-*srv'

try:
from getpass import getuser, getpass
from getpass import getuser as _getuser, getpass
except ImportError:
getpass = raw_input
def getuser():
return 'postgres'
else:
def getuser():
try:
return _getuser()
except ImportError: # w32 doesn't have module pwd
return 'postgres'

default_host = 'localhost'
default_port = 5432
Expand Down

0 comments on commit e8f5059

Please sign in to comment.