##// END OF EJS Templates
windows: avoid a bytes vs unicode crash reading passwords on py2...
Matt Harbison -
r48593:064cd182 stable
parent child Browse files
Show More
@@ -200,20 +200,20 b' def get_password():'
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):
General Comments 0
You need to be logged in to leave comments. Login now