Skip to content

Set iteration is broken over sets created with iterators #3933

@sagetrac-anakha

Description

@sagetrac-anakha

This works:

sage: list(Set([1, 2, 3, 4, 5]))
[1, 2, 3, 4, 5]

But this doesn't:

sage: list(Set(iter([1, 2, 3, 4, 5])))
[]

Basically Set makes a Set_object() out of it and Set_object is really not prepared to deal with an iterator. I glanced over the code and did find an obvious solution.

Component: misc

Issue created by migration from https://trac.sagemath.org/ticket/3933

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions