From 6449c56efefc9a5d35fffa1d406b642379c4e8cb Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 21 Jan 2008 20:15:02 +0000 Subject: [PATCH] Merge. [SVN r42905] --- src/object/stl_iterator.cpp | 6 ++++++ test/stl_iterator.py | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/object/stl_iterator.cpp b/src/object/stl_iterator.cpp index e2b66cea..e32d3214 100755 --- a/src/object/stl_iterator.cpp +++ b/src/object/stl_iterator.cpp @@ -2,6 +2,10 @@ // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// +// Credits: +// Andreas Kl\:ockner for fixing increment() to handle +// error conditions. #include #include @@ -27,6 +31,8 @@ void stl_input_iterator_impl::increment() { this->ob_ = boost::python::handle<>( boost::python::allow_null(PyIter_Next(this->it_.ptr()))); + if (PyErr_Occurred()) + throw boost::python::error_already_set(); } bool stl_input_iterator_impl::equal(stl_input_iterator_impl const &that) const diff --git a/test/stl_iterator.py b/test/stl_iterator.py index c044e85a..2c324c0a 100644 --- a/test/stl_iterator.py +++ b/test/stl_iterator.py @@ -12,6 +12,16 @@ 3 4 5 +>>> def generator(): +... yield 1 +... yield 2 +... raise RuntimeError, "oops" +>>> try: +... x.assign(iter(generator())) +... print "NOT OK" +... except RuntimeError: +... print "OK" +OK ''' def run(args = None): import sys