Lichen

Changeset

907:018b653418f2
2019-06-08 Paul Boddie raw files shortlog changelog graph Added an optional iterator attribute to StopIteration.
lib/__builtins__/exception/base.py (file) lib/__builtins__/iteration/iterator.py (file) lib/__builtins__/set.py (file) lib/__builtins__/span.py (file)
     1.1 --- a/lib/__builtins__/exception/base.py	Sat Jun 08 17:54:53 2019 +0200
     1.2 +++ b/lib/__builtins__/exception/base.py	Sat Jun 08 17:55:32 2019 +0200
     1.3 @@ -71,7 +71,11 @@
     1.4  
     1.5      "An exception signalling the end of iteration."
     1.6  
     1.7 -    pass
     1.8 +    def __init__(self, .iterator=None):
     1.9 +
    1.10 +        "Initialise the exception with the given 'iterator'."
    1.11 +
    1.12 +        pass
    1.13  
    1.14  class ValueError(Exception):
    1.15  
     2.1 --- a/lib/__builtins__/iteration/iterator.py	Sat Jun 08 17:54:53 2019 +0200
     2.2 +++ b/lib/__builtins__/iteration/iterator.py	Sat Jun 08 17:55:32 2019 +0200
     2.3 @@ -3,7 +3,7 @@
     2.4  """
     2.5  Iterator objects.
     2.6  
     2.7 -Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
     2.8 +Copyright (C) 2015, 2016, 2019 Paul Boddie <paul@boddie.org.uk>
     2.9  
    2.10  This program is free software; you can redistribute it and/or modify it under
    2.11  the terms of the GNU General Public License as published by the Free Software
    2.12 @@ -39,6 +39,6 @@
    2.13              self.i += 1
    2.14              return value
    2.15          except IndexError:
    2.16 -            raise StopIteration()
    2.17 +            raise StopIteration, self
    2.18  
    2.19  # vim: tabstop=4 expandtab shiftwidth=4
     3.1 --- a/lib/__builtins__/set.py	Sat Jun 08 17:54:53 2019 +0200
     3.2 +++ b/lib/__builtins__/set.py	Sat Jun 08 17:55:32 2019 +0200
     3.3 @@ -3,7 +3,7 @@
     3.4  """
     3.5  Set objects.
     3.6  
     3.7 -Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
     3.8 +Copyright (C) 2015, 2016, 2017, 2019 Paul Boddie <paul@boddie.org.uk>
     3.9  
    3.10  This program is free software; you can redistribute it and/or modify it under
    3.11  the terms of the GNU General Public License as published by the Free Software
    3.12 @@ -323,7 +323,7 @@
    3.13              try:
    3.14                  bucket = self.mapping.buckets[self.index]
    3.15              except IndexError:
    3.16 -                raise StopIteration
    3.17 +                raise StopIteration, self
    3.18  
    3.19              # Access the current item. If no such item exists, get another
    3.20              # bucket.
     4.1 --- a/lib/__builtins__/span.py	Sat Jun 08 17:54:53 2019 +0200
     4.2 +++ b/lib/__builtins__/span.py	Sat Jun 08 17:55:32 2019 +0200
     4.3 @@ -3,7 +3,7 @@
     4.4  """
     4.5  Span-related objects.
     4.6  
     4.7 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
     4.8 +Copyright (C) 2015, 2016, 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
     4.9  
    4.10  This program is free software; you can redistribute it and/or modify it under
    4.11  the terms of the GNU General Public License as published by the Free Software
    4.12 @@ -101,7 +101,7 @@
    4.13          "Return the next item or raise a StopIteration exception."
    4.14  
    4.15          if not self.count:
    4.16 -            raise StopIteration
    4.17 +            raise StopIteration, self
    4.18  
    4.19          current = self.current
    4.20          self.current = self.current.__add__(self.step)