Rev 2462: Fix 110204 by letting TestUIFactory encode password prompt. in file:///v/home/vila/src/bugs/110204/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Apr 26 09:16:31 BST 2007
At file:///v/home/vila/src/bugs/110204/
------------------------------------------------------------
revno: 2462
revision-id: v.ladeuil+lp at free.fr-20070426081629-g0rsiqfszpxz2tto
parent: pqm at pqm.ubuntu.com-20070426070825-6xw10b1el98su02i
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 110204
timestamp: Thu 2007-04-26 10:16:29 +0200
message:
Fix 110204 by letting TestUIFactory encode password prompt.
* bzrlib/ui/__init__.py:
(CLIUIFactory.get_non_echoed_password): Encode prompt with
sys.stdout.
(CLIUIFactory.get_password): Delegate prompt encoding to
get_non_echoed_password.
* bzrlib/tests/__init__.py:
(TestUIFactory.get_non_echoed_password): Encode prompt with
self.stdout.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2007-04-26 07:08:25 +0000
+++ b/NEWS 2007-04-26 08:16:29 +0000
@@ -219,6 +219,9 @@
* Handle moving a directory when children have been added, removed,
and renamed. (John Arbash Meinel, #105479)
+ * Let TestUIFactoy encode the password prompt with its own stdout.
+ (Vincent Ladeuil, #110204)
+
TESTING:
* Added ``bzrlib.strace.strace`` which will strace a single callable and
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2007-04-25 06:50:22 +0000
+++ b/bzrlib/tests/__init__.py 2007-04-26 08:16:29 +0000
@@ -721,7 +721,7 @@
def get_non_echoed_password(self, prompt):
"""Get password from stdin without trying to handle the echo mode"""
if prompt:
- self.stdout.write(prompt)
+ self.stdout.write(prompt.encode(self.stdout.encoding, 'replace'))
password = self.stdin.readline()
if not password:
raise EOFError
=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py 2007-03-23 01:41:37 +0000
+++ b/bzrlib/ui/__init__.py 2007-04-26 08:16:29 +0000
@@ -111,7 +111,7 @@
current_format_name,
basedir)
-
+
class CLIUIFactory(UIFactory):
"""Common behaviour for command line UI factories."""
@@ -131,7 +131,7 @@
return False
def get_non_echoed_password(self, prompt):
- return getpass.getpass(prompt)
+ return getpass.getpass(prompt.encode(sys.stdout.encoding, 'replace'))
def get_password(self, prompt='', **kwargs):
"""Prompt the user for a password.
@@ -144,7 +144,7 @@
canceled the request.
"""
prompt += ': '
- prompt = (prompt % kwargs).encode(sys.stdout.encoding, 'replace')
+ prompt = (prompt % kwargs)
# There's currently no way to say 'i decline to enter a password'
# as opposed to 'my password is empty' -- does it matter?
return self.get_non_echoed_password(prompt)
More information about the bazaar-commits
mailing list