mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
intbv and Signal unhashable
This commit is contained in:
parent
588e240308
commit
9ce961f438
@ -132,6 +132,10 @@ class Signal(object):
|
||||
negedge = property(_get_negedge, None, None, "'posedge' access methodes")
|
||||
|
||||
|
||||
# hashing not supported
|
||||
def __hash__(self):
|
||||
assert TypeError, "Signal objects are unhashable"
|
||||
|
||||
### operators for which delegation to current value is appropriate ###
|
||||
|
||||
def __nonzero__(self):
|
||||
|
@ -102,3 +102,5 @@ In the following, a "sig" denotes an instance of the Signal class.
|
||||
* A sig should have no other public attributes than those described
|
||||
above.
|
||||
|
||||
* Signal objects are unhashable.
|
||||
|
||||
|
@ -69,7 +69,10 @@ class intbv(object):
|
||||
res._len = basewidth + width
|
||||
return res
|
||||
|
||||
|
||||
# hash
|
||||
def __hash__(self):
|
||||
raise TypeError, "intbv objects are unhashable"
|
||||
|
||||
# copy methods
|
||||
def __copy__(self):
|
||||
return intbv(self._val)
|
||||
|
@ -77,6 +77,7 @@ separate type.
|
||||
addition, literal bit strings are accepted in concatenations, just as
|
||||
they are in intbv constructors.
|
||||
|
||||
|
||||
* intbv supports the iterator protocol to iterate on its bits; again,
|
||||
this requires a known length.
|
||||
|
||||
* intbv objects are unhashable
|
||||
|
@ -30,6 +30,11 @@ from Signal import Signal
|
||||
from _simulator import _siglist
|
||||
from intbv import intbv
|
||||
|
||||
class TestSignalUnhashable(TestCase):
|
||||
|
||||
def testSignalUnhashable(self):
|
||||
self.assertRaises(TypeError, hash, Signal(3))
|
||||
|
||||
class SigTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -35,6 +35,10 @@ import operator
|
||||
from intbv import intbv
|
||||
concat = intbv.concat
|
||||
|
||||
class TestIntbvUnhashable(TestCase):
|
||||
|
||||
def testIntbvUnhashable(self):
|
||||
self.assertRaises(TypeError, hash, intbv(3))
|
||||
|
||||
|
||||
class TestIntbvConcat(TestCase):
|
||||
|
Loading…
x
Reference in New Issue
Block a user