diff options
Diffstat (limited to 'mercurial/byterange.py')
-rw-r--r-- | mercurial/byterange.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mercurial/byterange.py b/mercurial/byterange.py index f4f5f53..cc8f893 100644 --- a/mercurial/byterange.py +++ b/mercurial/byterange.py @@ -9,8 +9,10 @@ # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, see -# <http://www.gnu.org/licenses/>. +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA # This file is part of urlgrabber, a high-level cross-protocol url-grabber # Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko @@ -101,7 +103,9 @@ class RangeableFileObject(object): """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.""" - return getattr(self.fo, name) + if hasattr(self.fo, name): + return getattr(self.fo, name) + raise AttributeError(name) def tell(self): """Return the position within the range. @@ -166,8 +170,10 @@ class RangeableFileObject(object): offset is relative to the current position (self.realpos). """ assert offset >= 0 - seek = getattr(self.fo, 'seek', self._poor_mans_seek) - seek(self.realpos + offset) + if not hasattr(self.fo, 'seek'): + self._poor_mans_seek(offset) + else: + self.fo.seek(self.realpos + offset) self.realpos += offset def _poor_mans_seek(self, offset): |