Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-01-17 17:47:54


Author: eric_niebler
Date: 2008-01-17 17:47:54 EST (Thu, 17 Jan 2008)
New Revision: 42836
URL: http://svn.boost.org/trac/boost/changeset/42836

Log:
stl_iterator does better error handling
Text files modified:
   trunk/libs/python/src/object/stl_iterator.cpp | 6 ++++++
   trunk/libs/python/test/stl_iterator.py | 10 ++++++++++
   2 files changed, 16 insertions(+), 0 deletions(-)

Modified: trunk/libs/python/src/object/stl_iterator.cpp
==============================================================================
--- trunk/libs/python/src/object/stl_iterator.cpp (original)
+++ trunk/libs/python/src/object/stl_iterator.cpp 2008-01-17 17:47:54 EST (Thu, 17 Jan 2008)
@@ -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 <boost/python/object.hpp>
 #include <boost/python/handle.hpp>
@@ -27,6 +31,8 @@
 {
     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

Modified: trunk/libs/python/test/stl_iterator.py
==============================================================================
--- trunk/libs/python/test/stl_iterator.py (original)
+++ trunk/libs/python/test/stl_iterator.py 2008-01-17 17:47:54 EST (Thu, 17 Jan 2008)
@@ -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


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk