##// 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 200 This shouldn't be called directly- use ``ui.getpass()`` instead, which
201 201 checks if the session is interactive first.
202 202 """
203 pw = ""
203 pw = u""
204 204 while True:
205 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 207 break
208 if c == '\003':
208 if c == u'\003':
209 209 raise KeyboardInterrupt
210 if c == '\b':
210 if c == u'\b':
211 211 pw = pw[:-1]
212 212 else:
213 213 pw = pw + c
214 msvcrt.putwch('\r') # pytype: disable=module-attr
215 msvcrt.putwch('\n') # pytype: disable=module-attr
216 return encoding.strtolocal(pw)
214 msvcrt.putwch(u'\r') # pytype: disable=module-attr
215 msvcrt.putwch(u'\n') # pytype: disable=module-attr
216 return encoding.unitolocal(pw)
217 217
218 218
219 219 class winstdout(object):
General Comments 0
You need to be logged in to leave comments. Login now