del not working for (exhausted) dict iterable value (Python 3.3)

Nick Mellor thebalancepro at
Tue Mar 12 06:35:43 CET 2013

Hi all,

event['Items'] is an exhausted (all used up) iterable.

Now I do the following (lines 142-4):

            event.update({'Attributes': filtered_attributes})
            del event['Items']
            yield event

and get a KeyError on the del statement. 'Items' is a key in the event dictionary at this point.

The full file is here:

I can get round it by copying all but the 'Items' member to a new dictionary, but obviously I don't want to.

Is there some deep design in Python here, that it won't delete a dict value that's an (exhausted) iterator, or have I found a bug?

Thanks for any help,


More information about the Python-list mailing list