[Libre-soc-bugs] [Bug 745] OP_TERNARY instruction

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Wed Dec 8 01:46:37 GMT 2021


https://bugs.libre-soc.org/show_bug.cgi?id=745

--- Comment #25 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #24)
> https://git.libre-soc.org/?p=soc.git;a=commitdiff;
> h=20ffa8ec223be44fc37df5184ca09d648e85a844
> 
> +def get_pspec_draft_bitmanip(pspec):
> +    return getattr(pspec, "draft_bitmanip", False)
> 
> it can't be done that way (at least, i don't think so, can you please
> check and put in a code-comment if it does)

yup, it won't work that way, if pspec is a Mock instance here. Mock will return
new Mock instances for any attribute access. Mock is plain and simple the wrong
tool for the job, dataclasses are better.

>From my reading through the code, it appears as though the pspec passed into
ShiftRot isn't the same pspec created for the whole core, so there shouldn't be
an issue for that particular use case.

> TestMemPspec actually is a subclass of unittest Mock() which has overrides
> on __getattr__ etc. and consequently you cannot just access attributes
> in the "normal" way.
> 
> you'll need to check that getattr() and hasattr() do the same thing:
> they probably don't, which is most likely why i specifically used the
> (odd-looking) "if hasattr(pspec, "attribute") and pspec.attribute == True)"

(hasattr(pspec, "attr") and pspec.attr) isn't any better than getattr(pspec,
"attr", default), cuz hasattr always returns true for any attr string.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list