class Elaboratable(metaclass=ABCMeta):
+ _Elaboratable__silence = False
+
def __new__(cls, *args, **kwargs):
self = super().__new__(cls)
self._Elaboratable__traceback = traceback.extract_stack()[:-1]
return self
def __del__(self):
+ if self._Elaboratable__silence:
+ return
if hasattr(self, "_Elaboratable__used") and not self._Elaboratable__used:
print("Elaboratable created but never used\n",
"Traceback (most recent call last):\n",
file=sys.stderr, sep="")
+_old_excepthook = sys.excepthook
+def _silence_elaboratable(type, value, traceback):
+ # Don't show anything if the interpreter crashed; that'd just obscure the exception
+ # traceback instead of helping.
+ Elaboratable._Elaboratable__silence = True
+ _old_excepthook(type, value, traceback)
+sys.excepthook = _silence_elaboratable
+
+
class DriverConflict(UserWarning):
pass