lib.wiring: fix Component.signature on subclasses without annotations.
On Python <3.10, classes without annotations do not get an `__annotations__` member at all, so the `getattr` on a subclass falls back to the parent class `__annotations__`, attempting to create signature members twice. Fix that by looking at the `__dict__` instead.
This commit is contained in:
parent
c7da6c1292
commit
470477a88f
2 changed files with 14 additions and 1 deletions
|
|
@ -887,3 +887,16 @@ class ComponentTestCase(unittest.TestCase):
|
|||
r"'rand: In\(Signature\({}\)\.flip\(\)\)' or "
|
||||
r"'rand: Out\(Signature\({}\)\.flip\(\)\)'\?$"):
|
||||
PageBuffer()
|
||||
|
||||
def test_inherit(self):
|
||||
class A(Component):
|
||||
clk: In(1)
|
||||
|
||||
class B(A):
|
||||
rst: In(1)
|
||||
|
||||
class C(B):
|
||||
pass
|
||||
|
||||
c = C()
|
||||
self.assertEqual(c.signature, Signature({"clk": In(1), "rst": In(1)}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue