[issue13003] Bug in equivalent code for itertools.izip_longest

New submission from Eli Bendersky <eliben@gmail.com>: Regarding the sample code in: http://docs.python.org/library/itertools#itertools.izip_longest If an IndexError is raised inside an iterator in the "equivalent" code from the docs, the generator stops and the error is swallowed. If an IndexError is raised inside an iterator in the "izip_longest_next" code in CPython's "Modules/itertoolsmodule.c", the generator stops and the error propagates. --- Reported by Adam Forsyth on the docs mailing list. More details in this SO discussion: http://stackoverflow.com/questions/7392902/izip-longest-in-itertools-how-doe... ---------- assignee: docs@python components: Documentation messages: 144228 nosy: docs@python, eli.bendersky priority: normal severity: normal status: open title: Bug in equivalent code for itertools.izip_longest versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13003> _______________________________________

Georg Brandl <georg@python.org> added the comment: I had forwarded this to Raymond, and he replied: The itertools module code is correct. The "equivalent" is only approximately correct I don't consider it to be a bug -- it is an implementation detail in an illustration. ---------- nosy: +georg.brandl resolution: -> wont fix status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13003> _______________________________________

Eli Bendersky <eliben@gmail.com> added the comment: What about at least documenting it? Since a real user ran into this and reported it as a problem, I think it would make sense to make the discrepancy explicit. Alternatively a generalized note can be added to the documentation of itertools stating that the "equivalent" code samples are only approximate and differ in small details from the real implementations. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13003> _______________________________________

Georg Brandl <georg@python.org> added the comment: Well, this is for Raymond to decide. ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13003> _______________________________________

Adam Forsyth <agforsyth@gmail.com> added the comment: This is marked as "wont fix" but has been fixed, the resolution should be changed. ---------- nosy: +agforsyth _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13003> _______________________________________

Eli Bendersky <eliben@gmail.com> added the comment: Yep, it appears that Raymond has fixed this in changeset b0065b9087ef ---------- resolution: wont fix -> fixed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue13003> _______________________________________
participants (3)
-
Adam Forsyth
-
Eli Bendersky
-
Georg Brandl