This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients josh.r, rhettinger, serhiy.storchaka
Date 2017-04-18.02:13:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492481613.71.0.884010963186.issue30049@psf.upfronthosting.co.za>
In-reply-to
Content
I'm having a hard time thinking of legitimate cases where replacing __next__ mid-iteration is a thing. Doing so retroactively on the class (so it changes all outstanding iterators, no matter what state they're in) seems dubious at best, and it wouldn't be thread-safe if many different ways if iterators of said type are being used in multiple threads.

Is the dynamic type lookup on every iteration necessary too? Would failing to do so cause crashes if evil iterator reassigns self.__class__ or something?

I feel like if segfaults aren't a possibility (I haven't been able to cause one on Py 3.5 by reassigning the class's __next__ or the instance's __class__), it's not our job to fix intentionally broken code at the expense of all other code. Raymond okayed the previous issue because it was a segfaulting bug, but it seems like this is just a "broken code is broken" bug.
History
Date User Action Args
2017-04-18 02:13:33josh.rsetrecipients: + josh.r, rhettinger, serhiy.storchaka
2017-04-18 02:13:33josh.rsetmessageid: <1492481613.71.0.884010963186.issue30049@psf.upfronthosting.co.za>
2017-04-18 02:13:33josh.rlinkissue30049 messages
2017-04-18 02:13:32josh.rcreate