[issue11236] getpass.getpass does not respond to ctrl-c or ctrl-z

Merlijn van Deen report at bugs.python.org
Thu Feb 17 22:09:13 CET 2011


Merlijn van Deen <valhallasw at gmail.com> added the comment:

To allow people to cancel at the password prompt, we added a manual post-check. Although this check runs after return is pressed, it's better than nothing.

Index: branches/rewrite/pywikibot/userinterfaces/terminal_interface.py
===================================================================
--- branches/rewrite/pywikibot/userinterfaces/terminal_interface.py	(revision 8977)
+++ branches/rewrite/pywikibot/userinterfaces/terminal_interface.py	(revision 8978)
@@ -175,6 +175,11 @@
             if password:
                 import getpass
                 text = getpass.getpass('')
+                # See PYWP-13 / http://bugs.python.org/issue11236
+                # getpass does not always raise an KeyboardInterrupt when ^C
+                # is pressed.
+                if '\x03' in text:
+                    raise KeyboardInterrupt()
             else:
                 text = raw_input()
         finally:

http://www.mediawiki.org/wiki/Special:Code/pywikipedia/8978

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11236>
_______________________________________


More information about the Python-bugs-list mailing list