Skip to content

Commit 9ac2ae2

Browse files
committed
Revert passwd empty string
1 parent 413a9ff commit 9ac2ae2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/getpass.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def unix_getpass(prompt='Password: ', stream=None, mask=None):
4242
4343
Always restores terminal settings before returning.
4444
"""
45-
passwd = ""
45+
passwd = None
4646
with contextlib.ExitStack() as stack:
4747
try:
4848
# Always try reading and writing directly on the tty first.
@@ -82,6 +82,7 @@ def unix_getpass(prompt='Password: ', stream=None, mask=None):
8282
stream.write('\n')
8383
return passwd
8484

85+
passwd = ""
8586
stream.write(prompt)
8687
stream.flush()
8788
while True:
@@ -104,7 +105,7 @@ def unix_getpass(prompt='Password: ', stream=None, mask=None):
104105
termios.tcsetattr(fd, tcsetattr_flags, old)
105106
stream.flush() # issue7208
106107
except termios.error:
107-
if passwd:
108+
if passwd is not None:
108109
# _raw_input succeeded. The final tcsetattr failed. Reraise
109110
# instead of leaving the terminal in an unknown state.
110111
raise

0 commit comments

Comments
 (0)