Opened 9 years ago
Closed 9 years ago
#14486 closed defect (fixed)
0 == Set([0]) raises error
Reported by: | vbraun | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-5.10 |
Component: | misc | Keywords: | |
Cc: | ncohen, was, nthiery | Merged in: | sage-5.10.beta1 |
Authors: | Volker Braun | Reviewers: | Nathann Cohen |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
See https://groups.google.com/d/msg/sage-devel/2y1knINMAy0/rev2RbskKgwJ
sage: 0 == Set([1]) ... AttributeError: 'Set_object_enumerated_with_category' object has no attribute '_richcmp_'
Apply :
Attachments (3)
Change History (13)
comment:1 Changed 9 years ago by
- Cc was nthiery added
- Status changed from new to needs_review
Changed 9 years ago by
comment:2 Changed 9 years ago by
Forgot to also check for Python ints, should work now.
comment:3 Changed 9 years ago by
Oh, I see... Well, unless you see a more generic way to avoid the problem, could you also add floats to the list ?
sage: Set(float(0)) Set of elements of 0.0 sage: list(Set(float(0))) ... AttributeError: 'float' object has no attribute '__iter__'
I don't see anything else that we should avoid, but one never knows... ^{};
Oh !
sage: Set(True) ... ValueError: underlying object cannot be an integer
What about doing it on a "whitelist" base ? Something like "if is an iterable we accept to build a Set from it", and otherwise we refuse ?
Looks lke it is what frozenset
does
sage: frozenset(1) ... TypeError: 'sage.rings.integer.Integer' object is not iterable
I'm sorry for only coming with problems and not solutions ^^;
Nathann
comment:4 Changed 9 years ago by
Those are all problems with the Set
factory function and not with the Set_object.__init__
constructor. Feel free to open a separate ticket for them.
comment:5 Changed 9 years ago by
Provided that I would spend the lifetime necessary to fix all broken doctests, what would be your idea of such a patch ?
Nathann
Changed 9 years ago by
comment:6 Changed 9 years ago by
The Set function should check that its argument is iterable using isinstance(X, collections.Iterable)
. This will probably uncover bugs in sage where iterables are not deriving from collections.Iterable that then need to be fixed up.
In a different ticket.
comment:7 Changed 9 years ago by
- Description modified (diff)
- Reviewers set to Nathann Cohen
Okayyyyyyyyyyyyyy ! Well, then if you agree with this ...
Nathann
Changed 9 years ago by
comment:8 Changed 9 years ago by
- Status changed from needs_review to positive_review
comment:9 Changed 9 years ago by
THanks !
Nathann
comment:10 Changed 9 years ago by
- Merged in set to sage-5.10.beta1
- Resolution set to fixed
- Status changed from positive_review to closed
Updated patch