Author rhettinger
Recipients gvanrossum, lukasz.langa, martin.panter, pitrou, rhettinger, scoder, vstinner, yselivanov
Date 2015-04-21.02:21:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429582917.72.0.169396481175.issue24018@psf.upfronthosting.co.za>
In-reply-to
Content
For the other ABCs, if you define the required abstract methods, you get working versions of all the mixin methods.

In the case of the Generator ABC, throw() and close() are useless empty stub methods.  In the other ABCs, we leave optional methods out entirely.  A user should expect that if isinstance(g, Generator) is true that all of the ABC methods will work.

Also, the return StopIteration in throw() doesn't seem correct.  Shouldn't it raise the exception that was thrown?

    >>> def f():
            yield x

            
    >>> g = f()
    >>> g.throw(KeyError)

    Traceback (most recent call last):
      File "<pyshell#11>", line 1, in <module>
        g.throw(KeyError)
      File "<pyshell#9>", line 1, in f
        def f():
    KeyError

Ideally, there should be a practical example of where this ABC would be useful with anything other than a real generator.
History
Date User Action Args
2015-04-21 02:21:57rhettingersetrecipients: + rhettinger, gvanrossum, pitrou, scoder, vstinner, lukasz.langa, martin.panter, yselivanov
2015-04-21 02:21:57rhettingersetmessageid: <1429582917.72.0.169396481175.issue24018@psf.upfronthosting.co.za>
2015-04-21 02:21:57rhettingerlinkissue24018 messages
2015-04-21 02:21:56rhettingercreate