Mercurial > hg-stable
changeset 14947:3aa34005a73d
byterange: replace uses of hasattr with getattr
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 15:09:17 -0500 |
parents | 28762bf809d8 |
children | 32302480b402 |
files | mercurial/byterange.py |
diffstat | 1 files changed, 3 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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):