Ask Your Question

Revision history [back]

The problem is this block in the code for Set:

    X = frozenset(X)
except TypeError:
    return Set_object(X)
    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/ b/src/sage/sets/
index 96e3b2ad7a..ff133a315e 100644
--- a/src/sage/sets/
+++ b/src/sage/sets/
@@ -198,11 +198,12 @@ def Set(X=None):
         raise TypeError("Element has no defined underlying set")

-        X = frozenset(X)
+        Y = list(X)
+        Y = frozenset(Y)
     except TypeError:
-        return Set_object(X)
+        return Set_object(Y)
-        return Set_object_enumerated(X)
+        return Set_object_enumerated(Y)

 class Set_base():