From 7a3dcf3d873c3e31541eeed2f7e85c1c800e390f Mon Sep 17 00:00:00 2001
From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Mon, 28 Jun 2010 10:27:14 +0000
Subject: [PATCH] fix iterator for sequence handle

This bug actually lead to the discovery of an interesting
phenotype of the "for" statement. If a class has the
__getitem__() defined and doesn't have a __iter__(),
Python uses __getitem__() to iterate over the items,
stopping when a IndexError is thrown. Previously we were
throwing a normal RuntimeError which Python didn't recognize
as the end of the list.

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2467 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/seq/base/src/impl/sequence_impl.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/seq/base/src/impl/sequence_impl.cc b/modules/seq/base/src/impl/sequence_impl.cc
index 06edaf5d5..d584c3549 100644
--- a/modules/seq/base/src/impl/sequence_impl.cc
+++ b/modules/seq/base/src/impl/sequence_impl.cc
@@ -108,7 +108,7 @@ void SequenceImpl::ShiftsFromSequence()
 int SequenceImpl::GetResidueIndex(int pos) const
 {
   if (pos<0 || pos>=static_cast<int>(seq_string_.length()))
-    throw Error("Position is not covered in sequence");
+    throw std::out_of_range("Position is not covered in sequence");
   if (seq_string_[pos]=='-')
     throw Error("Requested position contains a gap");
   std::list<Shift>::const_iterator i;
@@ -136,7 +136,7 @@ int SequenceImpl::GetPos(int index) const
   int shifted_index=index-sequence_offset_;
   int pos=this->GetPosNoBounds(shifted_index);
   if (pos<0 || pos>=static_cast<int>(seq_string_.length()))
-    throw Error("number not covered in sequence");
+    throw std::out_of_range("number not covered in sequence");
   return pos;
 }
 
@@ -171,7 +171,7 @@ int SequenceImpl::GetLength() const {
 char SequenceImpl::GetOneLetterCode(int position) const
 {
   if (position<0 || position>=static_cast<int>(seq_string_.length()))
-    throw Error("Position is not covered in sequence");
+    throw std::out_of_range("Position is not covered in sequence");
   return seq_string_[position];
 }
 
-- 
GitLab