Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 37f363e338ef
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2fa858b00342
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jul 10, 2019

  1. hdl.ir: make UnusedElaboratable a real warning.

    Before this commit, it was a print statement, and therefore, command
    interpreter options like -Wignore did not affect it. There is no API
    to access the warning filter list, so it was turned into a real
    warning; and further, since Python 3.6, tracemalloc can be used
    as a standard method to display traceback to allocation site instead
    of the ad-hoc traceback logic that was used in Elaboratable before.
    whitequark committed Jul 10, 2019
    Copy the full SHA
    2fa858b View commit details
Showing with 12 additions and 8 deletions.
  1. +12 −8 nmigen/hdl/ir.py
20 changes: 12 additions & 8 deletions nmigen/hdl/ir.py
Original file line number Diff line number Diff line change
@@ -10,26 +10,30 @@
from .cd import *


__all__ = ["Elaboratable", "DriverConflict", "Fragment", "Instance"]
__all__ = ["UnusedElaboratable", "Elaboratable", "DriverConflict", "Fragment", "Instance"]


class UnusedElaboratable(Warning):
pass


class Elaboratable(metaclass=ABCMeta):
_Elaboratable__silence = False

def __new__(cls, *args, **kwargs):
def __new__(cls, *args, src_loc_at=0, **kwargs):
self = super().__new__(cls)
self._Elaboratable__traceback = traceback.extract_stack()[:-1]
self._Elaboratable__used = False
self._Elaboratable__src_loc = traceback.extract_stack(limit=2 + src_loc_at)[0]
self._Elaboratable__used = False
return self

def __del__(self):
if self._Elaboratable__silence:
return
if hasattr(self, "_Elaboratable__used") and not self._Elaboratable__used:
print("Warning: elaboratable created but never used\n",
"Constructor traceback (most recent call last):\n",
*traceback.format_list(self._Elaboratable__traceback),
file=sys.stderr, sep="")
warnings.warn_explicit("{!r} created but never used".format(self), UnusedElaboratable,
filename=self._Elaboratable__src_loc.filename,
lineno=self._Elaboratable__src_loc.lineno,
source=self)


_old_excepthook = sys.excepthook