[Python-bugs-list] getpass.getpass (PR#349)

ctalley@caci.com ctalley@caci.com
Thu, 8 Jun 2000 15:52:20 -0400 (EDT)


Full_Name: Carl Talley
Version: 1.5.2
OS: W95
Submission from: (NULL) (199.249.193.112)


When using this code, the third line is skipped.  That is, the prompt
appears, but the program doesn't pause to accept input data.  It goes
right to the fourth line and pauses there.  I end up with a null string
for "fromaddr".

username=raw_input('Enter FTP server account username: ')
password=getpass.getpass('Enter FTP server account password: ')
fromaddr=raw_input('Enter your e-mail address: ')
toaddr=raw_input('Enter e-mail address for notification: ')

When using this code, everything works (although echo of the
password isn't suppressed.)

username=raw_input('Enter FTP server account username: ')
password=raw_input('Enter FTP server account password: ')
fromaddr=raw_input('Enter your e-mail address: ')
toaddr=raw_input('Enter e-mail address for notification: ')

The difference between the two code segments is that the first uses
the getpass method on the second line and the second uses raw_input.
What I think is happening is that getpass is leaving some garbage
in a buffer somewhere which is seen by raw_input as data.  raw_input
happily accepts the data and goes to the next line.  I've devised
several workarounds including "flush_input_buffer=raw_input('')"
immediately following the call to getpass.  It's ugly, but it works.

Thanks,
Carl Talley