Using SFTP pull on Win32
Alexey Shamrin
shamrin at gmail.com
Tue Nov 15 11:25:28 GMT 2005
On 11/11/05, John A Meinel <john at arbash-meinel.com> wrote:
> Alexey Shamrin wrote:
> > I think the better way to fix the bug is to encode the arguments using
> > sys.stdout.encoding, because getpass always write to stoud. Here is
> > the patch:
> I agree that this is the way to fix the problem. With one minor fix. I
> would use "self._username.encode(enc, errors='replace')".
> Because this is just displaying the username, and it is possible that
> those characters are illegal in the current encoding.
> Otherwise you get a UnicodeEncodeError if there is an illegal character.
I agree, but:
>>> u'test'.encode('cp866',errors='replace')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: encode() takes no keyword arguments
Here is the modified diff:
=== modified file 'bzrlib\\transport\\sftp.py'
--- bzrlib\transport\sftp.py
+++ bzrlib\transport\sftp.py
@@ -446,7 +446,8 @@
pass
# give up and ask for a password
- password = getpass.getpass('SSH %s@%s password: ' % (self._username, se
lf._host))
+ enc = sys.stdout.encoding
+ password = getpass.getpass('SSH %s@%s password: ' % (self._username.enc
ode(enc,'replace'), self._host.encode(enc)))
try:
transport.auth_password(self._username, password)
except paramiko.SSHException:
--
Alexey
More information about the bazaar
mailing list