Fixing the error 'must be char, not unicode' that happens on Windows for default Python getpass function

This commit is contained in:
Heitor Silva 2016-01-06 11:47:16 -02:00
parent bd8ea77e79
commit 4fa6e6ff09

View file

@ -28,7 +28,12 @@ log = logging.getLogger(__name__)
def getpass(prompt="Password: "):
if not TEST:
return gp.getpass(prompt)
try:
passwd = gp.getpass(prompt)
except TypeError:
passwd = gp.getpass(prompt.encode('ascii', 'ignore'))
return passwd
else:
return py23_input(prompt)