summaryrefslogtreecommitdiffstats
path: root/Lib/getpass.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/getpass.py')
-rw-r--r--Lib/getpass.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py
index 2ac6fd7..dc02bd1 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -47,7 +47,7 @@ def unix_getpass(prompt='Password: ', stream=None):
input = tty
if not stream:
stream = tty
- except EnvironmentError, e:
+ except EnvironmentError as e:
# If that fails, see if stdin can be controlled.
try:
fd = sys.stdin.fileno()
@@ -72,7 +72,7 @@ def unix_getpass(prompt='Password: ', stream=None):
finally:
termios.tcsetattr(fd, tcsetattr_flags, old)
stream.flush() # issue7208
- except termios.error, e:
+ except termios.error as e:
if passwd is not None:
# _raw_input succeeded. The final tcsetattr failed. Reraise
# instead of leaving the terminal in an unknown state.
@@ -92,10 +92,10 @@ def win_getpass(prompt='Password: ', stream=None):
return fallback_getpass(prompt, stream)
import msvcrt
for c in prompt:
- msvcrt.putch(c)
+ msvcrt.putwch(c)
pw = ""
while 1:
- c = msvcrt.getch()
+ c = msvcrt.getwch()
if c == '\r' or c == '\n':
break
if c == '\003':
@@ -104,8 +104,8 @@ def win_getpass(prompt='Password: ', stream=None):
pw = pw[:-1]
else:
pw = pw + c
- msvcrt.putch('\r')
- msvcrt.putch('\n')
+ msvcrt.putwch('\r')
+ msvcrt.putwch('\n')
return pw
@@ -114,13 +114,12 @@ def fallback_getpass(prompt='Password: ', stream=None):
stacklevel=2)
if not stream:
stream = sys.stderr
- print >>stream, "Warning: Password input may be echoed."
+ print("Warning: Password input may be echoed.", file=stream)
return _raw_input(prompt, stream)
def _raw_input(prompt="", stream=None, input=None):
- # A raw_input() replacement that doesn't save the string in the
- # GNU readline history.
+ # This doesn't save the string in the GNU readline history.
if not stream:
stream = sys.stderr
if not input:
@@ -167,12 +166,7 @@ except (ImportError, AttributeError):
try:
import msvcrt
except ImportError:
- try:
- from EasyDialogs import AskPassword
- except ImportError:
- getpass = fallback_getpass
- else:
- getpass = AskPassword
+ getpass = fallback_getpass
else:
getpass = win_getpass
else: