summaryrefslogtreecommitdiff
path: root/Lib/python/pycontainer.swg
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/python/pycontainer.swg')
-rw-r--r--Lib/python/pycontainer.swg12
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index 81909ae02..d4386622e 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -339,7 +339,7 @@ namespace swig {
std::advance(it,ii);
for (size_t rc=0; rc<replacecount; ++rc) {
*it++ = *isit++;
- for (Py_ssize_t c=0; c<(step-1); ++c)
+ for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
}
}
@@ -357,7 +357,7 @@ namespace swig {
std::advance(it,size-ii-1);
for (size_t rc=0; rc<replacecount; ++rc) {
*it++ = *isit++;
- for (Py_ssize_t c=0; c<(-step-1); ++c)
+ for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
it++;
}
}
@@ -383,9 +383,7 @@ namespace swig {
size_t delcount = (jj - ii + step - 1) / step;
while (delcount) {
it = self->erase(it);
- if (it==self->end())
- break;
- for (Py_ssize_t c=0; c<(step-1); ++c)
+ for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
delcount--;
}
@@ -399,9 +397,7 @@ namespace swig {
size_t delcount = (ii - jj - step - 1) / -step;
while (delcount) {
it = typename Sequence::reverse_iterator(self->erase((++it).base()));
- if (it==self->rend())
- break;
- for (Py_ssize_t c=0; c<(-step-1); ++c)
+ for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
it++;
delcount--;
}