Issue #16230: Fix a crash in select.select() when one the lists changes size while iterated on.

Patch by Serhiy Storchaka.
This commit is contained in:
Antoine Pitrou 2012-11-01 20:15:23 +01:00
commit 0168d3d9b1
3 changed files with 15 additions and 4 deletions

View file

@ -65,6 +65,16 @@ class SelectTestCase(unittest.TestCase):
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():
support.run_unittest(SelectTestCase)
support.reap_children()