Is StopIteration a singleton?

Terry Reedy tjreedy at udel.edu
Fri Nov 21 05:54:52 CET 2014


On 11/20/2014 11:23 PM, Chris Angelico wrote:
> On Fri, Nov 21, 2014 at 2:40 PM, Terry Reedy <tjreedy at udel.edu> 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.

Sorry I was unclear.  I meant ditto ValueError for all other classes.


-- 
Terry Jan Reedy




More information about the Python-list mailing list