# HG changeset patch # User Paul Boddie # Date 1560009332 -7200 # Node ID 018b653418f2435efb75fca2b284e079723fd881 # Parent 97fb61c1a87145b30edcee471b3037bca13afd76 Added an optional iterator attribute to StopIteration. diff -r 97fb61c1a871 -r 018b653418f2 lib/__builtins__/exception/base.py --- a/lib/__builtins__/exception/base.py Sat Jun 08 17:54:53 2019 +0200 +++ b/lib/__builtins__/exception/base.py Sat Jun 08 17:55:32 2019 +0200 @@ -71,7 +71,11 @@ "An exception signalling the end of iteration." - pass + def __init__(self, .iterator=None): + + "Initialise the exception with the given 'iterator'." + + pass class ValueError(Exception): diff -r 97fb61c1a871 -r 018b653418f2 lib/__builtins__/iteration/iterator.py --- a/lib/__builtins__/iteration/iterator.py Sat Jun 08 17:54:53 2019 +0200 +++ b/lib/__builtins__/iteration/iterator.py Sat Jun 08 17:55:32 2019 +0200 @@ -3,7 +3,7 @@ """ Iterator objects. -Copyright (C) 2015, 2016 Paul Boddie +Copyright (C) 2015, 2016, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -39,6 +39,6 @@ self.i += 1 return value except IndexError: - raise StopIteration() + raise StopIteration, self # vim: tabstop=4 expandtab shiftwidth=4 diff -r 97fb61c1a871 -r 018b653418f2 lib/__builtins__/set.py --- a/lib/__builtins__/set.py Sat Jun 08 17:54:53 2019 +0200 +++ b/lib/__builtins__/set.py Sat Jun 08 17:55:32 2019 +0200 @@ -3,7 +3,7 @@ """ Set objects. -Copyright (C) 2015, 2016, 2017 Paul Boddie +Copyright (C) 2015, 2016, 2017, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -323,7 +323,7 @@ try: bucket = self.mapping.buckets[self.index] except IndexError: - raise StopIteration + raise StopIteration, self # Access the current item. If no such item exists, get another # bucket. diff -r 97fb61c1a871 -r 018b653418f2 lib/__builtins__/span.py --- a/lib/__builtins__/span.py Sat Jun 08 17:54:53 2019 +0200 +++ b/lib/__builtins__/span.py Sat Jun 08 17:55:32 2019 +0200 @@ -3,7 +3,7 @@ """ Span-related objects. -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie +Copyright (C) 2015, 2016, 2017, 2018, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -101,7 +101,7 @@ "Return the next item or raise a StopIteration exception." if not self.count: - raise StopIteration + raise StopIteration, self current = self.current self.current = self.current.__add__(self.step)