Activity log for bug #70565

Date Who What changed Old value New value Message
2006-11-06 11:44:02 Nicholas Allen bug added bug
2006-11-06 17:17:12 John A Meinel bzr: status Unconfirmed Confirmed
2006-11-06 17:17:12 John A Meinel bzr: importance Undecided Medium
2006-11-06 17:17:12 John A Meinel bzr: statusexplanation This should be pretty easy to fix. The problem is that on Cygwin sys.stdout doesn't seem to be getting a proper encoding value. We have a function that is supposed to be used for this: osutils.get_terminal_encoding() This patch should fix it: === modified file 'bzrlib/ui/text.py' --- bzrlib/ui/text.py 2006-10-31 01:30:31 +0000 +++ bzrlib/ui/text.py 2006-11-06 17:14:08 +0000 @@ -82,7 +82,10 @@ :return: The password string, return None if the user canceled the request. """ - prompt = (prompt % kwargs).encode(sys.stdout.encoding, 'replace') + # prompt = (prompt % kwargs).encode(sys.stdout.encoding, 'replace') + encoding = osutils.get_terminal_encoding() + prompt = (prompt % kwargs) + prompt = prompt.encode(encoding, 'replace') prompt += ': ' # There's currently no way to say 'i decline to enter a password' # as opposed to 'my password is empty' -- does it matter? Also, it wouldn't be terribly hard to write a test for this. You just override sys.stdout with a StringIO() object, which doesn't have a .encoding attribute. (Use a try/finally to make sure to restore the original sys.stdout). Alternatively, you can use the bzrlib.tests.StringIOWrapper() which adds a .encoding attribute to StringIO, and set it to None. Also, we would need to override getpass.getpass() so that we don't actually try to prompt the user on the terminal. We may want to refactor getpass() so that it is called from a member of TextUIFactory, so we can subclass for testing. Nick: Can you test the patch and see if it works, before we spend too much time writing tests, etc.
2007-05-11 12:33:23 Vincent Ladeuil marked as duplicate 110204