http://www.mediawiki.org/wiki/Special:Code/pywikipedia/8978
Revision: 8978 Author: valhallasw Date: 2011-02-17 21:05:08 +0000 (Thu, 17 Feb 2011) Log Message: ----------- Added manual check for ctrl-C in getpass input. Fixes PYWP-13.
A bug in the getpass library makes it not respond to command characters such as ctrl-Z and ctrl-C in python 2.6+. This adds a manual check for ctrl-C characters in the password and raises an Exception if found.
See also: http://bugs.python.org/issue11236
Modified Paths: -------------- branches/rewrite/pywikibot/userinterfaces/terminal_interface.py
Modified: branches/rewrite/pywikibot/userinterfaces/terminal_interface.py =================================================================== --- branches/rewrite/pywikibot/userinterfaces/terminal_interface.py 2011-02-17 20:27:53 UTC (rev 8977) +++ branches/rewrite/pywikibot/userinterfaces/terminal_interface.py 2011-02-17 21:05:08 UTC (rev 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: