# HG changeset patch # User Augie Fackler # Date 1311624557 18000 # Node ID 3aa34005a73df5d46cd81835b7faa2ed7591c1af # Parent 28762bf809d8602d4ac7babd35d9443e7b64b515 byterange: replace uses of hasattr with getattr diff -r 28762bf809d8 -r 3aa34005a73d mercurial/byterange.py --- a/mercurial/byterange.py Mon Jul 25 15:07:09 2011 -0500 +++ b/mercurial/byterange.py Mon Jul 25 15:09:17 2011 -0500 @@ -103,9 +103,7 @@ """This effectively allows us to wrap at the instance level. Any attribute not found in _this_ object will be searched for in self.fo. This includes methods.""" - if hasattr(self.fo, name): - return getattr(self.fo, name) - raise AttributeError(name) + return getattr(self.fo, name) def tell(self): """Return the position within the range. @@ -170,10 +168,8 @@ offset is relative to the current position (self.realpos). """ assert offset >= 0 - if not hasattr(self.fo, 'seek'): - self._poor_mans_seek(offset) - else: - self.fo.seek(self.realpos + offset) + seek = getattr(self.fo, 'seek', self._poor_mans_seek) + seek(self.realpos + offset) self.realpos += offset def _poor_mans_seek(self, offset):