diff options
author | Guido van Rossum <guido@python.org> | 1998-06-12 14:28:38 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-06-12 14:28:38 (GMT) |
commit | c3da02e9041cfaf8e6e43b726f23b2676a05eb1a (patch) | |
tree | f2345998fdadc8cf2a78f5eddcb8985916a535b3 /Lib/getpass.py | |
parent | e7c4193755843e308df180f3014cea214fbf6dc5 (diff) | |
download | cpython-c3da02e9041cfaf8e6e43b726f23b2676a05eb1a.zip cpython-c3da02e9041cfaf8e6e43b726f23b2676a05eb1a.tar.gz cpython-c3da02e9041cfaf8e6e43b726f23b2676a05eb1a.tar.bz2 |
Don't catch interrupts in getpass() -- the finally clause will reset
the tty and the caller can deal with the interrupt.
In the windows version, recognize ^C and raise KeyboardInterrupt (not
sure if this is needed, but can't hurt).
Diffstat (limited to 'Lib/getpass.py')
-rw-r--r-- | Lib/getpass.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/getpass.py b/Lib/getpass.py index 8bd7523..d67240e 100644 --- a/Lib/getpass.py +++ b/Lib/getpass.py @@ -36,8 +36,7 @@ def getpass(prompt='Password: '): new[3] = new[3] & ~TERMIOS.ECHO # 3 == 'lflags' try: termios.tcsetattr(fd, TERMIOS.TCSADRAIN, new) - try: passwd = raw_input(prompt) - except KeyboardInterrupt: passwd = None + passwd = raw_input(prompt) finally: termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old) @@ -55,6 +54,8 @@ def win_getpass(prompt='Password: '): c = msvcrt.getch() if c == '\r' or c == '\n': break + if c == '\003': + raise KeyboardInterrupt if c == '\b': pw = pw[:-1] else: |