Re: [myhdl-list] Adding information to asserts
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2009-02-27 02:16:00
|
Christopher Felton wrote: > In general as MyHDL is more widely used we come across asserts that can > be enhanced. The enhancements are usually printing out more information > about the error. > > What is the correct pythonic method to add more information (print info) > to an assertion? I assume you do not want to simply add prints, then > the prints occur before the stack dump. First, any assert that escapes to the user should be considered a serious bug (and should be reported as such). The reason why I sometimes use AssertionError in the MyHDL code base, is to save implementation time: sometimes there is a point in the code which would be clearly wrong, but I don't immediately see how one would get there or what the error message should be. To me as a developer, there is a slight advantage of raising an assertion myself, instead of letting Python do it further down the road - but to a user, it is a bug in any case. The proper way to handle errors is to raise a clear exception of the correct type, that includes a message of what is wrong. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a hardware description language: http://www.myhdl.org |