bpo-29942: Fix the use of recursion in itertools.chain.from_iterable.#889
bpo-29942: Fix the use of recursion in itertools.chain.from_iterable.#889Yhg1s merged 5 commits intopython:masterfrom
Conversation
…rsion is unnecessary, and can easily cause stack overflows, especially when building in low optimization modes or with Py_DEBUG enabled.
|
@Yhg1s, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rhettinger, @kristjanvalur and @serhiy-storchaka to be potential reviewers. |
|
Please open an issue on the bug tracker, add an entry in |
|
The patch itself LGTM. |
|
bugs.python.org issue is http://bugs.python.org/issue29942. Misc/NEWS entry added. I'm already in Misc/ACKS, and considering I've been a core dev for many years I don't think I need separate credits for the patch. |
|
Oh, sorry. Your GitHab name was not known to me. |
Lib/test/test_itertools.py
Outdated
| # number this would probably only fail in Py_DEBUG mode. | ||
| it = chain.from_iterable(() for unused in range(10000000)) | ||
| with self.assertRaises(StopIteration): | ||
| next(it) |
There was a problem hiding this comment.
Two-space indentation?
Lib/test/test_itertools.py
Outdated
| self.assertRaises(AssertionError, list, cycle(gen1())) | ||
| self.assertEqual(hist, [0,1]) | ||
|
|
||
| def test_deep_recursion(self): |
There was a problem hiding this comment.
Now this is not a recursion. The recursion from user side is chain.from_iterable(chain.from_iterable(...)). Maybe use other name for the test?
…python#889) Fix the use of recursion in itertools.chain.from_iterable. Using recursion is unnecessary, and can easily cause stack overflows, especially when building in low optimization modes or with Py_DEBUG enabled. (cherry picked from commit 5466d4a)
…python#889) Fix the use of recursion in itertools.chain.from_iterable. Using recursion is unnecessary, and can easily cause stack overflows, especially when building in low optimization modes or with Py_DEBUG enabled. (cherry picked from commit 5466d4a)
…python#889) Fix the use of recursion in itertools.chain.from_iterable. Using recursion is unnecessary, and can easily cause stack overflows, especially when building in low optimization modes or with Py_DEBUG enabled. (cherry picked from commit 5466d4a)
Fix the use of recursion in
itertools.chain.from_iterable. Using recursion is unnecessary, and can easily cause stack overflows, especially when building in low optimization modes or withPy_DEBUGenabled.