Issue #16230: Fix a crash in select.select() when one the lists changes size while iterated on.
Patch by Serhiy Storchaka.
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 79b249b..175bbda 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -49,6 +49,15 @@
self.fail('Unexpected return values from select():', rfd, wfd, xfd)
p.close()
+ # Issue 16230: Crash on select resized list
+ def test_select_mutated(self):
+ a = []
+ class F:
+ def fileno(self):
+ del a[-1]
+ return sys.__stdout__.fileno()
+ a[:] = [F()] * 10
+ self.assertEqual(select.select([], a, []), ([], a[:5], []))
def test_main():
test_support.run_unittest(SelectTestCase)