Commit 5753e6b9 authored by Evan Simpson's avatar Evan Simpson

Only catch IndexError when testing sequence bounds.

parent 279488f1
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
__doc__='''Batch class, for iterating over a sequence in batches __doc__='''Batch class, for iterating over a sequence in batches
$Id: Batch.py,v 1.4 2001/10/02 20:54:49 evan Exp $''' $Id: Batch.py,v 1.5 2001/11/13 19:23:55 evan Exp $'''
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from ExtensionClass import Base from ExtensionClass import Base
...@@ -150,22 +150,22 @@ def opt(start,end,size,orphan,sequence): ...@@ -150,22 +150,22 @@ def opt(start,end,size,orphan,sequence):
if start > 0: if start > 0:
try: sequence[start-1] try: sequence[start-1]
except: start=len(sequence) except IndexError: start=len(sequence)
if end > 0: if end > 0:
if end < start: end=start if end < start: end=start
else: else:
end=start+size-1 end=start+size-1
try: sequence[end+orphan-1] try: sequence[end+orphan-1]
except: end=len(sequence) except IndexError: end=len(sequence)
elif end > 0: elif end > 0:
try: sequence[end-1] try: sequence[end-1]
except: end=len(sequence) except IndexError: end=len(sequence)
start=end+1-size start=end+1-size
if start - 1 < orphan: start=1 if start - 1 < orphan: start=1
else: else:
start=1 start=1
end=start+size-1 end=start+size-1
try: sequence[end+orphan-1] try: sequence[end+orphan-1]
except: end=len(sequence) except IndexError: end=len(sequence)
return start,end,size return start,end,size
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment