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

Merlijn van Deen report at bugs.python.org
Thu Mar 24 17:12:17 CET 2011

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

> Close similarity with getpass.c 's behavior had lent some to support to this change in 2.6. Changing now in older codeline has some chances of breaking others code.
> Someone who has been affected by this change in behavior should provide some insights if back-porting would make sense.

Most code will probably have been updated their getpass code with a line like

if '\x03' in text:
  raise KeyboardInterrupt()

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

However, people might have changed their code from
  pass = getpass.getpass()
except KeyboardInterrupt:
  print "Ctrl-C!"

pass = getpass.getpass()
if "\x03' in pass:
  print "Ctrl-C!"

which will break with this change. The first workaround makes more sense, though, so I suspect very little code will be broken by reverting the ISIG flag.

Overall, I think most people are not aware of the removal, either because they still use python 2.5 or because they don't press ctrl-c. They are still in for a surprise if the ISIG flag is not removed (although it will probably stay in the 2.6 branch, anyway?).


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list