Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment: I was about to say "yes, listiter.__next__ is atomic" (it should, really), but that's not true (Hint: there is a Py_DECREF in the code...).
The script below crashes with: Fatal Python error: Objects/listobject.c:2774 object at 0x7f66b7a6c600 has negative ref count -1 Attached patch fixes it. import threading class C: def __del__(self): print("DEL") ITER = iter([C() for x in range(100)]) def f(): for obj in ITER: pass for x in range(10): t = threading.Thread(target=f) t.start() ---------- keywords: +patch Added file: http://bugs.python.org/file26358/listiter_next_atomic.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15320> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com