# HG changeset patch # User Augie Fackler # Date 2011-07-26 01:36:59 # Node ID fd246aefedd33e4dd7203ebde87a3703fb007c9f # Parent 16e5271b216fa1414f86ca7dad6ed92634d38f38 keepalive: use safehasattr instead of hasattr diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py --- a/mercurial/keepalive.py +++ b/mercurial/keepalive.py @@ -547,13 +547,14 @@ def safesend(self, str): print "send:", repr(str) try: blocksize = 8192 - if hasattr(str,'read') : + read = getattr(str, 'read', None) + if read is not None: if self.debuglevel > 0: print "sendIng a read()able" - data = str.read(blocksize) + data = read(blocksize) while data: self.sock.sendall(data) - data = str.read(blocksize) + data = read(blocksize) else: self.sock.sendall(str) except socket.error, v: