Sitelet https://github.com/python/cpython/issues/93814
Skip to content

test_itertools.py does not test infinite iterable for itertools.chain.from_iterable #93814

Description

@youknowone

Bug report

itertools.chain.from_iterable is safe to use with infinite iterable, but no test exists.

example:

chain.from_iterable(repeat(range(5)))

Your environment

  • CPython versions tested on:
    3.10.4 and current main branch

  • Operating system and architecture:
    N/A

Activity

  1. rhettinger commented on Jun 14, 2022

    @rhettinger
    Contributor

    ISTM there is no point in adding another test for this. Infinite iterators a just a special case of "bigger than you can reasonably consume".

    From a consumers point of view, there is no way to differentiate an infinite iterator from a huge iterator (c.f. the halting problem).

  2. youknowone commented on Jun 14, 2022

    @youknowone
    ContributorAuthor

    The test will prevent a potential regression to evaluate given iterable before consuming.

    Please let me know if there is a test already covers a huge iterator.
    I found test_long_chain_of_empty_iterables is a similar one, but it doesn't fully prevent it.

    ref: RustPython/RustPython#3787

  3. added a commit that references this issue on Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions