~pythoneers/ubuntu/lucid/python2.6/ltsppa

« back to all changes in this revision

Viewing changes to Lib/getpass.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100311133019-sonignhpjsu6ld0x
Tags: 2.6.5~rc2-0ubuntu1
Python 2.6.5 release candidate 2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        try:
63
63
            old = termios.tcgetattr(fd)     # a copy to save
64
64
            new = old[:]
65
 
            new[3] &= ~termios.ECHO  # 3 == 'lflags'
 
65
            new[3] &= ~(termios.ECHO|termios.ISIG)  # 3 == 'lflags'
 
66
            tcsetattr_flags = termios.TCSAFLUSH
 
67
            if hasattr(termios, 'TCSASOFT'):
 
68
                tcsetattr_flags |= termios.TCSASOFT
66
69
            try:
67
 
                termios.tcsetattr(fd, termios.TCSADRAIN, new)
 
70
                termios.tcsetattr(fd, tcsetattr_flags, new)
68
71
                passwd = _raw_input(prompt, stream, input=input)
69
72
            finally:
70
 
                termios.tcsetattr(fd, termios.TCSADRAIN, old)
 
73
                termios.tcsetattr(fd, tcsetattr_flags, old)
 
74
                stream.flush()  # issue7208
71
75
        except termios.error, e:
72
76
            if passwd is not None:
73
77
                # _raw_input succeeded.  The final tcsetattr failed.  Reraise
125
129
    if prompt:
126
130
        stream.write(prompt)
127
131
        stream.flush()
 
132
    # NOTE: The Python C API calls flockfile() (and unlock) during readline.
128
133
    line = input.readline()
129
134
    if not line:
130
135
        raise EOFError