Opened 11 years ago
Closed 11 years ago
#10800 closed defect (fixed)
typo in Sequence
Reported by: | dsm | Owned by: | jason |
---|---|---|---|
Priority: | trivial | Milestone: | sage-4.7 |
Component: | misc | Keywords: | |
Cc: | Merged in: | sage-4.7.alpha1 | |
Authors: | Douglas McNeil | Reviewers: | André Apitzsch |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
If you try to hash a mutable sequence, Sage complains that immutable sequences are unhashable..
sage: a = Sequence([1,2,3]) sage: hash(a) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /Applications/sage_devel/<ipython console> in <module>() /Applications/sage/local/lib/python2.6/site-packages/sage/structure/sequence.pyc in __hash__(self) 517 """ 518 if not self._is_immutable: --> 519 raise ValueError, "immutable sequences are unhashable" 520 if self.__hash is None: 521 self.__hash = hash(tuple(self)) ValueError: immutable sequences are unhashable
which is backwards; immutable sequences are the only ones that are hashable.
Attachments (2)
Change History (15)
comment:1 Changed 11 years ago by
- Description modified (diff)
comment:2 Changed 11 years ago by
comment:3 Changed 11 years ago by
- Component changed from PLEASE CHANGE to misc
- Owner changed from tbd to jason
[Going with "misc" because I have no idea what to call this, and I'm tired of looking at "please change"..]
comment:4 Changed 11 years ago by
- Status changed from new to needs_review
comment:5 Changed 11 years ago by
- Milestone set to sage-4.7
- Reviewers set to André Apitzsch
- Status changed from needs_review to positive_review
comment:6 follow-up: ↓ 8 Changed 11 years ago by
- Status changed from positive_review to needs_work
Sorry, positive review was a bit too fast.
Could you change syntax of
raise ValueError, "mutable sequences are unhashable"
to
raise ValueError("mutable sequences are unhashable")
So we don't have to do it when porting sage to python3.
comment:7 Changed 11 years ago by
dsm, please add your e-mail address to the patch file. http://www.sagemath.org/doc/developer/walk_through.html#submitting-a-change
Changed 11 years ago by
comment:8 in reply to: ↑ 6 Changed 11 years ago by
- Status changed from needs_work to needs_review
Replying to aapitzsch:
raise ValueError("mutable sequences are unhashable")So we don't have to do it when porting sage to python3.
Done, but since 2to3 handles this automatically, I'd've thought it made more sense to leave these alone until then.
I've also added an email address. I won't throw anyone under the bus, but I didn't conclude that names were mandatory while email addresses were merely preferred on my own. :-)
comment:10 Changed 11 years ago by
- Status changed from positive_review to needs_work
This needs to be rebased to apply on top of #1819.
Changed 11 years ago by
comment:11 Changed 11 years ago by
- Status changed from needs_work to needs_review
Lots of work to remove two characters from an error message! ;^)
Rebased patch attached.
comment:12 Changed 11 years ago by
- Status changed from needs_review to positive_review
comment:13 Changed 11 years ago by
- Merged in set to sage-4.7.alpha1
- Resolution set to fixed
- Status changed from positive_review to closed
Patch attached (mostly to see if I've got the mercurial-queue-to-patch process right.)