Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 30814:b96c57c1f860
ui: check EOF of getpass() response read from command-server channel
readline() returns '' only when EOF is encountered, in which case, Python's
getpass() raises EOFError. We should do the same to abort the session as
"response expected."
This bug was reported to
https://bitbucket.org/tortoisehg/thg/issues/4659/
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 Jan 2017 20:31:35 +0900 |
parents | 16b5df5792a8 |
children | da5fa0f13a41 |
comparison
equal
deleted
inserted
replaced
30813:2cbbd4622ab0 | 30814:b96c57c1f860 |
---|---|
970 try: | 970 try: |
971 self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) | 971 self.write_err(self.label(prompt or _('password: '), 'ui.prompt')) |
972 # disable getpass() only if explicitly specified. it's still valid | 972 # disable getpass() only if explicitly specified. it's still valid |
973 # to interact with tty even if fin is not a tty. | 973 # to interact with tty even if fin is not a tty. |
974 if self.configbool('ui', 'nontty'): | 974 if self.configbool('ui', 'nontty'): |
975 return self.fin.readline().rstrip('\n') | 975 l = self.fin.readline() |
976 if not l: | |
977 raise EOFError | |
978 return l.rstrip('\n') | |
976 else: | 979 else: |
977 return getpass.getpass('') | 980 return getpass.getpass('') |
978 except EOFError: | 981 except EOFError: |
979 raise error.ResponseExpected() | 982 raise error.ResponseExpected() |
980 def status(self, *msg, **opts): | 983 def status(self, *msg, **opts): |