-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
itertools.tee lookahead/peek example doesn't work #126701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note, the bugfix has already been backported to 3.12 and 3.13. It looks like the online docs have publishing ahead of those bug fixes actually being released. That should resolve itself when 3.13.1 comes out. Until then, I'm thinking that it is best to temporarily remove the lookahead example entirely. As you observed, we could incorporate the bug workaround Another workaround that always worked is |
@erlend-aasland I removed the bug label because the bug has already been fixed. The problem here is that the doc example depends on the bug fix but the micro-release hasn't happened yet. So AFAICT this is a doc timing issue only. |
FYI, we normally use the doc and bug labels in combination for incorrect documentation (aka doc bugs). |
Now docs.python.org shows docs for 3.13.1. So, I'm closing this. |
Documentation
In the
tee
documentation a method for makingtee
-iterators peekable is mentioned:Tested on versions 3.13.0, 3.11.10, 3.9.18 (and 2.7.18 for a laugh).
#123884 seems to be the source of the error, and it is indeed working correctly on 3.14@4f3253a0ccf3a512c497f779e4a6db2656c75844. But the documentation for older version should be updated, as following recipes from the official docs that don't work on the version the docs are for makes debugging a nightmare.
The docs might also want to mention a possible workaround in the form of
_, iterator = tee(iterator, 2)
, as only the first copy from tee seems to be afflicted by the bug. At least that is my reading of its description, and it seems to work in a quick test.The text was updated successfully, but these errors were encountered: