Index: Lib/getpass.py =================================================================== --- Lib/getpass.py (revision 43488) +++ Lib/getpass.py (working copy) @@ -15,10 +15,14 @@ __all__ = ["getpass","getuser"] -def unix_getpass(prompt='Password: '): +def unix_getpass(prompt='Password: ', stream=None): """Prompt for a password, with echo turned off. + The caller can pass a stream to this function + to write output to. The default stream is stdout. + Restore terminal settings at end. + """ try: @@ -36,7 +40,10 @@ finally: termios.tcsetattr(fd, termios.TCSADRAIN, old) - sys.stdout.write('\n') + if stream is None: + stream = sys.stdout + + stream.write('\n') return passwd