Rev 5085: (spiv) Fix AttributeError in _close_ssh_proc. (Andrew Bennetts) in file:///home/pqm/archives/thelove/bzr/2.2/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Sep 10 04:42:18 BST 2010
At file:///home/pqm/archives/thelove/bzr/2.2/
------------------------------------------------------------
revno: 5085 [merge]
revision-id: pqm at pqm.ubuntu.com-20100910034216-7lal88p15ejfe26b
parent: pqm at pqm.ubuntu.com-20100909012913-ll8vz460ylcbdj2m
parent: andrew.bennetts at canonical.com-20100909073102-1cvb4kdcfi4h739w
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Fri 2010-09-10 04:42:16 +0100
message:
(spiv) Fix AttributeError in _close_ssh_proc. (Andrew Bennetts)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/transport/ssh.py ssh.py-20060824042150-0s9787kng6zv1nwq-1
=== modified file 'NEWS'
--- a/NEWS 2010-09-08 13:25:16 +0000
+++ b/NEWS 2010-09-09 07:31:02 +0000
@@ -19,7 +19,7 @@
* ``bzr add SYMLINK/FILE`` now works properly when the symlink points to a
previously-unversioned directory within the tree: the directory is
- marked versioned too.
+ marked versioned too.
(Martin Pool, #192859)
* CommitBuilder now uses the committer instead of _config.username to generate
@@ -28,10 +28,15 @@
* Cope with Microsoft FTP server that returns reply '250 Directory
created' when mkdir succeeds. (Martin Pool, #224373)
-* Fix ``AttributeError on parent.children`` when adding a file under a
+* Fix ``AttributeError on parent.children`` when adding a file under a
directory that was a symlink in the previous commit.
(Martin Pool, #192859)
+* Fix ``AttributeError: 'NoneType' object has no attribute 'close'`` in
+ ``_close_ssh_proc`` when using ``bzr+ssh://``. This was causing
+ connections to pre-1.6 bzr+ssh servers to fail, and causing warnings on
+ stderr in some other circumstances. (Andrew Bennetts, #633745)
+
* Only call ``setlocale`` in the bzr startup script on posix systems. This
avoids an issue with the newer windows C runtimes used by Python 2.6 and
later which can mangle bytestrings printed to the console.
=== modified file 'bzrlib/transport/ssh.py'
--- a/bzrlib/transport/ssh.py 2010-06-17 13:16:51 +0000
+++ b/bzrlib/transport/ssh.py 2010-09-09 07:31:02 +0000
@@ -645,11 +645,28 @@
_subproc_weakrefs = set()
def _close_ssh_proc(proc):
- for func in [proc.stdin.close, proc.stdout.close, proc.wait]:
- try:
- func()
+ """Carefully close stdin/stdout and reap the SSH process.
+
+ If the pipes are already closed and/or the process has already been
+ wait()ed on, that's ok, and no error is raised. The goal is to do our best
+ to clean up (whether or not a clean up was already tried).
+ """
+ dotted_names = ['stdin.close', 'stdout.close', 'wait']
+ for dotted_name in dotted_names:
+ attrs = dotted_name.split('.')
+ try:
+ obj = proc
+ for attr in attrs:
+ obj = getattr(obj, attr)
+ except AttributeError:
+ # It's ok for proc.stdin or proc.stdout to be None.
+ continue
+ try:
+ obj()
except OSError:
- pass
+ # It's ok for the pipe to already be closed, or the process to
+ # already be finished.
+ continue
class SSHConnection(object):
More information about the bazaar-commits
mailing list