import getpass
import errno


def _getpass(prompt):
    """
    Helper to turn IOErrors into KeyboardInterrupts.
    """
    try:
        return getpass.getpass(prompt)
    except IOError as e:
        if e.errno == errno.EINTR:
            raise KeyboardInterrupt
        raise
    except EOFError:
        raise KeyboardInterrupt