[C++-sig] [patch] Boost.Python STL input iterator does not propagate exceptions

Andreas Klöckner kloeckner at dam.brown.edu
Wed Jan 16 19:35:43 CET 2008


Hi Eric, 

On Donnerstag 03 Januar 2008, you wrote:
> Andreas Klöckner wrote:
> > The attached patch fixes an exception propagation issue in the STL input
> > iterator in Boost.Python. The problem is as follows: PyIter_Next may
> > return 0 for two reasons:
> >
> > - No more iterants left.
> > - An exception was caught.
> >
> > The current implementation interprets the latter as the former. A simple
> > fix (throw error_already_set if appropriate) is attached.
> >
> > I'd appreciate it if you could commit this. If there are any issues,
> > please let me know and I'll do my best to fix them.
>
> Thanks, please provide a test case.

Test case attached, along with original patch. On unpatched code, this gives:

**********************************************************************
File "stl_iterator.py", line 19, in __main__
Failed example:
    try:
      x.assign(iter(generator()))
      print "NOT OK"
    except RuntimeError:
      print "OK"
Expected:
    OK
Got:
    NOT OK
**********************************************************************

or it crashes outright.

Andreas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bpl-stl-iterator-prop-ex-2007-12-20.patch
Type: text/x-diff
Size: 635 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080116/654ae7d0/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stl-iterator-ex-prop-test.diff
Type: text/x-diff
Size: 462 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080116/654ae7d0/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20080116/654ae7d0/attachment.pgp>


More information about the Cplusplus-sig mailing list