Skip to content

Commit f28b20f

Browse files
committed
lib.wiring: ensure flipped(flipped(intf)) is intf.
1 parent 5a17f94 commit f28b20f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

amaranth/lib/wiring.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,10 @@ def __repr__(self):
552552

553553

554554
def flipped(interface):
555-
return FlippedInterface(interface)
555+
if type(interface) is FlippedInterface:
556+
return interface._FlippedInterface__unflipped
557+
else:
558+
return FlippedInterface(interface)
556559

557560

558561
@final

tests/test_lib_wiring.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ def test_basic(self):
530530
self.assertEqual(tintf, flipped(intf))
531531
self.assertRegex(repr(tintf),
532532
r"^flipped\(<.+?\.Interface object at .+>\)$")
533+
self.assertIs(flipped(tintf), intf)
533534

534535
def test_getattr_setattr(self):
535536
class I(Interface):

0 commit comments

Comments
 (0)