Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

This is different case than mutating a dict while iterate it. In this case the 
failure is caused by GC, and it is always hard to handle such issues. In case 
of a dict you can just copy it before iterating. But what to do with 
RuntimeError from slicing a list if copying a list is vulnerable to the same 
issue?

The example of yet one solution you can see in dict_keys() in dictobject.c. I 
always wondered why this code is needed.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31165>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to