Is StopIteration a singleton?

Chris Angelico rosuav at
Fri Nov 21 05:23:46 CET 2014

On Fri, Nov 21, 2014 at 2:40 PM, Terry Reedy <tjreedy at> wrote:
> On 11/20/2014 12:09 AM, Steven D'Aprano wrote:
>> No idea. But you can marshal StopIteration itself, but not StopIteration
>> instances:
>> py> marshal.dumps(StopIteration)
>> 'S'
>> py> marshal.dumps(StopIteration())
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> ValueError: unmarshallable object
> Ditto for other exception classes I tried.

I can't marshal any other exception instances, but I also can't
marshal any other exception classes. StopIteration is special-cased,
and I have no idea why.


More information about the Python-list mailing list