1 | initial version |
The problem is this block in the code for Set
:
try:
X = frozenset(X)
except TypeError:
return Set_object(X)
else:
return Set_object_enumerated(X)
When the entries of X
are not hashable, frozenset(X)
fails, but it still accesses X
. If X
is a generator, you lose the first entry of X
this way. This change in sage.set.set
might fix it:
diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
index 96e3b2ad7a..ff133a315e 100644
--- a/src/sage/sets/set.py
+++ b/src/sage/sets/set.py
@@ -198,11 +198,12 @@ def Set(X=None):
raise TypeError("Element has no defined underlying set")
try:
- X = frozenset(X)
+ Y = list(X)
+ Y = frozenset(Y)
except TypeError:
- return Set_object(X)
+ return Set_object(Y)
else:
- return Set_object_enumerated(X)
+ return Set_object_enumerated(Y)
class Set_base():