[myhdl-list] possible improvement for error message?
Brought to you by:
jandecaluwe
From: <dan...@we...> - 2005-12-08 01:41:47
|
Jan, When feeding test data from a csv file to a myhdl testbench I got the following error message: File "/usr/lib/python2.4/site-packages/myhdl/_Signal.py", line 172, in _set_next self._setNextVal(val) File "/usr/lib/python2.4/site-packages/myhdl/_Signal.py", line 206, in _setNextBool raise ValueError("Expected value 0 or 1, got %s" % val) ValueError: Expected value 0 or 1, got 1 What happened is that I did not think about converting the data from the python csv reader, which delivers the data as str type, into int type. I think the following change could improve the error message: Index: _Signal.py =================================================================== --- _Signal.py (revision 1.29) +++ _Signal.py (work copy) @@ -202,6 +202,8 @@ # set next methods def _setNextBool(self, val): + if not isinstance(val, (bool, int, long, intbv)): + raise TypeError("Expected bool, int, long, or intbv, got %s"%type(val)) if not val in (0, 1): raise ValueError("Expected value 0 or 1, got %s" % val) self._next = val Cheers, Guenter |