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