From 312da87172b9f1d0215cb040025fcca5357db46b Mon Sep 17 00:00:00 2001 From: inpos Date: Sat, 12 Mar 2016 00:29:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D1=83=D0=B6=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D1=82=D1=80=D0=B0=D1=85?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pyrrent2http/engine.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pyrrent2http/engine.py b/lib/pyrrent2http/engine.py index 62aa4d7..9610959 100644 --- a/lib/pyrrent2http/engine.py +++ b/lib/pyrrent2http/engine.py @@ -309,9 +309,9 @@ class Engine: res = self.list(timeout=timeout) if res: try: - return next((f for f in res if f.index == file_index)) - except StopIteration: - raise Error("Requested file index (%d) is invalid" % file_index, Error.INVALID_FILE_INDEX, + return res[file_index] + except IndexError: + raise Error("Requested file index (%d) is invalid" % (file_index,), Error.INVALID_FILE_INDEX, file_index=file_index) def peers(self, timeout=10):