patches/Python26-21-getpass.diff
author yippi
Mon, 27 Sep 2010 21:07:51 +0000
changeset 20108 51df67ca9307
parent 20043 a139d9d7ce35
permissions -rw-r--r--
I had these modules listed as being owned by me, but they are really owned by wangke, correcting.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20043
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     1
--- trunk/Lib/getpass.py	2009/10/31 21:23:39	75999
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     2
+++ trunk/Lib/getpass.py	2009/10/31 21:26:08	76000
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     3
@@ -62,12 +62,16 @@
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     4
         try:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     5
             old = termios.tcgetattr(fd)     # a copy to save
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     6
             new = old[:]
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     7
-            new[3] &= ~termios.ECHO  # 3 == 'lflags'
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     8
+            new[3] &= ~(termios.ECHO|termios.ISIG)  # 3 == 'lflags'
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
     9
+            tcsetattr_flags = termios.TCSAFLUSH
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    10
+            if hasattr(termios, 'TCSASOFT'):
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    11
+                tcsetattr_flags |= termios.TCSASOFT
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    12
             try:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    13
-                termios.tcsetattr(fd, termios.TCSADRAIN, new)
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    14
+                termios.tcsetattr(fd, tcsetattr_flags, new)
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    15
                 passwd = _raw_input(prompt, stream, input=input)
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    16
             finally:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    17
-                termios.tcsetattr(fd, termios.TCSADRAIN, old)
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    18
+                termios.tcsetattr(fd, tcsetattr_flags, old)
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    19
+                stream.flush()  # issue7208
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    20
         except termios.error, e:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    21
             if passwd is not None:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    22
                 # _raw_input succeeded.  The final tcsetattr failed.  Reraise
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    23
@@ -125,6 +129,7 @@
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    24
     if prompt:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    25
         stream.write(prompt)
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    26
         stream.flush()
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    27
+    # NOTE: The Python C API calls flockfile() (and unlock) during readline.
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    28
     line = input.readline()
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    29
     if not line:
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    30
         raise EOFError
a139d9d7ce35 2010-09-08 Ghee Teo <[email protected]>
gheet
parents: 20042
diff changeset
    31