equal
deleted
inserted
replaced
190 def _isatty(fp): |
190 def _isatty(fp): |
191 try: |
191 try: |
192 return fp.isatty() |
192 return fp.isatty() |
193 except AttributeError: |
193 except AttributeError: |
194 return False |
194 return False |
|
195 |
|
196 |
|
197 def get_password(): |
|
198 """Prompt for password with echo off, using Windows getch(). |
|
199 |
|
200 This shouldn't be called directly- use ``ui.getpass()`` instead, which |
|
201 checks if the session is interactive first. |
|
202 """ |
|
203 pw = "" |
|
204 while True: |
|
205 c = msvcrt.getwch() |
|
206 if c == '\r' or c == '\n': |
|
207 break |
|
208 if c == '\003': |
|
209 raise KeyboardInterrupt |
|
210 if c == '\b': |
|
211 pw = pw[:-1] |
|
212 else: |
|
213 pw = pw + c |
|
214 msvcrt.putwch('\r') |
|
215 msvcrt.putwch('\n') |
|
216 return encoding.strtolocal(pw) |
195 |
217 |
196 |
218 |
197 class winstdout(object): |
219 class winstdout(object): |
198 """Some files on Windows misbehave. |
220 """Some files on Windows misbehave. |
199 |
221 |