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")
|
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 ###
|
### operators for which delegation to current value is appropriate ###
|
||||||
|
|
||||||
def __nonzero__(self):
|
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
|
* A sig should have no other public attributes than those described
|
||||||
above.
|
above.
|
||||||
|
|
||||||
|
* Signal objects are unhashable.
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ class intbv(object):
|
|||||||
res._len = basewidth + width
|
res._len = basewidth + width
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# hash
|
||||||
|
def __hash__(self):
|
||||||
|
raise TypeError, "intbv objects are unhashable"
|
||||||
|
|
||||||
# copy methods
|
# copy methods
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
|
@ -77,6 +77,7 @@ separate type.
|
|||||||
addition, literal bit strings are accepted in concatenations, just as
|
addition, literal bit strings are accepted in concatenations, just as
|
||||||
they are in intbv constructors.
|
they are in intbv constructors.
|
||||||
|
|
||||||
|
|
||||||
* intbv supports the iterator protocol to iterate on its bits; again,
|
* intbv supports the iterator protocol to iterate on its bits; again,
|
||||||
this requires a known length.
|
this requires a known length.
|
||||||
|
|
||||||
|
* intbv objects are unhashable
|
||||||
|
@ -30,6 +30,11 @@ from Signal import Signal
|
|||||||
from _simulator import _siglist
|
from _simulator import _siglist
|
||||||
from intbv import intbv
|
from intbv import intbv
|
||||||
|
|
||||||
|
class TestSignalUnhashable(TestCase):
|
||||||
|
|
||||||
|
def testSignalUnhashable(self):
|
||||||
|
self.assertRaises(TypeError, hash, Signal(3))
|
||||||
|
|
||||||
class SigTest(TestCase):
|
class SigTest(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -35,6 +35,10 @@ import operator
|
|||||||
from intbv import intbv
|
from intbv import intbv
|
||||||
concat = intbv.concat
|
concat = intbv.concat
|
||||||
|
|
||||||
|
class TestIntbvUnhashable(TestCase):
|
||||||
|
|
||||||
|
def testIntbvUnhashable(self):
|
||||||
|
self.assertRaises(TypeError, hash, intbv(3))
|
||||||
|
|
||||||
|
|
||||||
class TestIntbvConcat(TestCase):
|
class TestIntbvConcat(TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user