Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 19085:be207d9b7e4b stable
i18n: show the non-ASCII password prompt text correctly
Before this patch, the prompt text for asking password is directly
passed to "getpass.getpass()" of Python standard library.
In "getpass.getpass()" implementation on Windows environment, the
prompt text is split into byte sequence and "msvcrt.putch()" is
applied on each bytes in it. This splitting causes non-ASCII prompt
text to be broken.
This patch shows the prompt text for asking password on "ui.getpass()"
side, and invokes "getpass.getpass()" with empty prompt text. This
prevents non-ASCII prompt text from being broken in
"getpass.getpass()" implementation.
This patch also sets "ui.prompt" label to prompt text to follow
"ui.prompt()" style.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 25 Apr 2013 20:48:49 +0900 |
parents | 2c4cd1c42365 |
children | 9311cd5c09ed |
comparison
equal
deleted
inserted
replaced
19084:70675d77fd4a | 19085:be207d9b7e4b |
---|---|
661 | 661 |
662 def getpass(self, prompt=None, default=None): | 662 def getpass(self, prompt=None, default=None): |
663 if not self.interactive(): | 663 if not self.interactive(): |
664 return default | 664 return default |
665 try: | 665 try: |
666 return getpass.getpass(prompt or _('password: ')) | 666 self.write(self.label(prompt or _('password: '), 'ui.prompt')) |
667 return getpass.getpass('') | |
667 except EOFError: | 668 except EOFError: |
668 raise util.Abort(_('response expected')) | 669 raise util.Abort(_('response expected')) |
669 def status(self, *msg, **opts): | 670 def status(self, *msg, **opts): |
670 '''write status message to output (if ui.quiet is False) | 671 '''write status message to output (if ui.quiet is False) |
671 | 672 |